From b1d7bd3916a9152e92af37442e199b701ae38696 Mon Sep 17 00:00:00 2001 From: Xabi Losada Date: Fri, 15 Sep 2023 12:23:56 +0200 Subject: [PATCH 01/25] feat: introduce useCallback and useMemo --- CHANGELOG.md | 38 ++++++++++++++++++++++++++++++++++++++ src/lib/vm/vm.js | 46 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1a1131e..80922682 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,43 @@ # Changelog +## Pending + - Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes. + +```jsx +const data = [ + //...some large array +]; + +const filteredData = useMemo(() => { + console.log("Filtering data"); + return data.filter(/* some filtering criteria */); +}, [data]); + +return ( +
+ {filteredData.map(item => ( +
{item.name}
+ ))} +
+); +``` + + - Introduce `useCallback` hook. Similarly to the React hook, it memoizes a callback function and returns that memoized version unless one of its dependencies changes. + ```jsx + const incrementCounter = useCallback(() => { + setCounter(counter + 1); +}, [counter]); + +return ( +
+ Counter = {counter} +
+ +
+
+); +``` + ## 2.4.1 - FIX: Resolve bug with `VM.require` affected by the introduction of `useState` and `useEffect` hooks. diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index b642d7e8..8c83d616 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -1085,7 +1085,51 @@ class VmStack { }); return undefined; - } else if (callee === "setTimeout") { + } else if (callee === "useMemo" || callee === "useCallback") { + if (this.prevStack) { + throw new Error( + `Method: ${callee}. The hook can only be called from the top of the stack` + ); + } + if (!this.vm.hooks) { + throw new Error("Hooks are unavailable for modules"); + } + const isMemo = callee === "useMemo"; + const fnArgName = isMemo ? 'factory' : 'callback'; + if (args.length < 1) { + throw new Error( + `Method: ${callee}. Required arguments: '${fnArgName}'. Optional: 'dependencies'` + ); + } + + const fn = args[0]; + if (!isFunction(fn)) { + throw new Error( + `Method: ${callee}. The first argument '${fnArgName}' must be a function` + ); + } + + const hookIndex = this.hookIndex++; + const dependencies = args[1]; + const hook = this.vm.hooks[hookIndex]; + + if (hook) { + const oldDependencies = hook.dependencies; + if ( + oldDependencies !== undefined && + deepEqual(oldDependencies, dependencies) + ) { + return hook.memoized; + } + } + + const memoized = isMemo ? fn() : fn; + this.vm.setReactHook(hookIndex, { + memoized, + dependencies, + }); + return memoized; + } else if (callee === "setTimeout") { const [callback, timeout] = args; const timer = setTimeout(() => { if (!this.vm.alive) { From a1e34a5a0e31b194e1d2459e4defe0a149d8120a Mon Sep 17 00:00:00 2001 From: medicz <22994538+medicz@users.noreply.github.com> Date: Tue, 19 Sep 2023 17:49:22 +0200 Subject: [PATCH 02/25] rebuild index.js --- dist/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 9c7abdc4..1e3673ac 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new M.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Nr,EthersProviderContext:()=>nn,Widget:()=>_o,useAccount:()=>ae,useAccountId:()=>ce,useCache:()=>wr,useInitNear:()=>Rt,useNear:()=>qt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>A,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>F,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>ut,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>M,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>W,isArray:()=>P,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),A=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var P=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!P(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return P(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},F=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},M=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,F(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,F(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=l(),st=n(764).lW;function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function ft(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ht(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function mt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function gt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){mt(i,n,o,a,c,"next",t)}function c(t){mt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var bt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},wt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},Et={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},xt={get:!0,keys:!0},St=function(){var t=gt(vt().mark((function t(e,r,n,o,i){return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in xt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function kt(t,e,r,n,o,i){return Ot.apply(this,arguments)}function Ot(){return(Ot=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[bt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function jt(t,e){return It.apply(this,arguments)}function It(){return(It=gt(vt().mark((function t(e,r){var n;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return At.apply(this,arguments)}function At(){return(At=gt(vt().mark((function t(e,r){var n,o,i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=bt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Pt(t,e,r,n,o,i){return Nt.apply(this,arguments)}function Nt(){return(Nt=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:st.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(st.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Tt(t,e,r,n){return _t.apply(this,arguments)}function _t(){return(_t=gt(vt().mark((function t(e,r,n,o){var i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=dt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Bt(t){return Ut.apply(this,arguments)}function Ut(){return(Ut=gt(vt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},Et,o):"testnet"===o.networkId&&(o=Object.assign({},wt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Pt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Tt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():St(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return kt(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return jt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Rt=(0,i.singletonHook)({},(function(){var t=dt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:ht(ht({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:ht(ht({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Bt)).then((function(t){return t.map((function(t){return ht(ht({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],Mt=(0,i.singletonHook)(Ft,(function(){var t=dt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Rt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),qt=function(t){return Mt()[t||"default"]||null};const Gt=require("local-storage");var Dt,Jt,$t,zt,Wt=n.n(Gt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Yt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Zt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Yt(i,n,o,a,c,"next",t)}function c(t){Yt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Qt="near-social-vm:v01:",te=Qt+":accountId:",ee=Qt+":pretendAccountId:",re={loading:!0,signedAccountId:null!==(Dt=Wt().get(te))&&void 0!==Dt?Dt:void 0,pretendAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,accountId:null!==($t=null!==(zt=Wt().get(ee))&&void 0!==zt?zt:Wt().get(te))&&void 0!==$t?$t:void 0,state:null,near:null};function ne(t,e){return oe.apply(this,arguments)}function oe(){return(oe=Zt(Vt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ie=function(){var t=Zt(Vt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(te,o),e.config.walletConnectCallback(o)):Wt().remove(te),i=null!==(n=Wt().get(ee))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Zt(Vt().mark((function t(){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Zt(Vt().mark((function t(n){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(ee,n):Wt().remove(ee),t.next=3,ie(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ae=(0,i.singletonHook)(re,(function(){var t=Xt((0,e.useState)(re),2),r=t[0],n=t[1],o=qt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Zt(Vt().mark((function t(e){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ne(o,e);case 2:return t.prev=2,t.next=5,ie(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ce=function(t){var e=qt(),r=ae();if(e&&(!t||e.config.networkId===t))return r.accountId};const ue=require("react-bootstrap/Modal");var se=n.n(ue);const le=require("remark-gfm");var fe=n.n(le);const he=require("react-markdown");var pe=n.n(he);const de=require("react-syntax-highlighter"),ye=require("react-syntax-highlighter/dist/esm/styles/prism"),ve=require("mdast-util-find-and-replace");var me=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function ge(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ve.findAndReplace)(e,me,t),e}}var be=/#(\w+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ve.findAndReplace)(e,be,t),e}}var Ee=["node","children"],xe=["node"],Se=["node"],ke=["node"],Oe=["node"],je=["node","inline","className","children"];function Ie(){return Ie=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ae=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(pe(),{plugins:[],rehypePlugins:[],remarkPlugins:[fe(),ge,we],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Le(t,Ee);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Le(t,xe);return e?r().createElement("a",Ie({onClick:e},n)):r().createElement("a",Ie({target:"_blank"},n))},img:function(t){t.node;var e=Le(t,Se);return r().createElement("img",Ie({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Le(t,ke);return r().createElement("blockquote",Ie({className:"blockquote"},e))},table:function(t){t.node;var e=Le(t,Oe);return r().createElement("table",Ie({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Le(t,je),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(de.Prism,Ie({children:String(o).replace(/\n$/,""),style:ye.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ie({className:n},i),o)}}})};const Ce=require("react-uuid");var Pe=n.n(Ce);function Ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function De(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Je(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){De(i,n,o,a,c,"next",t)}function c(t){De(i,n,o,a,c,"throw",t)}a(void 0)}))}}var $e=x.mul(2e3),ze=x.mul(500),We=x.mul(500),Ke=x.mul(500),Xe=function(){var t=Je(Ge().mark((function t(e,r){var n;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),He=function(){var t=Je(Ge().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return qe(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qe(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==Me(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==Me(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===Me(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Xe(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):ze).add(l?u()(0):Ke).add(We),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):$e),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ve=function(){var t=Je(Ge().mark((function t(e,r,n){return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ye=function(){var t=Je(Ge().mark((function t(e,r,n){var o,i;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(bt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(bt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Ze=require("react-bootstrap"),Qe=require("idb");function tr(t){return tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tr(t)}function er(t,e){if(t){if("string"==typeof t)return rr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rr(t,e):void 0}}function rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ir(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){or(i,n,o,a,c,"next",t)}function c(t){or(i,n,o,a,c,"throw",t)}a(void 0)}))}}function ar(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,Qe.openDB)(e,1,{upgrade:function(t){t.createObjectStore(dr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ir(nr().mark((function t(e){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(dr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ir(nr().mark((function t(e,r){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(dr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:lr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=pr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===fr||i.status===hr&&i.time+3e5>(new Date).getTime()||(i.status===lr&&this.innerGet(t).then((function(t){(t||n)&&i.status===fr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=fr,e&&e().then((function(e){i.status=hr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=hr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===cr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===ur&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||er(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=pr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i){return this.cachedPromise({action:cr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i)}},{key:"asyncFetch",value:(n=ir(nr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise({action:ur,url:t,options:e},(function(){return n.asyncFetch(t,e)}),r)}},{key:"cachedCustomPromise",value:function(t,e,r){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r)}},{key:"socialGet",value:function(t,e,r,n,o,i){if(!t)return null;var a={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},c=this.cachedViewCall(t,t.config.contractName,"get",a,n,i);if(null===c)return null;if(1===e.length)for(var u=e[0].split("/"),s=0;s=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function jr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ir(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ir(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ir(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,xr),p=jr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Sr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Pr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Tr=require("react-bootstrap-typeahead"),_r=require("styled-components");var Br=n.n(_r);const Ur=require("elliptic"),Rr=require("bn.js");var Fr=n.n(Rr);const Mr=require("tweetnacl"),qr=require("iframe-resizer-react");var Gr=n.n(qr);function Dr(){return Dr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Un(t,e,r){return Un=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Rn(o,r.prototype),o},Un.apply(null,arguments)}function Rn(t,e){return Rn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rn(t,e)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,_r.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!no[s.as]&&delete s.as,s.forwardedAs&&!no[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Jn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ue.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(Mn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Xn(Xn({},s),{},{children:g}));if(u)return(0,_r.isStyledComponent)(u)?r().createElement.apply(r(),[u,Xn({},s)].concat(Mn(g))):u(Xn({children:g},s));if("Widget"===o)return r().createElement(_o,s);if("CommitButton"===o)return r().createElement(Nr,Fn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Fe(),s,g);if("Tooltip"===o)return r().createElement(Ze.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Ze.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Tr.Typeahead,s);if("Markdown"===o)return r().createElement(Ae,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Be(),Fn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Be(),s,g);if("iframe"===o)return r().createElement(Hr,s);if("Web3Connect"===o)return r().createElement(on,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Xn({},s)].concat(Mn(g)));if(!1===i)return r().createElement(o,Xn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return ho(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=ao[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2])}if("Social"===t&&"keys"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return this.vm.cachedSocialKeys(r[0],r[1],r[2])}if("Social"===t&&"index"===e){if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return this.vm.cachedIndex(r[0],r[1],r[2])}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe'");var c=Jn(r,5),u=c[0],s=c[1],l=c[2],f=c[3],h=c[4];return this.vm.cachedNearView(u,s,l,f,mo(h,f))}if("Near"===t&&"asyncView"===e){var p;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(p=this.vm).asyncNearView.apply(p,Mn(r))}if("Near"===t&&"block"===e){var d=Jn(r,2),y=d[0],v=d[1];return this.vm.cachedNearBlock(y,mo(v,y))}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(P(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var m;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(m=r[2])&&void 0!==m?m:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return po(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var g=JSON.parse(r[0]);return yo(g),g}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return po(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return po(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return po(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return po(t)}));var b=Object.assign.apply(Object,Mn(r));return yo(b),b}if("fromEntries"===e){var w=Object.fromEntries(r[0]);return yo(w),w}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Wn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var E=r[0];this.vm.state.state=E,this.vm.setReactState(E)}return this.vm.state.state}if("State"===t&&"update"===e){var x;if(N(r[0]))this.vm.state.state=null!==(x=this.vm.state.state)&&void 0!==x?x:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var S;this.vm.state.state=null!==(S=this.vm.state.state)&&void 0!==S?S:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:eo},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:eo},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:ro},r[0],r[1])}if("Storage"===t&&"get"===e){var k;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(k=r[1])&&void 0!==k?k:this.vm.widgetSrc,type:ro},r[0])}var O,j,I;if("console"===t&&"log"===e)return(O=console).log.apply(O,[this.vm.widgetSrc].concat(Mn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(j=navigator.clipboard).writeText.apply(j,Mn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(I=this.vm).vmRequire.apply(I,Mn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var L,A=null===(L=this.vm.ethersProviderContext)||void 0===L?void 0:L.setChain;if(!A)throw new Error("The gateway doesn't support `setChain` operation");return A.apply(void 0,Mn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var C=Un(WebSocket,Mn(r));return this.vm.websockets.push(C),C}throw new Error("Unsupported WebSocket method")}if(void 0===a){if(co.hasOwnProperty(e))return co[e].apply(co,Mn(r));if("fetch"===e){var T;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(T=this.vm).cachedFetch.apply(T,Mn(r))}if("asyncFetch"===e){var B;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(B=this.vm).asyncFetch.apply(B,Mn(r))}if("useCache"===e){var U;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(U=this.vm).useCache.apply(U,Mn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var R=r[0],F=this.hookIndex++,M=this.vm.hooks[F];if(M)return[M.state,M.setState];var q=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[F])||void 0===r?void 0:r.state)),i.vm.setReactHook(F,{state:e,setState:t}),e};return[q(R),q]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var G=r[0];if(!_(G))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var D=this.hookIndex++,J=r[1],$=this.vm.hooks[D];if($){var z=$.dependencies;if(void 0!==z&&ut(z,J))return}var W=null==$?void 0:$.cleanup;return _(W)&&W(),void this.vm.setReactHook(D,{cleanup:G(),dependencies:J})}if("setTimeout"===e){var K=Jn(r,2),X=K[0],H=K[1],V=setTimeout((function(){i.vm.alive&&X()}),H);return this.vm.timeouts.add(V),V}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var Y=Jn(r,2),Z=Y[0],Q=Y[1],tt=setInterval((function(){i.vm.alive&&Z()}),Q);return this.vm.intervals.add(tt),tt}if("clearTimeout"===e){var et=r[0];return this.vm.timeouts.delete(et),clearTimeout(et)}if("clearInterval"===e){var rt=r[0];return this.vm.intervals.delete(rt),clearInterval(rt)}}}}else{var nt=e===t?a:a[e];if("function"==typeof nt)return o?Un(nt,Mn(r)):nt.apply(void 0,Mn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(ho(n),null!=e&&e.requireState&&n!==to)throw new Error("The top object should be ".concat(to));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(po(o),o===this.stack.state&&n in ao){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in ao){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return po(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,Mn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Wn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,A=I.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);po(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,P;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=vo(B);if(!(0,_r.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Br()(null!=U?U:B)}else{if("keyframes"===T)C=_r.keyframes;else{if(!(T in no))throw new Error("Unsupported styled tag: "+T);C=Br()(T)}P=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,M=JSON.stringify([P].concat(Mn(R)));if(F&&this.vm.cachedStyledComponents.has(M))return this.vm.cachedStyledComponents.get(M);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(Mn(q)));return F&&this.vm.cachedStyledComponents.set(M,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(Eo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);po(s);var l,f=Bn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(Eo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Wn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(go(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Bn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,A=!1,C=Bn(I.consequent);try{for(C.s();!(L=C.n()).done;){var P=L.value,N=k.executeStatement(P);if(N){if(N.break){A=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(A)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),ko=function(){function t(e){var r,n=this;qn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in lo?lo[o]:lo[o]=fo.parse(o,so),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=h,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Dn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.socialGet(o.near,t,e,r,n,i)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r){var n=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(o){return n.cache.cachedViewCall(n.near,n.near.config.contractName,"keys",{keys:t,options:r},e,o)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedEthersCall(n.ethersProvider,t,e,r)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o){var i=this;return this.cachedPromise((function(o){return i.cache.cachedViewCall(i.near,t,e,r,n,o)}),o)}},{key:"cachedNearBlock",value:function(t,e){var r=this;return this.cachedPromise((function(e){return r.cache.cachedBlock(r.near,t,e)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.cachedFetch(t,e,n)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.socialIndex(n.near,t,e,r,o)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedCustomPromise({widgetSrc:n.widgetSrc,dataKey:e},t,r)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=Jn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state={props:N(e)?Object.assign({},e):e,context:r,state:c,nacl:Yn,get elliptic(){return delete this.elliptic,this.elliptic=Zr().cloneDeep(Ur),this.elliptic},ethers:Zn,nanoid:Qn},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new So(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Oo=require("react-error-boundary");function jo(t){return jo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jo(t)}var Io=["loading","src","code","depth","config","props"];function Lo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ao(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Io),p=Po((0,e.useState)(0),2),d=p[0],y=p[1],v=Po((0,e.useState)(null),2),m=v[0],g=v[1],b=Po((0,e.useState)(null),2),E=b[0],x=b[1],S=Po((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=Po((0,e.useState)(0),2),I=j[0],C=j[1],P=Po((0,e.useState)({}),2),B=P[0],U=P[1],R=Po((0,e.useState)(null),2),F=R[0],M=R[1],q=Po((0,e.useState)(null),2),G=q[0],D=q[1],J=Po((0,e.useState)(null),2),$=J[0],z=J[1],W=Po((0,e.useState)(null),2),K=W[0],X=W[1],H=Po((0,e.useState)(null),2),V=H[0],Y=H[1],Z=Po((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(nn),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=wr(rt),ot=qt(rt),it=ce(rt),at=Po((0,e.useState)(null),2),st=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];ut(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=No(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);ut(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=Po(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){M(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),z(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new ko({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Pe()(),widgetConfigs:V,ethersProviderContext:et});return M(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(F){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:F.version,forwardedProps:Ao(Ao({},h),{},{ref:n})};if(!ut(t,K)){X(ct(t));try{var e;lt(null!==(e=F.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[F,f,B,k,I,K,n,h]),null!=st?r().createElement(Oo.ErrorBoundary,{FallbackComponent:A,onReset:function(){lt(null)},resetKeys:[st]},r().createElement(r().Fragment,null,st,G&&r().createElement(Te,{transactions:G,onHide:function(){return D(null)},networkId:rt}),$&&r().createElement(Pr,{show:!0,widgetSrc:E,data:$.data,force:$.force,onHide:function(){return z(null)},onCommit:$.onCommit,onCancel:$.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function z(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Nr,EthersProviderContext:()=>nn,Widget:()=>_o,useAccount:()=>ae,useAccountId:()=>ce,useCache:()=>wr,useInitNear:()=>Rt,useNear:()=>qt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>A,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>ut,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,indexMatch:()=>et,ipfsUpload:()=>$,ipfsUrl:()=>W,isArray:()=>P,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>z,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),A=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var P=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!P(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return P(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},z=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=l(),st=n(764).lW;function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function ft(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ht(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function mt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function gt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){mt(i,n,o,a,c,"next",t)}function c(t){mt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var bt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},wt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},Et={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},xt={get:!0,keys:!0},St=function(){var t=gt(vt().mark((function t(e,r,n,o,i){return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in xt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function kt(t,e,r,n,o,i){return Ot.apply(this,arguments)}function Ot(){return(Ot=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[bt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function jt(t,e){return It.apply(this,arguments)}function It(){return(It=gt(vt().mark((function t(e,r){var n;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return At.apply(this,arguments)}function At(){return(At=gt(vt().mark((function t(e,r){var n,o,i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=bt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Pt(t,e,r,n,o,i){return Nt.apply(this,arguments)}function Nt(){return(Nt=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:st.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(st.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Tt(t,e,r,n){return _t.apply(this,arguments)}function _t(){return(_t=gt(vt().mark((function t(e,r,n,o){var i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=dt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Bt(t){return Ut.apply(this,arguments)}function Ut(){return(Ut=gt(vt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},Et,o):"testnet"===o.networkId&&(o=Object.assign({},wt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Pt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Tt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():St(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return kt(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return jt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Rt=(0,i.singletonHook)({},(function(){var t=dt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:ht(ht({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:ht(ht({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Bt)).then((function(t){return t.map((function(t){return ht(ht({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Mt=[],Ft=(0,i.singletonHook)(Mt,(function(){var t=dt((0,e.useState)(Mt),2),r=t[0],n=t[1],o=Rt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),qt=function(t){return Ft()[t||"default"]||null};const Gt=require("local-storage");var Dt,Jt,zt,$t,Wt=n.n(Gt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Yt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Zt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Yt(i,n,o,a,c,"next",t)}function c(t){Yt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Qt="near-social-vm:v01:",te=Qt+":accountId:",ee=Qt+":pretendAccountId:",re={loading:!0,signedAccountId:null!==(Dt=Wt().get(te))&&void 0!==Dt?Dt:void 0,pretendAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,accountId:null!==(zt=null!==($t=Wt().get(ee))&&void 0!==$t?$t:Wt().get(te))&&void 0!==zt?zt:void 0,state:null,near:null};function ne(t,e){return oe.apply(this,arguments)}function oe(){return(oe=Zt(Vt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ie=function(){var t=Zt(Vt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(te,o),e.config.walletConnectCallback(o)):Wt().remove(te),i=null!==(n=Wt().get(ee))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Zt(Vt().mark((function t(){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Zt(Vt().mark((function t(n){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(ee,n):Wt().remove(ee),t.next=3,ie(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ae=(0,i.singletonHook)(re,(function(){var t=Xt((0,e.useState)(re),2),r=t[0],n=t[1],o=qt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Zt(Vt().mark((function t(e){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ne(o,e);case 2:return t.prev=2,t.next=5,ie(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ce=function(t){var e=qt(),r=ae();if(e&&(!t||e.config.networkId===t))return r.accountId};const ue=require("react-bootstrap/Modal");var se=n.n(ue);const le=require("remark-gfm");var fe=n.n(le);const he=require("react-markdown");var pe=n.n(he);const de=require("react-syntax-highlighter"),ye=require("react-syntax-highlighter/dist/esm/styles/prism"),ve=require("mdast-util-find-and-replace");var me=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function ge(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ve.findAndReplace)(e,me,t),e}}var be=/#(\w+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ve.findAndReplace)(e,be,t),e}}var Ee=["node","children"],xe=["node"],Se=["node"],ke=["node"],Oe=["node"],je=["node","inline","className","children"];function Ie(){return Ie=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ae=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(pe(),{plugins:[],rehypePlugins:[],remarkPlugins:[fe(),ge,we],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Le(t,Ee);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Le(t,xe);return e?r().createElement("a",Ie({onClick:e},n)):r().createElement("a",Ie({target:"_blank"},n))},img:function(t){t.node;var e=Le(t,Se);return r().createElement("img",Ie({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Le(t,ke);return r().createElement("blockquote",Ie({className:"blockquote"},e))},table:function(t){t.node;var e=Le(t,Oe);return r().createElement("table",Ie({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Le(t,je),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(de.Prism,Ie({children:String(o).replace(/\n$/,""),style:ye.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ie({className:n},i),o)}}})};const Ce=require("react-uuid");var Pe=n.n(Ce);function Ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function De(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Je(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){De(i,n,o,a,c,"next",t)}function c(t){De(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ze=x.mul(2e3),$e=x.mul(500),We=x.mul(500),Ke=x.mul(500),Xe=function(){var t=Je(Ge().mark((function t(e,r){var n;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),He=function(){var t=Je(Ge().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return qe(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qe(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==Fe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==Fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===Fe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Xe(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):$e).add(l?u()(0):Ke).add(We),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):ze),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ve=function(){var t=Je(Ge().mark((function t(e,r,n){return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ye=function(){var t=Je(Ge().mark((function t(e,r,n){var o,i;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(bt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(bt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Ze=require("react-bootstrap"),Qe=require("idb");function tr(t){return tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tr(t)}function er(t,e){if(t){if("string"==typeof t)return rr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rr(t,e):void 0}}function rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ir(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){or(i,n,o,a,c,"next",t)}function c(t){or(i,n,o,a,c,"throw",t)}a(void 0)}))}}function ar(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,Qe.openDB)(e,1,{upgrade:function(t){t.createObjectStore(dr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ir(nr().mark((function t(e){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(dr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ir(nr().mark((function t(e,r){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(dr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:lr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=pr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===fr||i.status===hr&&i.time+3e5>(new Date).getTime()||(i.status===lr&&this.innerGet(t).then((function(t){(t||n)&&i.status===fr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=fr,e&&e().then((function(e){i.status=hr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=hr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===cr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===ur&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||er(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=pr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i){return this.cachedPromise({action:cr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i)}},{key:"asyncFetch",value:(n=ir(nr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise({action:ur,url:t,options:e},(function(){return n.asyncFetch(t,e)}),r)}},{key:"cachedCustomPromise",value:function(t,e,r){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r)}},{key:"socialGet",value:function(t,e,r,n,o,i){if(!t)return null;var a={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},c=this.cachedViewCall(t,t.config.contractName,"get",a,n,i);if(null===c)return null;if(1===e.length)for(var u=e[0].split("/"),s=0;s=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function jr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ir(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ir(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ir(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,xr),p=jr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Sr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Pr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Tr=require("react-bootstrap-typeahead"),_r=require("styled-components");var Br=n.n(_r);const Ur=require("elliptic"),Rr=require("bn.js");var Mr=n.n(Rr);const Fr=require("tweetnacl"),qr=require("iframe-resizer-react");var Gr=n.n(qr);function Dr(){return Dr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Un(t,e,r){return Un=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Rn(o,r.prototype),o},Un.apply(null,arguments)}function Rn(t,e){return Rn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rn(t,e)}function Mn(){return Mn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,_r.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!no[s.as]&&delete s.as,s.forwardedAs&&!no[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Jn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ue.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(Fn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Xn(Xn({},s),{},{children:g}));if(u)return(0,_r.isStyledComponent)(u)?r().createElement.apply(r(),[u,Xn({},s)].concat(Fn(g))):u(Xn({children:g},s));if("Widget"===o)return r().createElement(_o,s);if("CommitButton"===o)return r().createElement(Nr,Mn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Me(),s,g);if("Tooltip"===o)return r().createElement(Ze.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Ze.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Tr.Typeahead,s);if("Markdown"===o)return r().createElement(Ae,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Be(),Mn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Be(),s,g);if("iframe"===o)return r().createElement(Hr,s);if("Web3Connect"===o)return r().createElement(on,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Xn({},s)].concat(Fn(g)));if(!1===i)return r().createElement(o,Xn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return ho(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=ao[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2])}if("Social"===t&&"keys"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return this.vm.cachedSocialKeys(r[0],r[1],r[2])}if("Social"===t&&"index"===e){if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return this.vm.cachedIndex(r[0],r[1],r[2])}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe'");var c=Jn(r,5),u=c[0],s=c[1],l=c[2],f=c[3],h=c[4];return this.vm.cachedNearView(u,s,l,f,mo(h,f))}if("Near"===t&&"asyncView"===e){var p;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(p=this.vm).asyncNearView.apply(p,Fn(r))}if("Near"===t&&"block"===e){var d=Jn(r,2),y=d[0],v=d[1];return this.vm.cachedNearBlock(y,mo(v,y))}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(P(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var m;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(m=r[2])&&void 0!==m?m:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return po(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var g=JSON.parse(r[0]);return yo(g),g}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return po(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return po(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return po(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return po(t)}));var b=Object.assign.apply(Object,Fn(r));return yo(b),b}if("fromEntries"===e){var w=Object.fromEntries(r[0]);return yo(w),w}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Wn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var E=r[0];this.vm.state.state=E,this.vm.setReactState(E)}return this.vm.state.state}if("State"===t&&"update"===e){var x;if(N(r[0]))this.vm.state.state=null!==(x=this.vm.state.state)&&void 0!==x?x:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var S;this.vm.state.state=null!==(S=this.vm.state.state)&&void 0!==S?S:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:eo},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:eo},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:ro},r[0],r[1])}if("Storage"===t&&"get"===e){var k;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(k=r[1])&&void 0!==k?k:this.vm.widgetSrc,type:ro},r[0])}var O,j,I;if("console"===t&&"log"===e)return(O=console).log.apply(O,[this.vm.widgetSrc].concat(Fn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(j=navigator.clipboard).writeText.apply(j,Fn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(I=this.vm).vmRequire.apply(I,Fn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var L,A=null===(L=this.vm.ethersProviderContext)||void 0===L?void 0:L.setChain;if(!A)throw new Error("The gateway doesn't support `setChain` operation");return A.apply(void 0,Fn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var C=Un(WebSocket,Fn(r));return this.vm.websockets.push(C),C}throw new Error("Unsupported WebSocket method")}if(void 0===a){if(co.hasOwnProperty(e))return co[e].apply(co,Fn(r));if("fetch"===e){var T;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(T=this.vm).cachedFetch.apply(T,Fn(r))}if("asyncFetch"===e){var B;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(B=this.vm).asyncFetch.apply(B,Fn(r))}if("useCache"===e){var U;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(U=this.vm).useCache.apply(U,Fn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var R=r[0],M=this.hookIndex++,F=this.vm.hooks[M];if(F)return[F.state,F.setState];var q=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[M])||void 0===r?void 0:r.state)),i.vm.setReactHook(M,{state:e,setState:t}),e};return[q(R),q]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var G=r[0];if(!_(G))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var D=this.hookIndex++,J=r[1],z=this.vm.hooks[D];if(z){var $=z.dependencies;if(void 0!==$&&ut($,J))return}var W=null==z?void 0:z.cleanup;return _(W)&&W(),void this.vm.setReactHook(D,{cleanup:G(),dependencies:J})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var K="useMemo"===e,X=K?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(X,"'. Optional: 'dependencies'"));var H=r[0];if(!_(H))throw new Error("Method: ".concat(e,". The first argument '").concat(X,"' must be a function"));var V=this.hookIndex++,Y=r[1],Z=this.vm.hooks[V];if(Z){var Q=Z.dependencies;if(void 0!==Q&&ut(Q,Y))return Z.memoized}var tt=K?H():H;return this.vm.setReactHook(V,{memoized:tt,dependencies:Y}),tt}if("setTimeout"===e){var et=Jn(r,2),rt=et[0],nt=et[1],ot=setTimeout((function(){i.vm.alive&&rt()}),nt);return this.vm.timeouts.add(ot),ot}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var it=Jn(r,2),ct=it[0],st=it[1],lt=setInterval((function(){i.vm.alive&&ct()}),st);return this.vm.intervals.add(lt),lt}if("clearTimeout"===e){var ft=r[0];return this.vm.timeouts.delete(ft),clearTimeout(ft)}if("clearInterval"===e){var ht=r[0];return this.vm.intervals.delete(ht),clearInterval(ht)}}}}else{var pt=e===t?a:a[e];if("function"==typeof pt)return o?Un(pt,Fn(r)):pt.apply(void 0,Fn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(ho(n),null!=e&&e.requireState&&n!==to)throw new Error("The top object should be ".concat(to));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(po(o),o===this.stack.state&&n in ao){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in ao){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return po(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,Fn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Wn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,A=I.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);po(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,P;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=vo(B);if(!(0,_r.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Br()(null!=U?U:B)}else{if("keyframes"===T)C=_r.keyframes;else{if(!(T in no))throw new Error("Unsupported styled tag: "+T);C=Br()(T)}P=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([P].concat(Fn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(Fn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(Eo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);po(s);var l,f=Bn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(Eo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Wn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(go(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Bn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,A=!1,C=Bn(I.consequent);try{for(C.s();!(L=C.n()).done;){var P=L.value,N=k.executeStatement(P);if(N){if(N.break){A=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(A)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),ko=function(){function t(e){var r,n=this;qn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in lo?lo[o]:lo[o]=fo.parse(o,so),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=h,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Dn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.socialGet(o.near,t,e,r,n,i)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r){var n=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(o){return n.cache.cachedViewCall(n.near,n.near.config.contractName,"keys",{keys:t,options:r},e,o)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedEthersCall(n.ethersProvider,t,e,r)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o){var i=this;return this.cachedPromise((function(o){return i.cache.cachedViewCall(i.near,t,e,r,n,o)}),o)}},{key:"cachedNearBlock",value:function(t,e){var r=this;return this.cachedPromise((function(e){return r.cache.cachedBlock(r.near,t,e)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.cachedFetch(t,e,n)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.socialIndex(n.near,t,e,r,o)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedCustomPromise({widgetSrc:n.widgetSrc,dataKey:e},t,r)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=Jn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state={props:N(e)?Object.assign({},e):e,context:r,state:c,nacl:Yn,get elliptic(){return delete this.elliptic,this.elliptic=Zr().cloneDeep(Ur),this.elliptic},ethers:Zn,nanoid:Qn},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new So(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Oo=require("react-error-boundary");function jo(t){return jo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jo(t)}var Io=["loading","src","code","depth","config","props"];function Lo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ao(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Io),p=Po((0,e.useState)(0),2),d=p[0],y=p[1],v=Po((0,e.useState)(null),2),m=v[0],g=v[1],b=Po((0,e.useState)(null),2),E=b[0],x=b[1],S=Po((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=Po((0,e.useState)(0),2),I=j[0],C=j[1],P=Po((0,e.useState)({}),2),B=P[0],U=P[1],R=Po((0,e.useState)(null),2),M=R[0],F=R[1],q=Po((0,e.useState)(null),2),G=q[0],D=q[1],J=Po((0,e.useState)(null),2),z=J[0],$=J[1],W=Po((0,e.useState)(null),2),K=W[0],X=W[1],H=Po((0,e.useState)(null),2),V=H[0],Y=H[1],Z=Po((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(nn),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=wr(rt),ot=qt(rt),it=ce(rt),at=Po((0,e.useState)(null),2),st=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];ut(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=No(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);ut(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=Po(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),$(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new ko({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Pe()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Ao(Ao({},h),{},{ref:n})};if(!ut(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=st?r().createElement(Oo.ErrorBoundary,{FallbackComponent:A,onReset:function(){lt(null)},resetKeys:[st]},r().createElement(r().Fragment,null,st,G&&r().createElement(Te,{transactions:G,onHide:function(){return D(null)},networkId:rt}),z&&r().createElement(Pr,{show:!0,widgetSrc:E,data:z.data,force:z.force,onHide:function(){return $(null)},onCommit:z.onCommit,onCancel:z.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file From 26d78f33d2650523a2e79932f63c9de54f6470b3 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Tue, 19 Sep 2023 10:54:23 -0700 Subject: [PATCH 03/25] Fix vm.depth --- CHANGELOG.md | 6 ++++-- dist/index.js | 2 +- src/lib/vm/vm.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80922682..00b9f705 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # Changelog ## Pending - - Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes. + +- Fix `vm.depth` not being initialized. +- Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes. ```jsx const data = [ @@ -22,7 +24,7 @@ return ( ); ``` - - Introduce `useCallback` hook. Similarly to the React hook, it memoizes a callback function and returns that memoized version unless one of its dependencies changes. +- Introduce `useCallback` hook. Similarly to the React hook, it memoizes a callback function and returns that memoized version unless one of its dependencies changes. ```jsx const incrementCounter = useCallback(() => { setCounter(counter + 1); diff --git a/dist/index.js b/dist/index.js index 1e3673ac..144923e3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function z(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Nr,EthersProviderContext:()=>nn,Widget:()=>_o,useAccount:()=>ae,useAccountId:()=>ce,useCache:()=>wr,useInitNear:()=>Rt,useNear:()=>qt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>A,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>ut,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,indexMatch:()=>et,ipfsUpload:()=>$,ipfsUrl:()=>W,isArray:()=>P,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>z,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),A=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var P=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!P(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return P(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},z=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=l(),st=n(764).lW;function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function ft(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ht(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function mt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function gt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){mt(i,n,o,a,c,"next",t)}function c(t){mt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var bt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},wt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},Et={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},xt={get:!0,keys:!0},St=function(){var t=gt(vt().mark((function t(e,r,n,o,i){return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in xt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function kt(t,e,r,n,o,i){return Ot.apply(this,arguments)}function Ot(){return(Ot=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[bt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function jt(t,e){return It.apply(this,arguments)}function It(){return(It=gt(vt().mark((function t(e,r){var n;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return At.apply(this,arguments)}function At(){return(At=gt(vt().mark((function t(e,r){var n,o,i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=bt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Pt(t,e,r,n,o,i){return Nt.apply(this,arguments)}function Nt(){return(Nt=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:st.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(st.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Tt(t,e,r,n){return _t.apply(this,arguments)}function _t(){return(_t=gt(vt().mark((function t(e,r,n,o){var i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=dt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Bt(t){return Ut.apply(this,arguments)}function Ut(){return(Ut=gt(vt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},Et,o):"testnet"===o.networkId&&(o=Object.assign({},wt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Pt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Tt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():St(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return kt(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return jt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Rt=(0,i.singletonHook)({},(function(){var t=dt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:ht(ht({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:ht(ht({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Bt)).then((function(t){return t.map((function(t){return ht(ht({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Mt=[],Ft=(0,i.singletonHook)(Mt,(function(){var t=dt((0,e.useState)(Mt),2),r=t[0],n=t[1],o=Rt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),qt=function(t){return Ft()[t||"default"]||null};const Gt=require("local-storage");var Dt,Jt,zt,$t,Wt=n.n(Gt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Yt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Zt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Yt(i,n,o,a,c,"next",t)}function c(t){Yt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Qt="near-social-vm:v01:",te=Qt+":accountId:",ee=Qt+":pretendAccountId:",re={loading:!0,signedAccountId:null!==(Dt=Wt().get(te))&&void 0!==Dt?Dt:void 0,pretendAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,accountId:null!==(zt=null!==($t=Wt().get(ee))&&void 0!==$t?$t:Wt().get(te))&&void 0!==zt?zt:void 0,state:null,near:null};function ne(t,e){return oe.apply(this,arguments)}function oe(){return(oe=Zt(Vt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ie=function(){var t=Zt(Vt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(te,o),e.config.walletConnectCallback(o)):Wt().remove(te),i=null!==(n=Wt().get(ee))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Zt(Vt().mark((function t(){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Zt(Vt().mark((function t(n){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(ee,n):Wt().remove(ee),t.next=3,ie(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ae=(0,i.singletonHook)(re,(function(){var t=Xt((0,e.useState)(re),2),r=t[0],n=t[1],o=qt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Zt(Vt().mark((function t(e){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ne(o,e);case 2:return t.prev=2,t.next=5,ie(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ce=function(t){var e=qt(),r=ae();if(e&&(!t||e.config.networkId===t))return r.accountId};const ue=require("react-bootstrap/Modal");var se=n.n(ue);const le=require("remark-gfm");var fe=n.n(le);const he=require("react-markdown");var pe=n.n(he);const de=require("react-syntax-highlighter"),ye=require("react-syntax-highlighter/dist/esm/styles/prism"),ve=require("mdast-util-find-and-replace");var me=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function ge(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ve.findAndReplace)(e,me,t),e}}var be=/#(\w+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ve.findAndReplace)(e,be,t),e}}var Ee=["node","children"],xe=["node"],Se=["node"],ke=["node"],Oe=["node"],je=["node","inline","className","children"];function Ie(){return Ie=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ae=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(pe(),{plugins:[],rehypePlugins:[],remarkPlugins:[fe(),ge,we],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Le(t,Ee);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Le(t,xe);return e?r().createElement("a",Ie({onClick:e},n)):r().createElement("a",Ie({target:"_blank"},n))},img:function(t){t.node;var e=Le(t,Se);return r().createElement("img",Ie({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Le(t,ke);return r().createElement("blockquote",Ie({className:"blockquote"},e))},table:function(t){t.node;var e=Le(t,Oe);return r().createElement("table",Ie({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Le(t,je),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(de.Prism,Ie({children:String(o).replace(/\n$/,""),style:ye.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ie({className:n},i),o)}}})};const Ce=require("react-uuid");var Pe=n.n(Ce);function Ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function De(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Je(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){De(i,n,o,a,c,"next",t)}function c(t){De(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ze=x.mul(2e3),$e=x.mul(500),We=x.mul(500),Ke=x.mul(500),Xe=function(){var t=Je(Ge().mark((function t(e,r){var n;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),He=function(){var t=Je(Ge().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return qe(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qe(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==Fe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==Fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===Fe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Xe(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):$e).add(l?u()(0):Ke).add(We),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):ze),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ve=function(){var t=Je(Ge().mark((function t(e,r,n){return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ye=function(){var t=Je(Ge().mark((function t(e,r,n){var o,i;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(bt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(bt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Ze=require("react-bootstrap"),Qe=require("idb");function tr(t){return tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tr(t)}function er(t,e){if(t){if("string"==typeof t)return rr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rr(t,e):void 0}}function rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ir(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){or(i,n,o,a,c,"next",t)}function c(t){or(i,n,o,a,c,"throw",t)}a(void 0)}))}}function ar(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,Qe.openDB)(e,1,{upgrade:function(t){t.createObjectStore(dr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ir(nr().mark((function t(e){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(dr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ir(nr().mark((function t(e,r){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(dr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:lr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=pr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===fr||i.status===hr&&i.time+3e5>(new Date).getTime()||(i.status===lr&&this.innerGet(t).then((function(t){(t||n)&&i.status===fr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=fr,e&&e().then((function(e){i.status=hr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=hr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===cr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===ur&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||er(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=pr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i){return this.cachedPromise({action:cr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i)}},{key:"asyncFetch",value:(n=ir(nr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise({action:ur,url:t,options:e},(function(){return n.asyncFetch(t,e)}),r)}},{key:"cachedCustomPromise",value:function(t,e,r){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r)}},{key:"socialGet",value:function(t,e,r,n,o,i){if(!t)return null;var a={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},c=this.cachedViewCall(t,t.config.contractName,"get",a,n,i);if(null===c)return null;if(1===e.length)for(var u=e[0].split("/"),s=0;s=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function jr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ir(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ir(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ir(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,xr),p=jr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Sr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Pr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Tr=require("react-bootstrap-typeahead"),_r=require("styled-components");var Br=n.n(_r);const Ur=require("elliptic"),Rr=require("bn.js");var Mr=n.n(Rr);const Fr=require("tweetnacl"),qr=require("iframe-resizer-react");var Gr=n.n(qr);function Dr(){return Dr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Un(t,e,r){return Un=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Rn(o,r.prototype),o},Un.apply(null,arguments)}function Rn(t,e){return Rn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rn(t,e)}function Mn(){return Mn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,_r.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!no[s.as]&&delete s.as,s.forwardedAs&&!no[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Jn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ue.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(Fn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Xn(Xn({},s),{},{children:g}));if(u)return(0,_r.isStyledComponent)(u)?r().createElement.apply(r(),[u,Xn({},s)].concat(Fn(g))):u(Xn({children:g},s));if("Widget"===o)return r().createElement(_o,s);if("CommitButton"===o)return r().createElement(Nr,Mn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Me(),s,g);if("Tooltip"===o)return r().createElement(Ze.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Ze.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Tr.Typeahead,s);if("Markdown"===o)return r().createElement(Ae,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Be(),Mn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Be(),s,g);if("iframe"===o)return r().createElement(Hr,s);if("Web3Connect"===o)return r().createElement(on,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Xn({},s)].concat(Fn(g)));if(!1===i)return r().createElement(o,Xn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return ho(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=ao[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2])}if("Social"===t&&"keys"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return this.vm.cachedSocialKeys(r[0],r[1],r[2])}if("Social"===t&&"index"===e){if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return this.vm.cachedIndex(r[0],r[1],r[2])}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe'");var c=Jn(r,5),u=c[0],s=c[1],l=c[2],f=c[3],h=c[4];return this.vm.cachedNearView(u,s,l,f,mo(h,f))}if("Near"===t&&"asyncView"===e){var p;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(p=this.vm).asyncNearView.apply(p,Fn(r))}if("Near"===t&&"block"===e){var d=Jn(r,2),y=d[0],v=d[1];return this.vm.cachedNearBlock(y,mo(v,y))}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(P(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var m;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(m=r[2])&&void 0!==m?m:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return po(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var g=JSON.parse(r[0]);return yo(g),g}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return po(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return po(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return po(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return po(t)}));var b=Object.assign.apply(Object,Fn(r));return yo(b),b}if("fromEntries"===e){var w=Object.fromEntries(r[0]);return yo(w),w}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Wn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var E=r[0];this.vm.state.state=E,this.vm.setReactState(E)}return this.vm.state.state}if("State"===t&&"update"===e){var x;if(N(r[0]))this.vm.state.state=null!==(x=this.vm.state.state)&&void 0!==x?x:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var S;this.vm.state.state=null!==(S=this.vm.state.state)&&void 0!==S?S:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:eo},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:eo},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:ro},r[0],r[1])}if("Storage"===t&&"get"===e){var k;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(k=r[1])&&void 0!==k?k:this.vm.widgetSrc,type:ro},r[0])}var O,j,I;if("console"===t&&"log"===e)return(O=console).log.apply(O,[this.vm.widgetSrc].concat(Fn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(j=navigator.clipboard).writeText.apply(j,Fn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(I=this.vm).vmRequire.apply(I,Fn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var L,A=null===(L=this.vm.ethersProviderContext)||void 0===L?void 0:L.setChain;if(!A)throw new Error("The gateway doesn't support `setChain` operation");return A.apply(void 0,Fn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var C=Un(WebSocket,Fn(r));return this.vm.websockets.push(C),C}throw new Error("Unsupported WebSocket method")}if(void 0===a){if(co.hasOwnProperty(e))return co[e].apply(co,Fn(r));if("fetch"===e){var T;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(T=this.vm).cachedFetch.apply(T,Fn(r))}if("asyncFetch"===e){var B;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(B=this.vm).asyncFetch.apply(B,Fn(r))}if("useCache"===e){var U;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(U=this.vm).useCache.apply(U,Fn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var R=r[0],M=this.hookIndex++,F=this.vm.hooks[M];if(F)return[F.state,F.setState];var q=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[M])||void 0===r?void 0:r.state)),i.vm.setReactHook(M,{state:e,setState:t}),e};return[q(R),q]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var G=r[0];if(!_(G))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var D=this.hookIndex++,J=r[1],z=this.vm.hooks[D];if(z){var $=z.dependencies;if(void 0!==$&&ut($,J))return}var W=null==z?void 0:z.cleanup;return _(W)&&W(),void this.vm.setReactHook(D,{cleanup:G(),dependencies:J})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var K="useMemo"===e,X=K?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(X,"'. Optional: 'dependencies'"));var H=r[0];if(!_(H))throw new Error("Method: ".concat(e,". The first argument '").concat(X,"' must be a function"));var V=this.hookIndex++,Y=r[1],Z=this.vm.hooks[V];if(Z){var Q=Z.dependencies;if(void 0!==Q&&ut(Q,Y))return Z.memoized}var tt=K?H():H;return this.vm.setReactHook(V,{memoized:tt,dependencies:Y}),tt}if("setTimeout"===e){var et=Jn(r,2),rt=et[0],nt=et[1],ot=setTimeout((function(){i.vm.alive&&rt()}),nt);return this.vm.timeouts.add(ot),ot}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var it=Jn(r,2),ct=it[0],st=it[1],lt=setInterval((function(){i.vm.alive&&ct()}),st);return this.vm.intervals.add(lt),lt}if("clearTimeout"===e){var ft=r[0];return this.vm.timeouts.delete(ft),clearTimeout(ft)}if("clearInterval"===e){var ht=r[0];return this.vm.intervals.delete(ht),clearInterval(ht)}}}}else{var pt=e===t?a:a[e];if("function"==typeof pt)return o?Un(pt,Fn(r)):pt.apply(void 0,Fn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(ho(n),null!=e&&e.requireState&&n!==to)throw new Error("The top object should be ".concat(to));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(po(o),o===this.stack.state&&n in ao){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in ao){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return po(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,Fn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Wn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,A=I.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);po(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,P;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=vo(B);if(!(0,_r.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Br()(null!=U?U:B)}else{if("keyframes"===T)C=_r.keyframes;else{if(!(T in no))throw new Error("Unsupported styled tag: "+T);C=Br()(T)}P=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([P].concat(Fn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(Fn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(Eo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);po(s);var l,f=Bn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(Eo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Wn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(go(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Bn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,A=!1,C=Bn(I.consequent);try{for(C.s();!(L=C.n()).done;){var P=L.value,N=k.executeStatement(P);if(N){if(N.break){A=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(A)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),ko=function(){function t(e){var r,n=this;qn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in lo?lo[o]:lo[o]=fo.parse(o,so),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=h,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Dn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.socialGet(o.near,t,e,r,n,i)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r){var n=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(o){return n.cache.cachedViewCall(n.near,n.near.config.contractName,"keys",{keys:t,options:r},e,o)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedEthersCall(n.ethersProvider,t,e,r)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o){var i=this;return this.cachedPromise((function(o){return i.cache.cachedViewCall(i.near,t,e,r,n,o)}),o)}},{key:"cachedNearBlock",value:function(t,e){var r=this;return this.cachedPromise((function(e){return r.cache.cachedBlock(r.near,t,e)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.cachedFetch(t,e,n)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.socialIndex(n.near,t,e,r,o)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedCustomPromise({widgetSrc:n.widgetSrc,dataKey:e},t,r)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=Jn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state={props:N(e)?Object.assign({},e):e,context:r,state:c,nacl:Yn,get elliptic(){return delete this.elliptic,this.elliptic=Zr().cloneDeep(Ur),this.elliptic},ethers:Zn,nanoid:Qn},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new So(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Oo=require("react-error-boundary");function jo(t){return jo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jo(t)}var Io=["loading","src","code","depth","config","props"];function Lo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ao(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Io),p=Po((0,e.useState)(0),2),d=p[0],y=p[1],v=Po((0,e.useState)(null),2),m=v[0],g=v[1],b=Po((0,e.useState)(null),2),E=b[0],x=b[1],S=Po((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=Po((0,e.useState)(0),2),I=j[0],C=j[1],P=Po((0,e.useState)({}),2),B=P[0],U=P[1],R=Po((0,e.useState)(null),2),M=R[0],F=R[1],q=Po((0,e.useState)(null),2),G=q[0],D=q[1],J=Po((0,e.useState)(null),2),z=J[0],$=J[1],W=Po((0,e.useState)(null),2),K=W[0],X=W[1],H=Po((0,e.useState)(null),2),V=H[0],Y=H[1],Z=Po((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(nn),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=wr(rt),ot=qt(rt),it=ce(rt),at=Po((0,e.useState)(null),2),st=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];ut(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=No(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);ut(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=Po(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),$(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new ko({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Pe()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Ao(Ao({},h),{},{ref:n})};if(!ut(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=st?r().createElement(Oo.ErrorBoundary,{FallbackComponent:A,onReset:function(){lt(null)},resetKeys:[st]},r().createElement(r().Fragment,null,st,G&&r().createElement(Te,{transactions:G,onHide:function(){return D(null)},networkId:rt}),z&&r().createElement(Pr,{show:!0,widgetSrc:E,data:z.data,force:z.force,onHide:function(){return $(null)},onCommit:z.onCommit,onCancel:z.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function z(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Nr,EthersProviderContext:()=>nn,Widget:()=>_o,useAccount:()=>ae,useAccountId:()=>ce,useCache:()=>wr,useInitNear:()=>Rt,useNear:()=>qt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>A,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>ut,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,indexMatch:()=>et,ipfsUpload:()=>$,ipfsUrl:()=>W,isArray:()=>P,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>z,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),A=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var P=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!P(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return P(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},z=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=l(),st=n(764).lW;function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function ft(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ht(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function mt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function gt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){mt(i,n,o,a,c,"next",t)}function c(t){mt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var bt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},wt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},Et={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},xt={get:!0,keys:!0},St=function(){var t=gt(vt().mark((function t(e,r,n,o,i){return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in xt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function kt(t,e,r,n,o,i){return Ot.apply(this,arguments)}function Ot(){return(Ot=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[bt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function jt(t,e){return It.apply(this,arguments)}function It(){return(It=gt(vt().mark((function t(e,r){var n;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return At.apply(this,arguments)}function At(){return(At=gt(vt().mark((function t(e,r){var n,o,i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=bt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Pt(t,e,r,n,o,i){return Nt.apply(this,arguments)}function Nt(){return(Nt=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:st.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(st.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Tt(t,e,r,n){return _t.apply(this,arguments)}function _t(){return(_t=gt(vt().mark((function t(e,r,n,o){var i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=dt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Bt(t){return Ut.apply(this,arguments)}function Ut(){return(Ut=gt(vt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},Et,o):"testnet"===o.networkId&&(o=Object.assign({},wt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Pt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Tt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():St(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return kt(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return jt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Rt=(0,i.singletonHook)({},(function(){var t=dt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:ht(ht({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:ht(ht({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Bt)).then((function(t){return t.map((function(t){return ht(ht({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Mt=[],Ft=(0,i.singletonHook)(Mt,(function(){var t=dt((0,e.useState)(Mt),2),r=t[0],n=t[1],o=Rt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),qt=function(t){return Ft()[t||"default"]||null};const Gt=require("local-storage");var Dt,Jt,zt,$t,Wt=n.n(Gt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Yt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Zt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Yt(i,n,o,a,c,"next",t)}function c(t){Yt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Qt="near-social-vm:v01:",te=Qt+":accountId:",ee=Qt+":pretendAccountId:",re={loading:!0,signedAccountId:null!==(Dt=Wt().get(te))&&void 0!==Dt?Dt:void 0,pretendAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,accountId:null!==(zt=null!==($t=Wt().get(ee))&&void 0!==$t?$t:Wt().get(te))&&void 0!==zt?zt:void 0,state:null,near:null};function ne(t,e){return oe.apply(this,arguments)}function oe(){return(oe=Zt(Vt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ie=function(){var t=Zt(Vt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(te,o),e.config.walletConnectCallback(o)):Wt().remove(te),i=null!==(n=Wt().get(ee))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Zt(Vt().mark((function t(){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Zt(Vt().mark((function t(n){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(ee,n):Wt().remove(ee),t.next=3,ie(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ae=(0,i.singletonHook)(re,(function(){var t=Xt((0,e.useState)(re),2),r=t[0],n=t[1],o=qt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Zt(Vt().mark((function t(e){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ne(o,e);case 2:return t.prev=2,t.next=5,ie(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ce=function(t){var e=qt(),r=ae();if(e&&(!t||e.config.networkId===t))return r.accountId};const ue=require("react-bootstrap/Modal");var se=n.n(ue);const le=require("remark-gfm");var fe=n.n(le);const he=require("react-markdown");var pe=n.n(he);const de=require("react-syntax-highlighter"),ye=require("react-syntax-highlighter/dist/esm/styles/prism"),ve=require("mdast-util-find-and-replace");var me=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function ge(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ve.findAndReplace)(e,me,t),e}}var be=/#(\w+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ve.findAndReplace)(e,be,t),e}}var Ee=["node","children"],xe=["node"],Se=["node"],ke=["node"],Oe=["node"],je=["node","inline","className","children"];function Ie(){return Ie=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ae=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(pe(),{plugins:[],rehypePlugins:[],remarkPlugins:[fe(),ge,we],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Le(t,Ee);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Le(t,xe);return e?r().createElement("a",Ie({onClick:e},n)):r().createElement("a",Ie({target:"_blank"},n))},img:function(t){t.node;var e=Le(t,Se);return r().createElement("img",Ie({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Le(t,ke);return r().createElement("blockquote",Ie({className:"blockquote"},e))},table:function(t){t.node;var e=Le(t,Oe);return r().createElement("table",Ie({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Le(t,je),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(de.Prism,Ie({children:String(o).replace(/\n$/,""),style:ye.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ie({className:n},i),o)}}})};const Ce=require("react-uuid");var Pe=n.n(Ce);function Ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function De(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Je(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){De(i,n,o,a,c,"next",t)}function c(t){De(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ze=x.mul(2e3),$e=x.mul(500),We=x.mul(500),Ke=x.mul(500),Xe=function(){var t=Je(Ge().mark((function t(e,r){var n;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),He=function(){var t=Je(Ge().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return qe(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qe(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==Fe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==Fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===Fe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Xe(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):$e).add(l?u()(0):Ke).add(We),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):ze),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ve=function(){var t=Je(Ge().mark((function t(e,r,n){return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ye=function(){var t=Je(Ge().mark((function t(e,r,n){var o,i;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(bt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(bt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Ze=require("react-bootstrap"),Qe=require("idb");function tr(t){return tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tr(t)}function er(t,e){if(t){if("string"==typeof t)return rr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rr(t,e):void 0}}function rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ir(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){or(i,n,o,a,c,"next",t)}function c(t){or(i,n,o,a,c,"throw",t)}a(void 0)}))}}function ar(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,Qe.openDB)(e,1,{upgrade:function(t){t.createObjectStore(dr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ir(nr().mark((function t(e){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(dr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ir(nr().mark((function t(e,r){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(dr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:lr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=pr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===fr||i.status===hr&&i.time+3e5>(new Date).getTime()||(i.status===lr&&this.innerGet(t).then((function(t){(t||n)&&i.status===fr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=fr,e&&e().then((function(e){i.status=hr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=hr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===cr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===ur&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||er(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=pr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i){return this.cachedPromise({action:cr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i)}},{key:"asyncFetch",value:(n=ir(nr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise({action:ur,url:t,options:e},(function(){return n.asyncFetch(t,e)}),r)}},{key:"cachedCustomPromise",value:function(t,e,r){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r)}},{key:"socialGet",value:function(t,e,r,n,o,i){if(!t)return null;var a={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},c=this.cachedViewCall(t,t.config.contractName,"get",a,n,i);if(null===c)return null;if(1===e.length)for(var u=e[0].split("/"),s=0;s=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function jr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ir(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ir(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ir(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,xr),p=jr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Sr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Pr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Tr=require("react-bootstrap-typeahead"),_r=require("styled-components");var Br=n.n(_r);const Ur=require("elliptic"),Rr=require("bn.js");var Mr=n.n(Rr);const Fr=require("tweetnacl"),qr=require("iframe-resizer-react");var Gr=n.n(qr);function Dr(){return Dr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Un(t,e,r){return Un=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Rn(o,r.prototype),o},Un.apply(null,arguments)}function Rn(t,e){return Rn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rn(t,e)}function Mn(){return Mn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,_r.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!no[s.as]&&delete s.as,s.forwardedAs&&!no[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Jn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ue.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(Fn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Xn(Xn({},s),{},{children:g}));if(u)return(0,_r.isStyledComponent)(u)?r().createElement.apply(r(),[u,Xn({},s)].concat(Fn(g))):u(Xn({children:g},s));if("Widget"===o)return r().createElement(_o,s);if("CommitButton"===o)return r().createElement(Nr,Mn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Me(),s,g);if("Tooltip"===o)return r().createElement(Ze.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Ze.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Tr.Typeahead,s);if("Markdown"===o)return r().createElement(Ae,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Be(),Mn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Be(),s,g);if("iframe"===o)return r().createElement(Hr,s);if("Web3Connect"===o)return r().createElement(on,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Xn({},s)].concat(Fn(g)));if(!1===i)return r().createElement(o,Xn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return ho(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=ao[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2])}if("Social"===t&&"keys"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return this.vm.cachedSocialKeys(r[0],r[1],r[2])}if("Social"===t&&"index"===e){if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return this.vm.cachedIndex(r[0],r[1],r[2])}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe'");var c=Jn(r,5),u=c[0],s=c[1],l=c[2],f=c[3],h=c[4];return this.vm.cachedNearView(u,s,l,f,mo(h,f))}if("Near"===t&&"asyncView"===e){var p;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(p=this.vm).asyncNearView.apply(p,Fn(r))}if("Near"===t&&"block"===e){var d=Jn(r,2),y=d[0],v=d[1];return this.vm.cachedNearBlock(y,mo(v,y))}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(P(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var m;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(m=r[2])&&void 0!==m?m:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return po(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var g=JSON.parse(r[0]);return yo(g),g}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return po(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return po(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return po(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return po(t)}));var b=Object.assign.apply(Object,Fn(r));return yo(b),b}if("fromEntries"===e){var w=Object.fromEntries(r[0]);return yo(w),w}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Wn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var E=r[0];this.vm.state.state=E,this.vm.setReactState(E)}return this.vm.state.state}if("State"===t&&"update"===e){var x;if(N(r[0]))this.vm.state.state=null!==(x=this.vm.state.state)&&void 0!==x?x:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var S;this.vm.state.state=null!==(S=this.vm.state.state)&&void 0!==S?S:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:eo},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:eo},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:ro},r[0],r[1])}if("Storage"===t&&"get"===e){var k;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(k=r[1])&&void 0!==k?k:this.vm.widgetSrc,type:ro},r[0])}var O,j,I;if("console"===t&&"log"===e)return(O=console).log.apply(O,[this.vm.widgetSrc].concat(Fn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(j=navigator.clipboard).writeText.apply(j,Fn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(I=this.vm).vmRequire.apply(I,Fn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var L,A=null===(L=this.vm.ethersProviderContext)||void 0===L?void 0:L.setChain;if(!A)throw new Error("The gateway doesn't support `setChain` operation");return A.apply(void 0,Fn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var C=Un(WebSocket,Fn(r));return this.vm.websockets.push(C),C}throw new Error("Unsupported WebSocket method")}if(void 0===a){if(co.hasOwnProperty(e))return co[e].apply(co,Fn(r));if("fetch"===e){var T;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(T=this.vm).cachedFetch.apply(T,Fn(r))}if("asyncFetch"===e){var B;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(B=this.vm).asyncFetch.apply(B,Fn(r))}if("useCache"===e){var U;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(U=this.vm).useCache.apply(U,Fn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var R=r[0],M=this.hookIndex++,F=this.vm.hooks[M];if(F)return[F.state,F.setState];var q=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[M])||void 0===r?void 0:r.state)),i.vm.setReactHook(M,{state:e,setState:t}),e};return[q(R),q]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var G=r[0];if(!_(G))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var D=this.hookIndex++,J=r[1],z=this.vm.hooks[D];if(z){var $=z.dependencies;if(void 0!==$&&ut($,J))return}var W=null==z?void 0:z.cleanup;return _(W)&&W(),void this.vm.setReactHook(D,{cleanup:G(),dependencies:J})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var K="useMemo"===e,X=K?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(X,"'. Optional: 'dependencies'"));var H=r[0];if(!_(H))throw new Error("Method: ".concat(e,". The first argument '").concat(X,"' must be a function"));var V=this.hookIndex++,Y=r[1],Z=this.vm.hooks[V];if(Z){var Q=Z.dependencies;if(void 0!==Q&&ut(Q,Y))return Z.memoized}var tt=K?H():H;return this.vm.setReactHook(V,{memoized:tt,dependencies:Y}),tt}if("setTimeout"===e){var et=Jn(r,2),rt=et[0],nt=et[1],ot=setTimeout((function(){i.vm.alive&&rt()}),nt);return this.vm.timeouts.add(ot),ot}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var it=Jn(r,2),ct=it[0],st=it[1],lt=setInterval((function(){i.vm.alive&&ct()}),st);return this.vm.intervals.add(lt),lt}if("clearTimeout"===e){var ft=r[0];return this.vm.timeouts.delete(ft),clearTimeout(ft)}if("clearInterval"===e){var ht=r[0];return this.vm.intervals.delete(ht),clearInterval(ht)}}}}else{var pt=e===t?a:a[e];if("function"==typeof pt)return o?Un(pt,Fn(r)):pt.apply(void 0,Fn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(ho(n),null!=e&&e.requireState&&n!==to)throw new Error("The top object should be ".concat(to));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(po(o),o===this.stack.state&&n in ao){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in ao){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return po(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,Fn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Wn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,A=I.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);po(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,P;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=vo(B);if(!(0,_r.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Br()(null!=U?U:B)}else{if("keyframes"===T)C=_r.keyframes;else{if(!(T in no))throw new Error("Unsupported styled tag: "+T);C=Br()(T)}P=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([P].concat(Fn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(Fn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(Eo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);po(s);var l,f=Bn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(Eo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Wn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(go(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Bn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,A=!1,C=Bn(I.consequent);try{for(C.s();!(L=C.n()).done;){var P=L.value,N=k.executeStatement(P);if(N){if(N.break){A=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(A)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),ko=function(){function t(e){var r,n=this;qn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in lo?lo[o]:lo[o]=fo.parse(o,so),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Dn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.socialGet(o.near,t,e,r,n,i)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r){var n=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(o){return n.cache.cachedViewCall(n.near,n.near.config.contractName,"keys",{keys:t,options:r},e,o)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedEthersCall(n.ethersProvider,t,e,r)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o){var i=this;return this.cachedPromise((function(o){return i.cache.cachedViewCall(i.near,t,e,r,n,o)}),o)}},{key:"cachedNearBlock",value:function(t,e){var r=this;return this.cachedPromise((function(e){return r.cache.cachedBlock(r.near,t,e)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.cachedFetch(t,e,n)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.socialIndex(n.near,t,e,r,o)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedCustomPromise({widgetSrc:n.widgetSrc,dataKey:e},t,r)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=Jn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state={props:N(e)?Object.assign({},e):e,context:r,state:c,nacl:Yn,get elliptic(){return delete this.elliptic,this.elliptic=Zr().cloneDeep(Ur),this.elliptic},ethers:Zn,nanoid:Qn},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new So(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Oo=require("react-error-boundary");function jo(t){return jo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jo(t)}var Io=["loading","src","code","depth","config","props"];function Lo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ao(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Io),p=Po((0,e.useState)(0),2),d=p[0],y=p[1],v=Po((0,e.useState)(null),2),m=v[0],g=v[1],b=Po((0,e.useState)(null),2),E=b[0],x=b[1],S=Po((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=Po((0,e.useState)(0),2),I=j[0],C=j[1],P=Po((0,e.useState)({}),2),B=P[0],U=P[1],R=Po((0,e.useState)(null),2),M=R[0],F=R[1],q=Po((0,e.useState)(null),2),G=q[0],D=q[1],J=Po((0,e.useState)(null),2),z=J[0],$=J[1],W=Po((0,e.useState)(null),2),K=W[0],X=W[1],H=Po((0,e.useState)(null),2),V=H[0],Y=H[1],Z=Po((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(nn),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=wr(rt),ot=qt(rt),it=ce(rt),at=Po((0,e.useState)(null),2),st=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];ut(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=No(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);ut(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=Po(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),$(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new ko({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Pe()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Ao(Ao({},h),{},{ref:n})};if(!ut(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=st?r().createElement(Oo.ErrorBoundary,{FallbackComponent:A,onReset:function(){lt(null)},resetKeys:[st]},r().createElement(r().Fragment,null,st,G&&r().createElement(Te,{transactions:G,onHide:function(){return D(null)},networkId:rt}),z&&r().createElement(Pr,{show:!0,widgetSrc:E,data:z.data,force:z.force,onHide:function(){return $(null)},onCommit:z.onCommit,onCancel:z.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index 8c83d616..21e31eaf 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -1899,7 +1899,7 @@ export default class VM { this.cache = cache; this.refreshCache = refreshCache; this.confirmTransactions = confirmTransactions; - this.depth = depth; + this.depth = depth ?? 0; this.widgetSrc = widgetSrc; this.requestCommit = requestCommit; this.version = version; From 1238981bd6d322cb23f47728a903a7c8c1fd70a0 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Fri, 22 Sep 2023 11:25:14 -0700 Subject: [PATCH 04/25] Improve events and errors for functions --- CHANGELOG.md | 4 ++ dist/index.js | 2 +- src/lib/data/utils.js | 8 +++ src/lib/vm/vm.js | 115 ++++++++++++++++++++++++------------------ 4 files changed, 80 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b622733e..04cc22c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Pending +- Update the way events and errors are passed to the functions. + - If it's a callback on a function call, then `preventDefault` and `stopPropagation` are available. + NOTE: Previously, all React's `SyntheticEvent` was getting `preventDefault()` called by default. + - For errors, expose `message`, `name` and `type` are exposed. - Fix `vm.depth` not being initialized. - Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes. diff --git a/dist/index.js b/dist/index.js index a02adc06..99d9c0b5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function z(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Nr,EthersProviderContext:()=>nn,Widget:()=>_o,useAccount:()=>ae,useAccountId:()=>ce,useCache:()=>wr,useInitNear:()=>Rt,useNear:()=>qt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>C,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>ut,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,indexMatch:()=>et,ipfsUpload:()=>$,ipfsUrl:()=>W,isArray:()=>P,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>z,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),C=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var P=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!P(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return P(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},z=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=l(),st=n(764).lW;function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function ft(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ht(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function mt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function gt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){mt(i,n,o,a,c,"next",t)}function c(t){mt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var bt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},wt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},Et={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},xt={get:!0,keys:!0},St=function(){var t=gt(vt().mark((function t(e,r,n,o,i){return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in xt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function kt(t,e,r,n,o,i){return Ot.apply(this,arguments)}function Ot(){return(Ot=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[bt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function jt(t,e){return It.apply(this,arguments)}function It(){return(It=gt(vt().mark((function t(e,r){var n;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=gt(vt().mark((function t(e,r){var n,o,i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=bt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function At(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Pt(t,e,r,n,o,i){return Nt.apply(this,arguments)}function Nt(){return(Nt=gt(vt().mark((function t(e,r,n,o,i,a){var c;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:st.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(st.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Tt(t,e,r,n){return _t.apply(this,arguments)}function _t(){return(_t=gt(vt().mark((function t(e,r,n,o){var i;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=dt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Bt(t){return Ut.apply(this,arguments)}function Ut(){return(Ut=gt(vt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},Et,o):"testnet"===o.networkId&&(o=Object.assign({},wt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Pt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Tt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():St(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return kt(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=At(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return jt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Rt=(0,i.singletonHook)({},(function(){var t=dt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:ht(ht({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:ht(ht({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Bt)).then((function(t){return t.map((function(t){return ht(ht({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Mt=[],Ft=(0,i.singletonHook)(Mt,(function(){var t=dt((0,e.useState)(Mt),2),r=t[0],n=t[1],o=Rt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),qt=function(t){return Ft()[t||"default"]||null};const Gt=require("local-storage");var Dt,Jt,zt,$t,Wt=n.n(Gt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Yt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Zt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Yt(i,n,o,a,c,"next",t)}function c(t){Yt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Qt="near-social-vm:v01:",te=Qt+":accountId:",ee=Qt+":pretendAccountId:",re={loading:!0,signedAccountId:null!==(Dt=Wt().get(te))&&void 0!==Dt?Dt:void 0,pretendAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,accountId:null!==(zt=null!==($t=Wt().get(ee))&&void 0!==$t?$t:Wt().get(te))&&void 0!==zt?zt:void 0,state:null,near:null};function ne(t,e){return oe.apply(this,arguments)}function oe(){return(oe=Zt(Vt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ie=function(){var t=Zt(Vt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(te,o),e.config.walletConnectCallback(o)):Wt().remove(te),i=null!==(n=Wt().get(ee))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Zt(Vt().mark((function t(){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Zt(Vt().mark((function t(n){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(ee,n):Wt().remove(ee),t.next=3,ie(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ae=(0,i.singletonHook)(re,(function(){var t=Xt((0,e.useState)(re),2),r=t[0],n=t[1],o=qt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Zt(Vt().mark((function t(e){return Vt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ne(o,e);case 2:return t.prev=2,t.next=5,ie(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ce=function(t){var e=qt(),r=ae();if(e&&(!t||e.config.networkId===t))return r.accountId};const ue=require("react-bootstrap/Modal");var se=n.n(ue);const le=require("remark-gfm");var fe=n.n(le);const he=require("react-markdown");var pe=n.n(he);const de=require("react-syntax-highlighter"),ye=require("react-syntax-highlighter/dist/esm/styles/prism"),ve=require("mdast-util-find-and-replace");var me=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function ge(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ve.findAndReplace)(e,me,t),e}}var be=/#(\w+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ve.findAndReplace)(e,be,t),e}}var Ee=["node","children"],xe=["node"],Se=["node"],ke=["node"],Oe=["node"],je=["node","inline","className","children"];function Ie(){return Ie=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ce=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(pe(),{plugins:[],rehypePlugins:[],remarkPlugins:[fe(),ge,we],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Le(t,Ee);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Le(t,xe);return e?r().createElement("a",Ie({onClick:e},n)):r().createElement("a",Ie({target:"_blank"},n))},img:function(t){t.node;var e=Le(t,Se);return r().createElement("img",Ie({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Le(t,ke);return r().createElement("blockquote",Ie({className:"blockquote"},e))},table:function(t){t.node;var e=Le(t,Oe);return r().createElement("table",Ie({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Le(t,je),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(de.Prism,Ie({children:String(o).replace(/\n$/,""),style:ye.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ie({className:n},i),o)}}})};const Ae=require("react-uuid");var Pe=n.n(Ae);function Ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function De(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Je(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){De(i,n,o,a,c,"next",t)}function c(t){De(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ze=x.mul(2e3),$e=x.mul(500),We=x.mul(500),Ke=x.mul(500),Xe=function(){var t=Je(Ge().mark((function t(e,r){var n;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),He=function(){var t=Je(Ge().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return qe(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qe(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==Fe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==Fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===Fe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Xe(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):$e).add(l?u()(0):Ke).add(We),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):ze),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ve=function(){var t=Je(Ge().mark((function t(e,r,n){return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ye=function(){var t=Je(Ge().mark((function t(e,r,n){var o,i;return Ge().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(bt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(bt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Ze=require("react-bootstrap"),Qe=require("idb");function tr(t){return tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tr(t)}function er(t,e){if(t){if("string"==typeof t)return rr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rr(t,e):void 0}}function rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ir(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){or(i,n,o,a,c,"next",t)}function c(t){or(i,n,o,a,c,"throw",t)}a(void 0)}))}}function ar(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,Qe.openDB)(e,1,{upgrade:function(t){t.createObjectStore(dr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ir(nr().mark((function t(e){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(dr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ir(nr().mark((function t(e,r){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(dr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:lr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=pr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===fr||i.status===hr&&i.time+3e5>(new Date).getTime()||(i.status!==lr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===fr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=fr,e&&e().then((function(e){i.status=hr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=hr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===cr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===ur&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||er(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=pr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:cr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=ir(nr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:ur,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Or(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function jr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ir(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ir(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ir(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,xr),p=jr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Sr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Pr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Tr=require("react-bootstrap-typeahead"),_r=require("styled-components");var Br=n.n(_r);const Ur=require("elliptic"),Rr=require("bn.js");var Mr=n.n(Rr);const Fr=require("tweetnacl"),qr=require("iframe-resizer-react");var Gr=n.n(qr);function Dr(){return Dr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Un(t,e,r){return Un=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Rn(o,r.prototype),o},Un.apply(null,arguments)}function Rn(t,e){return Rn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rn(t,e)}function Mn(){return Mn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,_r.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!no[s.as]&&delete s.as,s.forwardedAs&&!no[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Jn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ue.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(Fn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Xn(Xn({},s),{},{children:g}));if(u)return(0,_r.isStyledComponent)(u)?r().createElement.apply(r(),[u,Xn({},s)].concat(Fn(g))):u(Xn({children:g},s));if("Widget"===o)return r().createElement(_o,s);if("CommitButton"===o)return r().createElement(Nr,Mn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Me(),s,g);if("Tooltip"===o)return r().createElement(Ze.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Ze.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Tr.Typeahead,s);if("Markdown"===o)return r().createElement(Ce,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Be(),Mn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Be(),s,g);if("iframe"===o)return r().createElement(Hr,s);if("Web3Connect"===o)return r().createElement(on,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Xn({},s)].concat(Fn(g)));if(!1===i)return r().createElement(o,Xn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return ho(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=ao[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2],r[3])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2],r[3])}if("Social"===t&&"keys"===e){var c;if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return(c=this.vm).cachedSocialKeys.apply(c,Fn(r))}if("Social"===t&&"index"===e){var u;if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return(u=this.vm).cachedIndex.apply(u,Fn(r))}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe', 'cacheOptions'");var s=Jn(r,6),l=s[0],f=s[1],h=s[2],p=s[3],d=s[4],y=s[5];return this.vm.cachedNearView(l,f,h,p,mo(d,p),y)}if("Near"===t&&"asyncView"===e){var v;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(v=this.vm).asyncNearView.apply(v,Fn(r))}if("Near"===t&&"block"===e){var m=Jn(r,3),g=m[0],b=m[1],w=m[2];return this.vm.cachedNearBlock(g,mo(b,g),w)}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(P(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var E;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(E=r[2])&&void 0!==E?E:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return po(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var x=JSON.parse(r[0]);return yo(x),x}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return po(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return po(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return po(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return po(t)}));var S=Object.assign.apply(Object,Fn(r));return yo(S),S}if("fromEntries"===e){var k=Object.fromEntries(r[0]);return yo(k),k}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Wn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var O=r[0];this.vm.state.state=O,this.vm.setReactState(O)}return this.vm.state.state}if("State"===t&&"update"===e){var j;if(N(r[0]))this.vm.state.state=null!==(j=this.vm.state.state)&&void 0!==j?j:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var I;this.vm.state.state=null!==(I=this.vm.state.state)&&void 0!==I?I:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:eo},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:eo},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:ro},r[0],r[1])}if("Storage"===t&&"get"===e){var L;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(L=r[1])&&void 0!==L?L:this.vm.widgetSrc,type:ro},r[0])}var C,A,T;if("console"===t&&"log"===e)return(C=console).log.apply(C,[this.vm.widgetSrc].concat(Fn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(A=navigator.clipboard).writeText.apply(A,Fn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(T=this.vm).vmRequire.apply(T,Fn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var B,U=null===(B=this.vm.ethersProviderContext)||void 0===B?void 0:B.setChain;if(!U)throw new Error("The gateway doesn't support `setChain` operation");return U.apply(void 0,Fn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var R=Un(WebSocket,Fn(r));return this.vm.websockets.push(R),R}throw new Error("Unsupported WebSocket method")}if(void 0===a){if(co.hasOwnProperty(e))return co[e].apply(co,Fn(r));if("fetch"===e){var M;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(M=this.vm).cachedFetch.apply(M,Fn(r))}if("asyncFetch"===e){var F;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(F=this.vm).asyncFetch.apply(F,Fn(r))}if("useCache"===e){var q;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(q=this.vm).useCache.apply(q,Fn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var G=r[0],D=this.hookIndex++,J=this.vm.hooks[D];if(J)return[J.state,J.setState];var z=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[D])||void 0===r?void 0:r.state)),i.vm.setReactHook(D,{state:e,setState:t}),e};return[z(G),z]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var $=r[0];if(!_($))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var W=this.hookIndex++,K=r[1],X=this.vm.hooks[W];if(X){var H=X.dependencies;if(void 0!==H&&ut(H,K))return}var V=null==X?void 0:X.cleanup;return _(V)&&V(),void this.vm.setReactHook(W,{cleanup:$(),dependencies:K})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var Y="useMemo"===e,Z=Y?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(Z,"'. Optional: 'dependencies'"));var Q=r[0];if(!_(Q))throw new Error("Method: ".concat(e,". The first argument '").concat(Z,"' must be a function"));var tt=this.hookIndex++,et=r[1],rt=this.vm.hooks[tt];if(rt){var nt=rt.dependencies;if(void 0!==nt&&ut(nt,et))return rt.memoized}var ot=Y?Q():Q;return this.vm.setReactHook(tt,{memoized:ot,dependencies:et}),ot}if("setTimeout"===e){var it=Jn(r,2),ct=it[0],st=it[1],lt=setTimeout((function(){i.vm.alive&&ct()}),st);return this.vm.timeouts.add(lt),lt}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var ft=Jn(r,2),ht=ft[0],pt=ft[1],dt=setInterval((function(){i.vm.alive&&ht()}),pt);return this.vm.intervals.add(dt),dt}if("clearTimeout"===e){var yt=r[0];return this.vm.timeouts.delete(yt),clearTimeout(yt)}if("clearInterval"===e){var vt=r[0];return this.vm.intervals.delete(vt),clearInterval(vt)}}}}else{var mt=e===t?a:a[e];if("function"==typeof mt)return o?Un(mt,Fn(r)):mt.apply(void 0,Fn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(ho(n),null!=e&&e.requireState&&n!==to)throw new Error("The top object should be ".concat(to));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(po(o),o===this.stack.state&&n in ao){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in ao){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return po(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,Fn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Wn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,C=I.key;if("++"===t.operator)return t.prefix?++L[C]:L[C]++;if("--"===t.operator)return t.prefix?--L[C]:L[C]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);po(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var A,P;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=vo(B);if(!(0,_r.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');A=Br()(null!=U?U:B)}else{if("keyframes"===T)A=_r.keyframes;else{if(!(T in no))throw new Error("Unsupported styled tag: "+T);A=Br()(T)}P=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([P].concat(Fn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(A instanceof Function){var G=A.apply(void 0,[R].concat(Fn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(Eo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);po(s);var l,f=Bn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(Eo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Wn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(go(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Bn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,C=!1,A=Bn(I.consequent);try{for(A.s();!(L=A.n()).done;){var P=L.value,N=k.executeStatement(P);if(N){if(N.break){C=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(C)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),ko=function(){function t(e){var r,n=this;qn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in lo?lo[o]:lo[o]=fo.parse(o,so),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Dn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n,o){var i=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(a){return i.cache.socialGet(i.near,t,e,r,n,a,o)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.cachedViewCall(o.near,o.near.config.contractName,"keys",{keys:t,options:r},e,i,n)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedEthersCall(o.ethersProvider,t,e,r,n)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o,i){var a=this;return this.cachedPromise((function(o){return a.cache.cachedViewCall(a.near,t,e,r,n,o,i)}),o)}},{key:"cachedNearBlock",value:function(t,e,r){var n=this;return this.cachedPromise((function(e){return n.cache.cachedBlock(n.near,t,e,r)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.cachedFetch(t,e,o,r)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(i){return o.cache.socialIndex(o.near,t,e,r,i,n)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedCustomPromise({widgetSrc:o.widgetSrc,dataKey:e},t,r,n)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=Jn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state={props:N(e)?Object.assign({},e):e,context:r,state:c,nacl:Yn,get elliptic(){return delete this.elliptic,this.elliptic=Zr()(Ur),this.elliptic},ethers:Zn,nanoid:Qn},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new So(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Oo=require("react-error-boundary");function jo(t){return jo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jo(t)}var Io=["loading","src","code","depth","config","props"];function Lo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Co(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Io),p=Po((0,e.useState)(0),2),d=p[0],y=p[1],v=Po((0,e.useState)(null),2),m=v[0],g=v[1],b=Po((0,e.useState)(null),2),E=b[0],x=b[1],S=Po((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=Po((0,e.useState)(0),2),I=j[0],A=j[1],P=Po((0,e.useState)({}),2),B=P[0],U=P[1],R=Po((0,e.useState)(null),2),M=R[0],F=R[1],q=Po((0,e.useState)(null),2),G=q[0],D=q[1],J=Po((0,e.useState)(null),2),z=J[0],$=J[1],W=Po((0,e.useState)(null),2),K=W[0],X=W[1],H=Po((0,e.useState)(null),2),V=H[0],Y=H[1],Z=Po((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(nn),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=wr(rt),ot=qt(rt),it=ce(rt),at=Po((0,e.useState)(null),2),st=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];ut(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=No(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);ut(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=Po(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),$(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new ko({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Pe()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Co(Co({},h),{},{ref:n})};if(!ut(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=st?r().createElement(Oo.ErrorBoundary,{FallbackComponent:C,onReset:function(){lt(null)},resetKeys:[st]},r().createElement(r().Fragment,null,st,G&&r().createElement(Te,{transactions:G,onHide:function(){return D(null)},networkId:rt}),z&&r().createElement(Pr,{show:!0,widgetSrc:E,data:z.data,force:z.force,onHide:function(){return $(null)},onCommit:z.onCommit,onCancel:z.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function z(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Tr,EthersProviderContext:()=>on,Widget:()=>Bo,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Er,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>P,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>$,ipfsUrl:()=>W,isArray:()=>A,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>z,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),P=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var A=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!A(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return A(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},z=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Pt(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function At(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Pt(p,t)},p.contract=At(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,zt,$t,Wt,Kt=n.n(Dt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Kt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==(zt=Kt().get(re))&&void 0!==zt?zt:void 0,accountId:null!==($t=null!==(Wt=Kt().get(re))&&void 0!==Wt?Wt:Kt().get(ee))&&void 0!==$t?$t:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(ee,o),e.config.walletConnectCallback(o)):Kt().remove(ee),i=null!==(n=Kt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(re,n):Kt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Ht((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}var xe=["node","children"],Se=["node"],ke=["node"],Oe=["node"],je=["node"],Ie=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ce=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Pe(t,xe);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Pe(t,Se);return e?r().createElement("a",Le({onClick:e},n)):r().createElement("a",Le({target:"_blank"},n))},img:function(t){t.node;var e=Pe(t,ke);return r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Pe(t,Oe);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Pe(t,je);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Pe(t,Ie),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Ae=require("react-uuid");var Ne=n.n(Ae);function Te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Je(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ze(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Je(i,n,o,a,c,"next",t)}function c(t){Je(i,n,o,a,c,"throw",t)}a(void 0)}))}}var $e=x.mul(2e3),We=x.mul(500),Ke=x.mul(500),Xe=x.mul(500),He=function(){var t=ze(De().mark((function t(e,r){var n;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),Ve=function(){var t=ze(De().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ge(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ge(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==qe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===qe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,He(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):We).add(l?u()(0):Xe).add(Ke),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):$e),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ye=function(){var t=ze(De().mark((function t(e,r,n){return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ze=function(){var t=ze(De().mark((function t(e,r,n){var o,i;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Qe=require("react-bootstrap"),tr=require("idb");function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function rr(t,e){if(t){if("string"==typeof t)return nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nr(t,e):void 0}}function nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function ir(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ar(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ir(i,n,o,a,c,"next",t)}function c(t){ir(i,n,o,a,c,"throw",t)}a(void 0)}))}}function cr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,tr.openDB)(e,1,{upgrade:function(t){t.createObjectStore(yr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ar(or().mark((function t(e){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(yr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ar(or().mark((function t(e,r){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(yr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:fr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=dr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===hr||i.status===pr&&i.time+3e5>(new Date).getTime()||(i.status!==fr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===hr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=hr,e&&e().then((function(e){i.status=pr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=pr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===ur&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===sr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||rr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=dr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:ur,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=ar(or().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:sr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function jr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ir(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Lr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Lr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Sr),p=Ir((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",kr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Nr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const _r=require("react-bootstrap-typeahead"),Br=require("styled-components");var Ur=n.n(Br);const Rr=require("elliptic"),Mr=require("bn.js");var Fr=n.n(Mr);const qr=require("tweetnacl"),Gr=require("iframe-resizer-react");var Dr=n.n(Gr);function Jr(){return Jr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rn(t,e,r){return Rn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Mn(o,r.prototype),o},Rn.apply(null,arguments)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Br.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!oo[s.as]&&delete s.as,s.forwardedAs&&!oo[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=zn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Re.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(qn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Hn(Hn({},s),{},{children:g}));if(u)return(0,Br.isStyledComponent)(u)?r().createElement.apply(r(),[u,Hn({},s)].concat(qn(g))):u(Hn({children:g},s));if("Widget"===o)return r().createElement(Bo,s);if("CommitButton"===o)return r().createElement(Tr,Fn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Fe(),s,g);if("Tooltip"===o)return r().createElement(Qe.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Qe.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(_r.Typeahead,s);if("Markdown"===o)return r().createElement(Ce,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ue(),Fn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ue(),s,g);if("iframe"===o)return r().createElement(Vr,s);if("Web3Connect"===o)return r().createElement(an,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Hn({},s)].concat(qn(g)));if(!1===i)return r().createElement(o,Hn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return po(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=co[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2],r[3])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2],r[3])}if("Social"===t&&"keys"===e){var c;if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return(c=this.vm).cachedSocialKeys.apply(c,qn(r))}if("Social"===t&&"index"===e){var u;if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return(u=this.vm).cachedIndex.apply(u,qn(r))}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe', 'cacheOptions'");var s=zn(r,6),l=s[0],f=s[1],h=s[2],p=s[3],d=s[4],y=s[5];return this.vm.cachedNearView(l,f,h,p,go(d,p),y)}if("Near"===t&&"asyncView"===e){var v;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(v=this.vm).asyncNearView.apply(v,qn(r))}if("Near"===t&&"block"===e){var m=zn(r,3),g=m[0],b=m[1],w=m[2];return this.vm.cachedNearBlock(g,go(b,g),w)}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(A(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var E;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(E=r[2])&&void 0!==E?E:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return yo(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var x=JSON.parse(r[0]);return vo(x),x}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return yo(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return yo(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return yo(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return yo(t)}));var S=Object.assign.apply(Object,qn(r));return vo(S),S}if("fromEntries"===e){var k=Object.fromEntries(r[0]);return vo(k),k}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Kn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var O=r[0];this.vm.state.state=O,this.vm.setReactState(O)}return this.vm.state.state}if("State"===t&&"update"===e){var j;if(N(r[0]))this.vm.state.state=null!==(j=this.vm.state.state)&&void 0!==j?j:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var I;this.vm.state.state=null!==(I=this.vm.state.state)&&void 0!==I?I:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:ro},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:ro},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:no},r[0],r[1])}if("Storage"===t&&"get"===e){var L;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(L=r[1])&&void 0!==L?L:this.vm.widgetSrc,type:no},r[0])}var P,C,T;if("console"===t&&"log"===e)return(P=console).log.apply(P,[this.vm.widgetSrc].concat(qn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(C=navigator.clipboard).writeText.apply(C,qn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(T=this.vm).vmRequire.apply(T,qn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var B,U=null===(B=this.vm.ethersProviderContext)||void 0===B?void 0:B.setChain;if(!U)throw new Error("The gateway doesn't support `setChain` operation");return U.apply(void 0,qn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var R=Rn(WebSocket,qn(r));return this.vm.websockets.push(R),R}throw new Error("Unsupported WebSocket method")}if(void 0===a){if(uo.hasOwnProperty(e))return uo[e].apply(uo,qn(r));if("fetch"===e){var M;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(M=this.vm).cachedFetch.apply(M,qn(r))}if("asyncFetch"===e){var F;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(F=this.vm).asyncFetch.apply(F,qn(r))}if("useCache"===e){var q;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(q=this.vm).useCache.apply(q,qn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var G=r[0],D=this.hookIndex++,J=this.vm.hooks[D];if(J)return[J.state,J.setState];var z=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[D])||void 0===r?void 0:r.state)),i.vm.setReactHook(D,{state:e,setState:t}),e};return[z(G),z]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var $=r[0];if(!_($))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var W=this.hookIndex++,K=r[1],X=this.vm.hooks[W];if(X){var H=X.dependencies;if(void 0!==H&&st(H,K))return}var V=null==X?void 0:X.cleanup;return _(V)&&V(),void this.vm.setReactHook(W,{cleanup:$(),dependencies:K})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var Y="useMemo"===e,Z=Y?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(Z,"'. Optional: 'dependencies'"));var Q=r[0];if(!_(Q))throw new Error("Method: ".concat(e,". The first argument '").concat(Z,"' must be a function"));var tt=this.hookIndex++,et=r[1],rt=this.vm.hooks[tt];if(rt){var nt=rt.dependencies;if(void 0!==nt&&st(nt,et))return rt.memoized}var ot=Y?Q():Q;return this.vm.setReactHook(tt,{memoized:ot,dependencies:et}),ot}if("setTimeout"===e){var it=zn(r,2),ct=it[0],ut=it[1],lt=setTimeout((function(){i.vm.alive&&ct()}),ut);return this.vm.timeouts.add(lt),lt}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var ft=zn(r,2),ht=ft[0],pt=ft[1],dt=setInterval((function(){i.vm.alive&&ht()}),pt);return this.vm.intervals.add(dt),dt}if("clearTimeout"===e){var yt=r[0];return this.vm.timeouts.delete(yt),clearTimeout(yt)}if("clearInterval"===e){var vt=r[0];return this.vm.intervals.delete(vt),clearInterval(vt)}}}}else{var mt=e===t?a:a[e];if("function"==typeof mt)return o?Rn(mt,qn(r)):mt.apply(void 0,qn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(po(n),null!=e&&e.requireState&&n!==eo)throw new Error("The top object should be ".concat(eo));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(yo(o),o===this.stack.state&&n in co){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in co){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return yo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,qn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Kn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,P=I.key;if("++"===t.operator)return t.prefix?++L[P]:L[P]++;if("--"===t.operator)return t.prefix?--L[P]:L[P]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);yo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,A;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=mo(B);if(!(0,Br.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Ur()(null!=U?U:B)}else{if("keyframes"===T)C=Br.keyframes;else{if(!(T in oo))throw new Error("Unsupported styled tag: "+T);C=Ur()(T)}A=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([A].concat(qn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(qn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(xo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);yo(s);var l,f=Un(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(xo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Kn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(bo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Un(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,P=!1,C=Un(I.consequent);try{for(C.s();!(L=C.n()).done;){var A=L.value,N=k.executeStatement(A);if(N){if(N.break){P=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(P)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Oo=function(){function t(e){var r,n=this;Gn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in fo?fo[o]:fo[o]=ho.parse(o,lo),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Jn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n,o){var i=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(a){return i.cache.socialGet(i.near,t,e,r,n,a,o)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.cachedViewCall(o.near,o.near.config.contractName,"keys",{keys:t,options:r},e,i,n)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedEthersCall(o.ethersProvider,t,e,r,n)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o,i){var a=this;return this.cachedPromise((function(o){return a.cache.cachedViewCall(a.near,t,e,r,n,o,i)}),o)}},{key:"cachedNearBlock",value:function(t,e,r){var n=this;return this.cachedPromise((function(e){return n.cache.cachedBlock(n.near,t,e,r)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.cachedFetch(t,e,o,r)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(i){return o.cache.socialIndex(o.near,t,e,r,i,n)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedCustomPromise({widgetSrc:o.widgetSrc,dataKey:e},t,r,n)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=zn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state={props:N(e)?Object.assign({},e):e,context:r,state:c,nacl:Zn,get elliptic(){return delete this.elliptic,this.elliptic=Qr()(Rr),this.elliptic},ethers:Qn,nanoid:to},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new ko(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const jo=require("react-error-boundary");function Io(t){return Io="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Io(t)}var Lo=["loading","src","code","depth","config","props"];function Po(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Co(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Lo),p=No((0,e.useState)(0),2),d=p[0],y=p[1],v=No((0,e.useState)(null),2),m=v[0],g=v[1],b=No((0,e.useState)(null),2),E=b[0],x=b[1],S=No((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=No((0,e.useState)(0),2),I=j[0],C=j[1],A=No((0,e.useState)({}),2),B=A[0],U=A[1],R=No((0,e.useState)(null),2),M=R[0],F=R[1],q=No((0,e.useState)(null),2),G=q[0],D=q[1],J=No((0,e.useState)(null),2),z=J[0],$=J[1],W=No((0,e.useState)(null),2),K=W[0],X=W[1],H=No((0,e.useState)(null),2),V=H[0],Y=H[1],Z=No((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(on),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Er(rt),ot=Gt(rt),it=ue(rt),at=No((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=To(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);st(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=No(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),$(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new Oo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ne()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Co(Co({},h),{},{ref:n})};if(!st(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=ut?r().createElement(jo.ErrorBoundary,{FallbackComponent:P,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(_e,{transactions:G,onHide:function(){return D(null)},networkId:rt}),z&&r().createElement(Nr,{show:!0,widgetSrc:E,data:z.data,force:z.force,onHide:function(){return $(null)},onCommit:z.onCommit,onCancel:z.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file diff --git a/src/lib/data/utils.js b/src/lib/data/utils.js index dbcaded1..25b44db1 100644 --- a/src/lib/data/utils.js +++ b/src/lib/data/utils.js @@ -395,4 +395,12 @@ export const deepCopy = (o) => { } }; +export const filterValues = (o) => { + return isObject(o) + ? Object.fromEntries( + Object.entries(o).filter(([key, value]) => value !== undefined) + ) + : o; +}; + export const deepEqual = equal; diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index f258d0d5..d55cf4eb 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -4,6 +4,7 @@ import { deepCopy, deepEqual, deepFreeze, + filterValues, ipfsUpload, ipfsUrl, isArray, @@ -1108,49 +1109,49 @@ class VmStack { return undefined; } else if (callee === "useMemo" || callee === "useCallback") { if (this.prevStack) { - throw new Error( - `Method: ${callee}. The hook can only be called from the top of the stack` - ); + throw new Error( + `Method: ${callee}. The hook can only be called from the top of the stack` + ); } if (!this.vm.hooks) { throw new Error("Hooks are unavailable for modules"); } const isMemo = callee === "useMemo"; - const fnArgName = isMemo ? 'factory' : 'callback'; + const fnArgName = isMemo ? "factory" : "callback"; if (args.length < 1) { - throw new Error( - `Method: ${callee}. Required arguments: '${fnArgName}'. Optional: 'dependencies'` - ); + throw new Error( + `Method: ${callee}. Required arguments: '${fnArgName}'. Optional: 'dependencies'` + ); } - + const fn = args[0]; if (!isFunction(fn)) { - throw new Error( - `Method: ${callee}. The first argument '${fnArgName}' must be a function` - ); + throw new Error( + `Method: ${callee}. The first argument '${fnArgName}' must be a function` + ); } - + const hookIndex = this.hookIndex++; const dependencies = args[1]; const hook = this.vm.hooks[hookIndex]; - + if (hook) { - const oldDependencies = hook.dependencies; - if ( - oldDependencies !== undefined && - deepEqual(oldDependencies, dependencies) - ) { - return hook.memoized; - } + const oldDependencies = hook.dependencies; + if ( + oldDependencies !== undefined && + deepEqual(oldDependencies, dependencies) + ) { + return hook.memoized; + } } - + const memoized = isMemo ? fn() : fn; this.vm.setReactHook(hookIndex, { - memoized, - dependencies, + memoized, + dependencies, }); return memoized; - } else if (callee === "setTimeout") { + } else if (callee === "setTimeout") { const [callback, timeout] = args; const timer = setTimeout(() => { if (!this.vm.alive) { @@ -1564,33 +1565,51 @@ class VmStack { if (arg !== undefined) { try { if (arg?.nativeEvent instanceof Event) { - arg.preventDefault(); + const native = arg; arg = arg.nativeEvent; + arg._preventDefault = () => native.preventDefault(); + arg._stopPropagation = () => native.stopPropagation(); + arg._isDefaultPrevented = () => native.isDefaultPrevented(); + arg._isPropagationStopped = () => native.isPropagationStopped(); } if (arg instanceof Event) { - arg = { - target: { - value: arg?.target?.value, - id: arg?.target?.id, - dataset: arg?.target?.dataset, - href: arg?.target?.href, - checked: arg?.target?.checked, - }, - data: arg?.data, - code: arg?.code, - key: arg?.key, - ctrlKey: arg?.ctrlKey, - altKey: arg?.altKey, - shiftKey: arg?.shiftKey, - metaKey: arg?.metaKey, - button: arg?.button, - buttons: arg?.buttons, - clientX: arg?.clientX, - clientY: arg?.clientY, - screenX: arg?.screenX, - screenY: arg?.screenY, - touches: arg?.touches, - }; + arg = filterValues({ + target: arg.target + ? filterValues({ + value: arg.target?.value, + id: arg.target?.id, + dataset: arg.target?.dataset, + href: arg.target?.href, + checked: arg.target?.checked, + }) + : undefined, + data: arg.data, + code: arg.code, + key: arg.key, + ctrlKey: arg.ctrlKey, + altKey: arg.altKey, + shiftKey: arg.shiftKey, + metaKey: arg.metaKey, + button: arg.button, + buttons: arg.buttons, + clientX: arg.clientX, + clientY: arg.clientY, + screenX: arg.screenX, + screenY: arg.screenY, + touches: arg.touches, + preventDefault: arg._preventDefault ?? arg.preventDefault, + stopPropagation: arg._stopPropagation ?? arg.stopPropagation, + defaultPrevented: arg.defaultPrevented, + isDefaultPrevented: + arg._isDefaultPrevented ?? (() => arg.defaultPrevented), + isPropagationStopped: arg._isPropagationStopped, + }); + } else if (arg instanceof Error) { + arg = filterValues({ + type: arg.type, + name: arg.name, + message: arg.message, + }); } v = deepCopy(arg); } catch (e) { From 9a2b609835b8f78430763dc33d0f6ae3fd43a120 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Fri, 22 Sep 2023 11:31:27 -0700 Subject: [PATCH 05/25] Update doc --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04cc22c3..a8ac57bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,9 @@ ## Pending - Update the way events and errors are passed to the functions. - - If it's a callback on a function call, then `preventDefault` and `stopPropagation` are available. + - For events, expose `preventDefault()` and `stopPropagation()` functions. NOTE: Previously, all React's `SyntheticEvent` was getting `preventDefault()` called by default. - - For errors, expose `message`, `name` and `type` are exposed. + - For errors, expose `message`, `name` and `type`. - Fix `vm.depth` not being initialized. - Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes. From 14b88b04a30122c2e66cbd5ebd604e658d27343e Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Fri, 22 Sep 2023 11:59:47 -0700 Subject: [PATCH 06/25] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8ac57bb..961ebf3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Update the way events and errors are passed to the functions. - For events, expose `preventDefault()` and `stopPropagation()` functions. - NOTE: Previously, all React's `SyntheticEvent` was getting `preventDefault()` called by default. + NOTE: Previously, all React's `SyntheticEvent`s were getting `preventDefault()` called by default. - For errors, expose `message`, `name` and `type`. - Fix `vm.depth` not being initialized. - Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes. From b2ae5e37094072c129a33f7fc071a3239d06286e Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Mon, 25 Sep 2023 11:23:02 -0700 Subject: [PATCH 07/25] Inject global native static functions, objects and libs --- CHANGELOG.md | 1 + dist/index.js | 2 +- src/lib/vm/vm.js | 118 ++++++++++++++++++++++++----------------------- 3 files changed, 62 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 961ebf3e..03a69b23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Pending +- Expose certain native objects directly into the state. It should improve access to the functions. - Update the way events and errors are passed to the functions. - For events, expose `preventDefault()` and `stopPropagation()` functions. NOTE: Previously, all React's `SyntheticEvent`s were getting `preventDefault()` called by default. diff --git a/dist/index.js b/dist/index.js index 99d9c0b5..cefb1067 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function z(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Tr,EthersProviderContext:()=>on,Widget:()=>Bo,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Er,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>P,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>$,ipfsUrl:()=>W,isArray:()=>A,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>z,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),P=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var A=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!A(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return A(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},z=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Pt(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function At(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Pt(p,t)},p.contract=At(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,zt,$t,Wt,Kt=n.n(Dt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Kt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==(zt=Kt().get(re))&&void 0!==zt?zt:void 0,accountId:null!==($t=null!==(Wt=Kt().get(re))&&void 0!==Wt?Wt:Kt().get(ee))&&void 0!==$t?$t:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(ee,o),e.config.walletConnectCallback(o)):Kt().remove(ee),i=null!==(n=Kt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(re,n):Kt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Ht((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}var xe=["node","children"],Se=["node"],ke=["node"],Oe=["node"],je=["node"],Ie=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ce=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Pe(t,xe);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Pe(t,Se);return e?r().createElement("a",Le({onClick:e},n)):r().createElement("a",Le({target:"_blank"},n))},img:function(t){t.node;var e=Pe(t,ke);return r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Pe(t,Oe);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Pe(t,je);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Pe(t,Ie),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Ae=require("react-uuid");var Ne=n.n(Ae);function Te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Je(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ze(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Je(i,n,o,a,c,"next",t)}function c(t){Je(i,n,o,a,c,"throw",t)}a(void 0)}))}}var $e=x.mul(2e3),We=x.mul(500),Ke=x.mul(500),Xe=x.mul(500),He=function(){var t=ze(De().mark((function t(e,r){var n;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),Ve=function(){var t=ze(De().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ge(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ge(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==qe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===qe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,He(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):We).add(l?u()(0):Xe).add(Ke),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):$e),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ye=function(){var t=ze(De().mark((function t(e,r,n){return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ze=function(){var t=ze(De().mark((function t(e,r,n){var o,i;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Qe=require("react-bootstrap"),tr=require("idb");function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function rr(t,e){if(t){if("string"==typeof t)return nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nr(t,e):void 0}}function nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function ir(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ar(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ir(i,n,o,a,c,"next",t)}function c(t){ir(i,n,o,a,c,"throw",t)}a(void 0)}))}}function cr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,tr.openDB)(e,1,{upgrade:function(t){t.createObjectStore(yr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ar(or().mark((function t(e){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(yr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ar(or().mark((function t(e,r){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(yr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:fr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=dr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===hr||i.status===pr&&i.time+3e5>(new Date).getTime()||(i.status!==fr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===hr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=hr,e&&e().then((function(e){i.status=pr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=pr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===ur&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===sr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||rr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=dr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:ur,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=ar(or().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:sr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function jr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ir(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Lr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Lr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Sr),p=Ir((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",kr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Nr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const _r=require("react-bootstrap-typeahead"),Br=require("styled-components");var Ur=n.n(Br);const Rr=require("elliptic"),Mr=require("bn.js");var Fr=n.n(Mr);const qr=require("tweetnacl"),Gr=require("iframe-resizer-react");var Dr=n.n(Gr);function Jr(){return Jr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rn(t,e,r){return Rn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Mn(o,r.prototype),o},Rn.apply(null,arguments)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Br.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!oo[s.as]&&delete s.as,s.forwardedAs&&!oo[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=zn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Re.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(qn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Hn(Hn({},s),{},{children:g}));if(u)return(0,Br.isStyledComponent)(u)?r().createElement.apply(r(),[u,Hn({},s)].concat(qn(g))):u(Hn({children:g},s));if("Widget"===o)return r().createElement(Bo,s);if("CommitButton"===o)return r().createElement(Tr,Fn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Fe(),s,g);if("Tooltip"===o)return r().createElement(Qe.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Qe.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(_r.Typeahead,s);if("Markdown"===o)return r().createElement(Ce,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ue(),Fn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ue(),s,g);if("iframe"===o)return r().createElement(Vr,s);if("Web3Connect"===o)return r().createElement(an,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Hn({},s)].concat(qn(g)));if(!1===i)return r().createElement(o,Hn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return po(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=co[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2],r[3])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2],r[3])}if("Social"===t&&"keys"===e){var c;if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return(c=this.vm).cachedSocialKeys.apply(c,qn(r))}if("Social"===t&&"index"===e){var u;if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return(u=this.vm).cachedIndex.apply(u,qn(r))}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe', 'cacheOptions'");var s=zn(r,6),l=s[0],f=s[1],h=s[2],p=s[3],d=s[4],y=s[5];return this.vm.cachedNearView(l,f,h,p,go(d,p),y)}if("Near"===t&&"asyncView"===e){var v;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(v=this.vm).asyncNearView.apply(v,qn(r))}if("Near"===t&&"block"===e){var m=zn(r,3),g=m[0],b=m[1],w=m[2];return this.vm.cachedNearBlock(g,go(b,g),w)}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(A(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var E;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(E=r[2])&&void 0!==E?E:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return yo(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var x=JSON.parse(r[0]);return vo(x),x}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return yo(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return yo(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return yo(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return yo(t)}));var S=Object.assign.apply(Object,qn(r));return vo(S),S}if("fromEntries"===e){var k=Object.fromEntries(r[0]);return vo(k),k}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Kn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var O=r[0];this.vm.state.state=O,this.vm.setReactState(O)}return this.vm.state.state}if("State"===t&&"update"===e){var j;if(N(r[0]))this.vm.state.state=null!==(j=this.vm.state.state)&&void 0!==j?j:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var I;this.vm.state.state=null!==(I=this.vm.state.state)&&void 0!==I?I:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:ro},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:ro},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:no},r[0],r[1])}if("Storage"===t&&"get"===e){var L;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(L=r[1])&&void 0!==L?L:this.vm.widgetSrc,type:no},r[0])}var P,C,T;if("console"===t&&"log"===e)return(P=console).log.apply(P,[this.vm.widgetSrc].concat(qn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(C=navigator.clipboard).writeText.apply(C,qn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(T=this.vm).vmRequire.apply(T,qn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var B,U=null===(B=this.vm.ethersProviderContext)||void 0===B?void 0:B.setChain;if(!U)throw new Error("The gateway doesn't support `setChain` operation");return U.apply(void 0,qn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var R=Rn(WebSocket,qn(r));return this.vm.websockets.push(R),R}throw new Error("Unsupported WebSocket method")}if(void 0===a){if(uo.hasOwnProperty(e))return uo[e].apply(uo,qn(r));if("fetch"===e){var M;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(M=this.vm).cachedFetch.apply(M,qn(r))}if("asyncFetch"===e){var F;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(F=this.vm).asyncFetch.apply(F,qn(r))}if("useCache"===e){var q;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(q=this.vm).useCache.apply(q,qn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var G=r[0],D=this.hookIndex++,J=this.vm.hooks[D];if(J)return[J.state,J.setState];var z=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[D])||void 0===r?void 0:r.state)),i.vm.setReactHook(D,{state:e,setState:t}),e};return[z(G),z]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var $=r[0];if(!_($))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var W=this.hookIndex++,K=r[1],X=this.vm.hooks[W];if(X){var H=X.dependencies;if(void 0!==H&&st(H,K))return}var V=null==X?void 0:X.cleanup;return _(V)&&V(),void this.vm.setReactHook(W,{cleanup:$(),dependencies:K})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var Y="useMemo"===e,Z=Y?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(Z,"'. Optional: 'dependencies'"));var Q=r[0];if(!_(Q))throw new Error("Method: ".concat(e,". The first argument '").concat(Z,"' must be a function"));var tt=this.hookIndex++,et=r[1],rt=this.vm.hooks[tt];if(rt){var nt=rt.dependencies;if(void 0!==nt&&st(nt,et))return rt.memoized}var ot=Y?Q():Q;return this.vm.setReactHook(tt,{memoized:ot,dependencies:et}),ot}if("setTimeout"===e){var it=zn(r,2),ct=it[0],ut=it[1],lt=setTimeout((function(){i.vm.alive&&ct()}),ut);return this.vm.timeouts.add(lt),lt}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var ft=zn(r,2),ht=ft[0],pt=ft[1],dt=setInterval((function(){i.vm.alive&&ht()}),pt);return this.vm.intervals.add(dt),dt}if("clearTimeout"===e){var yt=r[0];return this.vm.timeouts.delete(yt),clearTimeout(yt)}if("clearInterval"===e){var vt=r[0];return this.vm.intervals.delete(vt),clearInterval(vt)}}}}else{var mt=e===t?a:a[e];if("function"==typeof mt)return o?Rn(mt,qn(r)):mt.apply(void 0,qn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(po(n),null!=e&&e.requireState&&n!==eo)throw new Error("The top object should be ".concat(eo));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(yo(o),o===this.stack.state&&n in co){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in co){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return yo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,qn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Kn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,P=I.key;if("++"===t.operator)return t.prefix?++L[P]:L[P]++;if("--"===t.operator)return t.prefix?--L[P]:L[P]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);yo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,A;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=mo(B);if(!(0,Br.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Ur()(null!=U?U:B)}else{if("keyframes"===T)C=Br.keyframes;else{if(!(T in oo))throw new Error("Unsupported styled tag: "+T);C=Ur()(T)}A=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([A].concat(qn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(qn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(xo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);yo(s);var l,f=Un(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(xo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Kn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(bo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Un(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,P=!1,C=Un(I.consequent);try{for(C.s();!(L=C.n()).done;){var A=L.value,N=k.executeStatement(A);if(N){if(N.break){P=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(P)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Oo=function(){function t(e){var r,n=this;Gn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in fo?fo[o]:fo[o]=ho.parse(o,lo),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Jn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n,o){var i=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(a){return i.cache.socialGet(i.near,t,e,r,n,a,o)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.cachedViewCall(o.near,o.near.config.contractName,"keys",{keys:t,options:r},e,i,n)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedEthersCall(o.ethersProvider,t,e,r,n)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o,i){var a=this;return this.cachedPromise((function(o){return a.cache.cachedViewCall(a.near,t,e,r,n,o,i)}),o)}},{key:"cachedNearBlock",value:function(t,e,r){var n=this;return this.cachedPromise((function(e){return n.cache.cachedBlock(n.near,t,e,r)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.cachedFetch(t,e,o,r)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(i){return o.cache.socialIndex(o.near,t,e,r,i,n)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedCustomPromise({widgetSrc:o.widgetSrc,dataKey:e},t,r,n)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=zn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state={props:N(e)?Object.assign({},e):e,context:r,state:c,nacl:Zn,get elliptic(){return delete this.elliptic,this.elliptic=Qr()(Rr),this.elliptic},ethers:Qn,nanoid:to},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new ko(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const jo=require("react-error-boundary");function Io(t){return Io="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Io(t)}var Lo=["loading","src","code","depth","config","props"];function Po(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Co(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Lo),p=No((0,e.useState)(0),2),d=p[0],y=p[1],v=No((0,e.useState)(null),2),m=v[0],g=v[1],b=No((0,e.useState)(null),2),E=b[0],x=b[1],S=No((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=No((0,e.useState)(0),2),I=j[0],C=j[1],A=No((0,e.useState)({}),2),B=A[0],U=A[1],R=No((0,e.useState)(null),2),M=R[0],F=R[1],q=No((0,e.useState)(null),2),G=q[0],D=q[1],J=No((0,e.useState)(null),2),z=J[0],$=J[1],W=No((0,e.useState)(null),2),K=W[0],X=W[1],H=No((0,e.useState)(null),2),V=H[0],Y=H[1],Z=No((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(on),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Er(rt),ot=Gt(rt),it=ue(rt),at=No((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=To(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);st(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=No(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),$(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new Oo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ne()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Co(Co({},h),{},{ref:n})};if(!st(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=ut?r().createElement(jo.ErrorBoundary,{FallbackComponent:P,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(_e,{transactions:G,onHide:function(){return D(null)},networkId:rt}),z&&r().createElement(Nr,{show:!0,widgetSrc:E,data:z.data,force:z.force,onHide:function(){return $(null)},onCommit:z.onCommit,onCancel:z.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function z(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Tr,EthersProviderContext:()=>on,Widget:()=>Bo,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Er,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>P,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>$,ipfsUrl:()=>W,isArray:()=>A,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>z,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),P=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var A=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!A(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return A(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},z=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Pt(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function At(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Pt(p,t)},p.contract=At(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,zt,$t,Wt,Kt=n.n(Dt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Kt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==(zt=Kt().get(re))&&void 0!==zt?zt:void 0,accountId:null!==($t=null!==(Wt=Kt().get(re))&&void 0!==Wt?Wt:Kt().get(ee))&&void 0!==$t?$t:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(ee,o),e.config.walletConnectCallback(o)):Kt().remove(ee),i=null!==(n=Kt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(re,n):Kt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Ht((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}var xe=["node","children"],Se=["node"],ke=["node"],Oe=["node"],je=["node"],Ie=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ce=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Pe(t,xe);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Pe(t,Se);return e?r().createElement("a",Le({onClick:e},n)):r().createElement("a",Le({target:"_blank"},n))},img:function(t){t.node;var e=Pe(t,ke);return r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Pe(t,Oe);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Pe(t,je);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Pe(t,Ie),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Ae=require("react-uuid");var Ne=n.n(Ae);function Te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Je(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ze(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Je(i,n,o,a,c,"next",t)}function c(t){Je(i,n,o,a,c,"throw",t)}a(void 0)}))}}var $e=x.mul(2e3),We=x.mul(500),Ke=x.mul(500),Xe=x.mul(500),He=function(){var t=ze(De().mark((function t(e,r){var n;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),Ve=function(){var t=ze(De().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ge(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ge(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==qe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===qe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,He(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):We).add(l?u()(0):Xe).add(Ke),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):$e),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ye=function(){var t=ze(De().mark((function t(e,r,n){return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ze=function(){var t=ze(De().mark((function t(e,r,n){var o,i;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Qe=require("react-bootstrap"),tr=require("idb");function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function rr(t,e){if(t){if("string"==typeof t)return nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nr(t,e):void 0}}function nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function ir(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ar(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ir(i,n,o,a,c,"next",t)}function c(t){ir(i,n,o,a,c,"throw",t)}a(void 0)}))}}function cr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,tr.openDB)(e,1,{upgrade:function(t){t.createObjectStore(yr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ar(or().mark((function t(e){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(yr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ar(or().mark((function t(e,r){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(yr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:fr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=dr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===hr||i.status===pr&&i.time+3e5>(new Date).getTime()||(i.status!==fr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===hr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=hr,e&&e().then((function(e){i.status=pr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=pr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===ur&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===sr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||rr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=dr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:ur,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=ar(or().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:sr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function jr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ir(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Lr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Lr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Sr),p=Ir((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",kr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Nr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const _r=require("react-bootstrap-typeahead"),Br=require("styled-components");var Ur=n.n(Br);const Rr=require("elliptic"),Mr=require("bn.js");var Fr=n.n(Mr);const qr=require("tweetnacl"),Gr=require("iframe-resizer-react");var Dr=n.n(Gr);function Jr(){return Jr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rn(t,e,r){return Rn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Mn(o,r.prototype),o},Rn.apply(null,arguments)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Br.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!oo[s.as]&&delete s.as,s.forwardedAs&&!oo[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=zn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Re.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(qn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Hn(Hn({},s),{},{children:g}));if(u)return(0,Br.isStyledComponent)(u)?r().createElement.apply(r(),[u,Hn({},s)].concat(qn(g))):u(Hn({children:g},s));if("Widget"===o)return r().createElement(Bo,s);if("CommitButton"===o)return r().createElement(Tr,Fn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Fe(),s,g);if("Tooltip"===o)return r().createElement(Qe.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Qe.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(_r.Typeahead,s);if("Markdown"===o)return r().createElement(Ce,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ue(),Fn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ue(),s,g);if("iframe"===o)return r().createElement(Vr,s);if("Web3Connect"===o)return r().createElement(an,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Hn({},s)].concat(qn(g)));if(!1===i)return r().createElement(o,Hn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return po(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=co[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2],r[3])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2],r[3])}if("Social"===t&&"keys"===e){var c;if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return(c=this.vm).cachedSocialKeys.apply(c,qn(r))}if("Social"===t&&"index"===e){var u;if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return(u=this.vm).cachedIndex.apply(u,qn(r))}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe', 'cacheOptions'");var s=zn(r,6),l=s[0],f=s[1],h=s[2],p=s[3],d=s[4],y=s[5];return this.vm.cachedNearView(l,f,h,p,go(d,p),y)}if("Near"===t&&"asyncView"===e){var v;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(v=this.vm).asyncNearView.apply(v,qn(r))}if("Near"===t&&"block"===e){var m=zn(r,3),g=m[0],b=m[1],w=m[2];return this.vm.cachedNearBlock(g,go(b,g),w)}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(A(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var E;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(E=r[2])&&void 0!==E?E:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return yo(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var x=JSON.parse(r[0]);return vo(x),x}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return yo(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return yo(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return yo(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return yo(t)}));var S=Object.assign.apply(Object,qn(r));return vo(S),S}if("fromEntries"===e){var k=Object.fromEntries(r[0]);return vo(k),k}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Kn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var O=r[0];this.vm.state.state=O,this.vm.setReactState(O)}return this.vm.state.state}if("State"===t&&"update"===e){var j;if(N(r[0]))this.vm.state.state=null!==(j=this.vm.state.state)&&void 0!==j?j:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var I;this.vm.state.state=null!==(I=this.vm.state.state)&&void 0!==I?I:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:ro},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:ro},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:no},r[0],r[1])}if("Storage"===t&&"get"===e){var L;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(L=r[1])&&void 0!==L?L:this.vm.widgetSrc,type:no},r[0])}var P,C,T;if("console"===t&&"log"===e)return(P=console).log.apply(P,[this.vm.widgetSrc].concat(qn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(C=navigator.clipboard).writeText.apply(C,qn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(T=this.vm).vmRequire.apply(T,qn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var B,U=null===(B=this.vm.ethersProviderContext)||void 0===B?void 0:B.setChain;if(!U)throw new Error("The gateway doesn't support `setChain` operation");return U.apply(void 0,qn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var R=Rn(WebSocket,qn(r));return this.vm.websockets.push(R),R}throw new Error("Unsupported WebSocket method")}if(void 0===a){if("fetch"===e){var M;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(M=this.vm).cachedFetch.apply(M,qn(r))}if("asyncFetch"===e){var F;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(F=this.vm).asyncFetch.apply(F,qn(r))}if("useCache"===e){var q;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(q=this.vm).useCache.apply(q,qn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var G=r[0],D=this.hookIndex++,J=this.vm.hooks[D];if(J)return[J.state,J.setState];var z=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[D])||void 0===r?void 0:r.state)),i.vm.setReactHook(D,{state:e,setState:t}),e};return[z(G),z]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var $=r[0];if(!_($))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var W=this.hookIndex++,K=r[1],X=this.vm.hooks[W];if(X){var H=X.dependencies;if(void 0!==H&&st(H,K))return}var V=null==X?void 0:X.cleanup;return _(V)&&V(),void this.vm.setReactHook(W,{cleanup:$(),dependencies:K})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var Y="useMemo"===e,Z=Y?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(Z,"'. Optional: 'dependencies'"));var Q=r[0];if(!_(Q))throw new Error("Method: ".concat(e,". The first argument '").concat(Z,"' must be a function"));var tt=this.hookIndex++,et=r[1],rt=this.vm.hooks[tt];if(rt){var nt=rt.dependencies;if(void 0!==nt&&st(nt,et))return rt.memoized}var ot=Y?Q():Q;return this.vm.setReactHook(tt,{memoized:ot,dependencies:et}),ot}if("setTimeout"===e){var it=zn(r,2),ct=it[0],ut=it[1],lt=setTimeout((function(){i.vm.alive&&ct()}),ut);return this.vm.timeouts.add(lt),lt}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var ft=zn(r,2),ht=ft[0],pt=ft[1],dt=setInterval((function(){i.vm.alive&&ht()}),pt);return this.vm.intervals.add(dt),dt}if("clearTimeout"===e){var yt=r[0];return this.vm.timeouts.delete(yt),clearTimeout(yt)}if("clearInterval"===e){var vt=r[0];return this.vm.intervals.delete(vt),clearInterval(vt)}}}}else{var mt=e===t?a:a[e];if("function"==typeof mt)return o?Rn(mt,qn(r)):mt.apply(void 0,qn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(po(n),null!=e&&e.requireState&&n!==eo)throw new Error("The top object should be ".concat(eo));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(yo(o),o===this.stack.state&&n in co){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in co){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return yo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,qn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Kn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,P=I.key;if("++"===t.operator)return t.prefix?++L[P]:L[P]++;if("--"===t.operator)return t.prefix?--L[P]:L[P]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);yo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,A;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=mo(B);if(!(0,Br.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Ur()(null!=U?U:B)}else{if("keyframes"===T)C=Br.keyframes;else{if(!(T in oo))throw new Error("Unsupported styled tag: "+T);C=Ur()(T)}A=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([A].concat(qn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(qn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(xo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);yo(s);var l,f=Un(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(xo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Kn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(bo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Un(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,P=!1,C=Un(I.consequent);try{for(C.s();!(L=C.n()).done;){var A=L.value,N=k.executeStatement(A);if(N){if(N.break){P=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(P)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Oo=function(){function t(e){var r,n=this;Gn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in fo?fo[o]:fo[o]=ho.parse(o,lo),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Jn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n,o){var i=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(a){return i.cache.socialGet(i.near,t,e,r,n,a,o)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.cachedViewCall(o.near,o.near.config.contractName,"keys",{keys:t,options:r},e,i,n)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedEthersCall(o.ethersProvider,t,e,r,n)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o,i){var a=this;return this.cachedPromise((function(o){return a.cache.cachedViewCall(a.near,t,e,r,n,o,i)}),o)}},{key:"cachedNearBlock",value:function(t,e,r){var n=this;return this.cachedPromise((function(e){return n.cache.cachedBlock(n.near,t,e,r)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.cachedFetch(t,e,o,r)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(i){return o.cache.socialIndex(o.near,t,e,r,i,n)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedCustomPromise({widgetSrc:o.widgetSrc,dataKey:e},t,r,n)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=zn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Hn(Hn({},uo),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=Qr()(Rr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new ko(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const jo=require("react-error-boundary");function Io(t){return Io="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Io(t)}var Lo=["loading","src","code","depth","config","props"];function Po(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Co(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Lo),p=No((0,e.useState)(0),2),d=p[0],y=p[1],v=No((0,e.useState)(null),2),m=v[0],g=v[1],b=No((0,e.useState)(null),2),E=b[0],x=b[1],S=No((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=No((0,e.useState)(0),2),I=j[0],C=j[1],A=No((0,e.useState)({}),2),B=A[0],U=A[1],R=No((0,e.useState)(null),2),M=R[0],F=R[1],q=No((0,e.useState)(null),2),G=q[0],D=q[1],J=No((0,e.useState)(null),2),z=J[0],$=J[1],W=No((0,e.useState)(null),2),K=W[0],X=W[1],H=No((0,e.useState)(null),2),V=H[0],Y=H[1],Z=No((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(on),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Er(rt),ot=Gt(rt),it=ue(rt),at=No((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=To(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);st(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=No(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),$(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new Oo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ne()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Co(Co({},h),{},{ref:n})};if(!st(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=ut?r().createElement(jo.ErrorBoundary,{FallbackComponent:P,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(_e,{transactions:G,onHide:function(){return D(null)},networkId:rt}),z&&r().createElement(Nr,{show:!0,widgetSrc:E,data:z.data,force:z.force,onHide:function(){return $(null)},onCommit:z.onCommit,onCancel:z.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index d55cf4eb..69b7daec 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -64,30 +64,6 @@ import * as ToggleGroup from "@radix-ui/react-toggle-group"; import * as Toolbar from "@radix-ui/react-toolbar"; import * as RadixTooltip from "@radix-ui/react-tooltip"; -const frozenNacl = Object.freeze({ - randomBytes: deepFreeze(nacl.randomBytes), - secretbox: deepFreeze(nacl.secretbox), - scalarMult: deepFreeze(nacl.scalarMult), - box: deepFreeze(nacl.box), - sign: deepFreeze(nacl.sign), - hash: deepFreeze(nacl.hash), - verify: deepFreeze(nacl.verify), -}); - -const frozenEthers = Object.freeze({ - utils: deepFreeze(ethers.utils), - BigNumber: deepFreeze(ethers.BigNumber), - Contract: deepFreeze(ethers.Contract), - providers: deepFreeze(ethers.providers), -}); - -// `nanoid.nanoid()` is a but odd, but it seems better to match the official -// API than to create an alias -const frozenNanoid = Object.freeze({ - nanoid: deepFreeze(nanoid), - customAlphabet: deepFreeze(customAlphabet), -}); - const LoopLimit = 1000000; const MaxDepth = 32; @@ -234,40 +210,70 @@ const Keywords = { console: true, styled: true, Object: true, - Date, - Number, - Big, - Math, - Buffer, - Audio, - Image, - File, - Blob, - FileReader, - URL, - Array, - BN, - Uint8Array, - Map, - Set, clipboard: true, Ethers: true, WebSocket: true, VM: true, }; -const NativeFunctions = { - encodeURIComponent, - decodeURIComponent, - isNaN, - parseInt, - parseFloat, - isFinite, - btoa, - atob, - decodeURI, - encodeURI, -}; +const GlobalInjected = deepFreeze( + cloneDeep({ + // Functions + encodeURIComponent, + decodeURIComponent, + isNaN, + parseInt, + parseFloat, + isFinite, + btoa, + atob, + decodeURI, + encodeURI, + + // Libs + nacl: { + randomBytes: nacl.randomBytes, + secretbox: nacl.secretbox, + scalarMult: nacl.scalarMult, + box: nacl.box, + sign: nacl.sign, + hash: nacl.hash, + verify: nacl.verify, + }, + ethers: { + utils: ethers.utils, + BigNumber: ethers.BigNumber, + Contract: ethers.Contract, + providers: ethers.providers, + }, + // `nanoid.nanoid()` is a bit odd, but it seems better to match the official + // API than to create an alias + nanoid: { + nanoid, + customAlphabet, + }, + + // Objects + Promise, + Date, + Number, + String, + Big, + Math, + Buffer, + Audio, + Image, + File, + Blob, + FileReader, + URL, + Array, + BN, + Uint8Array, + Map, + Set, + }) +); const ReservedKeys = { [ReactKey]: true, @@ -1005,9 +1011,7 @@ class VmStack { throw new Error("Unsupported WebSocket method"); } } else if (keywordType === undefined) { - if (NativeFunctions.hasOwnProperty(callee)) { - return NativeFunctions[callee](...args); - } else if (callee === "fetch") { + if (callee === "fetch") { if (args.length < 1) { throw new Error( "Method: fetch. Required arguments: 'url'. Optional: 'options'" @@ -2212,17 +2216,15 @@ export default class VM { const { hooks, state } = reactState ?? {}; this.hooks = hooks; this.state = { + ...GlobalInjected, props: isObject(props) ? Object.assign({}, props) : props, context, state, - nacl: frozenNacl, get elliptic() { delete this.elliptic; this.elliptic = cloneDeep(elliptic); return this.elliptic; }, - ethers: frozenEthers, - nanoid: frozenNanoid, }; this.forwardedProps = forwardedProps; this.loopLimit = LoopLimit; From 6ad83eee4331cd059dd5de504bda1ac2745ef8a1 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Mon, 25 Sep 2023 11:54:30 -0700 Subject: [PATCH 08/25] Rebuild --- dist/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index cefb1067..b4729de1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function z(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Tr,EthersProviderContext:()=>on,Widget:()=>Bo,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Er,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>P,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>$,ipfsUrl:()=>W,isArray:()=>A,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>z,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),P=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var A=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!A(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return A(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},z=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Pt(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function At(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Pt(p,t)},p.contract=At(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,zt,$t,Wt,Kt=n.n(Dt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Kt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==(zt=Kt().get(re))&&void 0!==zt?zt:void 0,accountId:null!==($t=null!==(Wt=Kt().get(re))&&void 0!==Wt?Wt:Kt().get(ee))&&void 0!==$t?$t:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(ee,o),e.config.walletConnectCallback(o)):Kt().remove(ee),i=null!==(n=Kt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(re,n):Kt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Ht((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}var xe=["node","children"],Se=["node"],ke=["node"],Oe=["node"],je=["node"],Ie=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ce=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Pe(t,xe);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Pe(t,Se);return e?r().createElement("a",Le({onClick:e},n)):r().createElement("a",Le({target:"_blank"},n))},img:function(t){t.node;var e=Pe(t,ke);return r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Pe(t,Oe);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Pe(t,je);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Pe(t,Ie),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Ae=require("react-uuid");var Ne=n.n(Ae);function Te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Je(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ze(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Je(i,n,o,a,c,"next",t)}function c(t){Je(i,n,o,a,c,"throw",t)}a(void 0)}))}}var $e=x.mul(2e3),We=x.mul(500),Ke=x.mul(500),Xe=x.mul(500),He=function(){var t=ze(De().mark((function t(e,r){var n;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),Ve=function(){var t=ze(De().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ge(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ge(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==qe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===qe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,He(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):We).add(l?u()(0):Xe).add(Ke),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):$e),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ye=function(){var t=ze(De().mark((function t(e,r,n){return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ze=function(){var t=ze(De().mark((function t(e,r,n){var o,i;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Qe=require("react-bootstrap"),tr=require("idb");function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function rr(t,e){if(t){if("string"==typeof t)return nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nr(t,e):void 0}}function nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function ir(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ar(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ir(i,n,o,a,c,"next",t)}function c(t){ir(i,n,o,a,c,"throw",t)}a(void 0)}))}}function cr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,tr.openDB)(e,1,{upgrade:function(t){t.createObjectStore(yr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ar(or().mark((function t(e){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(yr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ar(or().mark((function t(e,r){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(yr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:fr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=dr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===hr||i.status===pr&&i.time+3e5>(new Date).getTime()||(i.status!==fr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===hr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=hr,e&&e().then((function(e){i.status=pr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=pr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===ur&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===sr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||rr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=dr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:ur,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=ar(or().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:sr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function jr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ir(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Lr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Lr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Sr),p=Ir((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",kr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Nr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const _r=require("react-bootstrap-typeahead"),Br=require("styled-components");var Ur=n.n(Br);const Rr=require("elliptic"),Mr=require("bn.js");var Fr=n.n(Mr);const qr=require("tweetnacl"),Gr=require("iframe-resizer-react");var Dr=n.n(Gr);function Jr(){return Jr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rn(t,e,r){return Rn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Mn(o,r.prototype),o},Rn.apply(null,arguments)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Br.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!oo[s.as]&&delete s.as,s.forwardedAs&&!oo[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=zn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Re.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(qn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Hn(Hn({},s),{},{children:g}));if(u)return(0,Br.isStyledComponent)(u)?r().createElement.apply(r(),[u,Hn({},s)].concat(qn(g))):u(Hn({children:g},s));if("Widget"===o)return r().createElement(Bo,s);if("CommitButton"===o)return r().createElement(Tr,Fn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Fe(),s,g);if("Tooltip"===o)return r().createElement(Qe.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Qe.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(_r.Typeahead,s);if("Markdown"===o)return r().createElement(Ce,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ue(),Fn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ue(),s,g);if("iframe"===o)return r().createElement(Vr,s);if("Web3Connect"===o)return r().createElement(an,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Hn({},s)].concat(qn(g)));if(!1===i)return r().createElement(o,Hn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return po(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=co[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2],r[3])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2],r[3])}if("Social"===t&&"keys"===e){var c;if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return(c=this.vm).cachedSocialKeys.apply(c,qn(r))}if("Social"===t&&"index"===e){var u;if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return(u=this.vm).cachedIndex.apply(u,qn(r))}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe', 'cacheOptions'");var s=zn(r,6),l=s[0],f=s[1],h=s[2],p=s[3],d=s[4],y=s[5];return this.vm.cachedNearView(l,f,h,p,go(d,p),y)}if("Near"===t&&"asyncView"===e){var v;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(v=this.vm).asyncNearView.apply(v,qn(r))}if("Near"===t&&"block"===e){var m=zn(r,3),g=m[0],b=m[1],w=m[2];return this.vm.cachedNearBlock(g,go(b,g),w)}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(A(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var E;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(E=r[2])&&void 0!==E?E:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return yo(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var x=JSON.parse(r[0]);return vo(x),x}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return yo(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return yo(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return yo(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return yo(t)}));var S=Object.assign.apply(Object,qn(r));return vo(S),S}if("fromEntries"===e){var k=Object.fromEntries(r[0]);return vo(k),k}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Kn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var O=r[0];this.vm.state.state=O,this.vm.setReactState(O)}return this.vm.state.state}if("State"===t&&"update"===e){var j;if(N(r[0]))this.vm.state.state=null!==(j=this.vm.state.state)&&void 0!==j?j:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var I;this.vm.state.state=null!==(I=this.vm.state.state)&&void 0!==I?I:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:ro},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:ro},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:no},r[0],r[1])}if("Storage"===t&&"get"===e){var L;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(L=r[1])&&void 0!==L?L:this.vm.widgetSrc,type:no},r[0])}var P,C,T;if("console"===t&&"log"===e)return(P=console).log.apply(P,[this.vm.widgetSrc].concat(qn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(C=navigator.clipboard).writeText.apply(C,qn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(T=this.vm).vmRequire.apply(T,qn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var B,U=null===(B=this.vm.ethersProviderContext)||void 0===B?void 0:B.setChain;if(!U)throw new Error("The gateway doesn't support `setChain` operation");return U.apply(void 0,qn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var R=Rn(WebSocket,qn(r));return this.vm.websockets.push(R),R}throw new Error("Unsupported WebSocket method")}if(void 0===a){if("fetch"===e){var M;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(M=this.vm).cachedFetch.apply(M,qn(r))}if("asyncFetch"===e){var F;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(F=this.vm).asyncFetch.apply(F,qn(r))}if("useCache"===e){var q;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(q=this.vm).useCache.apply(q,qn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var G=r[0],D=this.hookIndex++,J=this.vm.hooks[D];if(J)return[J.state,J.setState];var z=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[D])||void 0===r?void 0:r.state)),i.vm.setReactHook(D,{state:e,setState:t}),e};return[z(G),z]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var $=r[0];if(!_($))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var W=this.hookIndex++,K=r[1],X=this.vm.hooks[W];if(X){var H=X.dependencies;if(void 0!==H&&st(H,K))return}var V=null==X?void 0:X.cleanup;return _(V)&&V(),void this.vm.setReactHook(W,{cleanup:$(),dependencies:K})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var Y="useMemo"===e,Z=Y?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(Z,"'. Optional: 'dependencies'"));var Q=r[0];if(!_(Q))throw new Error("Method: ".concat(e,". The first argument '").concat(Z,"' must be a function"));var tt=this.hookIndex++,et=r[1],rt=this.vm.hooks[tt];if(rt){var nt=rt.dependencies;if(void 0!==nt&&st(nt,et))return rt.memoized}var ot=Y?Q():Q;return this.vm.setReactHook(tt,{memoized:ot,dependencies:et}),ot}if("setTimeout"===e){var it=zn(r,2),ct=it[0],ut=it[1],lt=setTimeout((function(){i.vm.alive&&ct()}),ut);return this.vm.timeouts.add(lt),lt}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var ft=zn(r,2),ht=ft[0],pt=ft[1],dt=setInterval((function(){i.vm.alive&&ht()}),pt);return this.vm.intervals.add(dt),dt}if("clearTimeout"===e){var yt=r[0];return this.vm.timeouts.delete(yt),clearTimeout(yt)}if("clearInterval"===e){var vt=r[0];return this.vm.intervals.delete(vt),clearInterval(vt)}}}}else{var mt=e===t?a:a[e];if("function"==typeof mt)return o?Rn(mt,qn(r)):mt.apply(void 0,qn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(po(n),null!=e&&e.requireState&&n!==eo)throw new Error("The top object should be ".concat(eo));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(yo(o),o===this.stack.state&&n in co){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in co){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return yo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,qn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Kn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,P=I.key;if("++"===t.operator)return t.prefix?++L[P]:L[P]++;if("--"===t.operator)return t.prefix?--L[P]:L[P]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);yo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,A;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=mo(B);if(!(0,Br.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Ur()(null!=U?U:B)}else{if("keyframes"===T)C=Br.keyframes;else{if(!(T in oo))throw new Error("Unsupported styled tag: "+T);C=Ur()(T)}A=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([A].concat(qn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(qn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(xo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);yo(s);var l,f=Un(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(xo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Kn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(bo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Un(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,P=!1,C=Un(I.consequent);try{for(C.s();!(L=C.n()).done;){var A=L.value,N=k.executeStatement(A);if(N){if(N.break){P=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(P)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Oo=function(){function t(e){var r,n=this;Gn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in fo?fo[o]:fo[o]=ho.parse(o,lo),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Jn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n,o){var i=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(a){return i.cache.socialGet(i.near,t,e,r,n,a,o)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.cachedViewCall(o.near,o.near.config.contractName,"keys",{keys:t,options:r},e,i,n)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedEthersCall(o.ethersProvider,t,e,r,n)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o,i){var a=this;return this.cachedPromise((function(o){return a.cache.cachedViewCall(a.near,t,e,r,n,o,i)}),o)}},{key:"cachedNearBlock",value:function(t,e,r){var n=this;return this.cachedPromise((function(e){return n.cache.cachedBlock(n.near,t,e,r)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.cachedFetch(t,e,o,r)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(i){return o.cache.socialIndex(o.near,t,e,r,i,n)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedCustomPromise({widgetSrc:o.widgetSrc,dataKey:e},t,r,n)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=zn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Hn(Hn({},uo),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=Qr()(Rr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new ko(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const jo=require("react-error-boundary");function Io(t){return Io="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Io(t)}var Lo=["loading","src","code","depth","config","props"];function Po(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Co(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Lo),p=No((0,e.useState)(0),2),d=p[0],y=p[1],v=No((0,e.useState)(null),2),m=v[0],g=v[1],b=No((0,e.useState)(null),2),E=b[0],x=b[1],S=No((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=No((0,e.useState)(0),2),I=j[0],C=j[1],A=No((0,e.useState)({}),2),B=A[0],U=A[1],R=No((0,e.useState)(null),2),M=R[0],F=R[1],q=No((0,e.useState)(null),2),G=q[0],D=q[1],J=No((0,e.useState)(null),2),z=J[0],$=J[1],W=No((0,e.useState)(null),2),K=W[0],X=W[1],H=No((0,e.useState)(null),2),V=H[0],Y=H[1],Z=No((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(on),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Er(rt),ot=Gt(rt),it=ue(rt),at=No((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=To(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);st(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=No(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),$(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new Oo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ne()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Co(Co({},h),{},{ref:n})};if(!st(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=ut?r().createElement(jo.ErrorBoundary,{FallbackComponent:P,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(_e,{transactions:G,onHide:function(){return D(null)},networkId:rt}),z&&r().createElement(Nr,{show:!0,widgetSrc:E,data:z.data,force:z.force,onHide:function(){return $(null)},onCommit:z.onCommit,onCancel:z.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Tr,EthersProviderContext:()=>on,Widget:()=>No,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Er,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>P,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>W,isArray:()=>A,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),P=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var A=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!A(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return A(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Pt(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function At(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Pt(p,t)},p.contract=At(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,$t,zt,Wt,Kt=n.n(Dt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Kt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,accountId:null!==(zt=null!==(Wt=Kt().get(re))&&void 0!==Wt?Wt:Kt().get(ee))&&void 0!==zt?zt:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(ee,o),e.config.walletConnectCallback(o)):Kt().remove(ee),i=null!==(n=Kt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(re,n):Kt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Ht((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}var xe=["node","children"],Se=["node"],ke=["node"],Oe=["node"],je=["node"],Ie=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ce=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Pe(t,xe);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Pe(t,Se);return e?r().createElement("a",Le({onClick:e},n)):r().createElement("a",Le({target:"_blank"},n))},img:function(t){t.node;var e=Pe(t,ke);return r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Pe(t,Oe);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Pe(t,je);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Pe(t,Ie),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Ae=require("react-uuid");var Ne=n.n(Ae);function Te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Je(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function $e(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Je(i,n,o,a,c,"next",t)}function c(t){Je(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ze=x.mul(2e3),We=x.mul(500),Ke=x.mul(500),Xe=x.mul(500),He=function(){var t=$e(De().mark((function t(e,r){var n;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),Ve=function(){var t=$e(De().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ge(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ge(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==qe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===qe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,He(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):We).add(l?u()(0):Xe).add(Ke),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):ze),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ye=function(){var t=$e(De().mark((function t(e,r,n){return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ze=function(){var t=$e(De().mark((function t(e,r,n){var o,i;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Qe=require("react-bootstrap"),tr=require("idb");function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function rr(t,e){if(t){if("string"==typeof t)return nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nr(t,e):void 0}}function nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function ir(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ar(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ir(i,n,o,a,c,"next",t)}function c(t){ir(i,n,o,a,c,"throw",t)}a(void 0)}))}}function cr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,tr.openDB)(e,1,{upgrade:function(t){t.createObjectStore(yr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ar(or().mark((function t(e){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(yr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ar(or().mark((function t(e,r){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(yr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:fr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=dr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===hr||i.status===pr&&i.time+3e5>(new Date).getTime()||(i.status!==fr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===hr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=hr,e&&e().then((function(e){i.status=pr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=pr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===ur&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===sr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||rr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=dr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:ur,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=ar(or().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:sr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function jr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ir(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Lr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Lr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Sr),p=Ir((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",kr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Nr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const _r=require("react-bootstrap-typeahead"),Br=require("styled-components");var Ur=n.n(Br);const Rr=require("elliptic"),Mr=require("bn.js");var Fr=n.n(Mr);const qr=require("tweetnacl"),Gr=require("iframe-resizer-react");var Dr=n.n(Gr);function Jr(){return Jr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rn(t,e,r){return Rn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Mn(o,r.prototype),o},Rn.apply(null,arguments)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Br.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!eo[s.as]&&delete s.as,s.forwardedAs&&!eo[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=$n(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Re.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(qn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Hn(Hn({},s),{},{children:g}));if(u)return(0,Br.isStyledComponent)(u)?r().createElement.apply(r(),[u,Hn({},s)].concat(qn(g))):u(Hn({children:g},s));if("Widget"===o)return r().createElement(No,s);if("CommitButton"===o)return r().createElement(Tr,Fn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Fe(),s,g);if("Tooltip"===o)return r().createElement(Qe.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Qe.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(_r.Typeahead,s);if("Markdown"===o)return r().createElement(Ce,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ue(),Fn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ue(),s,g);if("iframe"===o)return r().createElement(Vr,s);if("Web3Connect"===o)return r().createElement(an,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Hn({},s)].concat(qn(g)));if(!1===i)return r().createElement(o,Hn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return lo(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=oo[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2],r[3])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2],r[3])}if("Social"===t&&"keys"===e){var c;if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return(c=this.vm).cachedSocialKeys.apply(c,qn(r))}if("Social"===t&&"index"===e){var u;if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return(u=this.vm).cachedIndex.apply(u,qn(r))}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe', 'cacheOptions'");var s=$n(r,6),l=s[0],f=s[1],h=s[2],p=s[3],d=s[4],y=s[5];return this.vm.cachedNearView(l,f,h,p,yo(d,p),y)}if("Near"===t&&"asyncView"===e){var v;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(v=this.vm).asyncNearView.apply(v,qn(r))}if("Near"===t&&"block"===e){var m=$n(r,3),g=m[0],b=m[1],w=m[2];return this.vm.cachedNearBlock(g,yo(b,g),w)}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(A(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var E;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(E=r[2])&&void 0!==E?E:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return fo(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var x=JSON.parse(r[0]);return ho(x),x}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return fo(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return fo(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return fo(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return fo(t)}));var S=Object.assign.apply(Object,qn(r));return ho(S),S}if("fromEntries"===e){var k=Object.fromEntries(r[0]);return ho(k),k}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Kn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var O=r[0];this.vm.state.state=O,this.vm.setReactState(O)}return this.vm.state.state}if("State"===t&&"update"===e){var j;if(N(r[0]))this.vm.state.state=null!==(j=this.vm.state.state)&&void 0!==j?j:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var I;this.vm.state.state=null!==(I=this.vm.state.state)&&void 0!==I?I:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:Qn},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:Qn},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:to},r[0],r[1])}if("Storage"===t&&"get"===e){var L;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(L=r[1])&&void 0!==L?L:this.vm.widgetSrc,type:to},r[0])}var P,C,T;if("console"===t&&"log"===e)return(P=console).log.apply(P,[this.vm.widgetSrc].concat(qn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(C=navigator.clipboard).writeText.apply(C,qn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(T=this.vm).vmRequire.apply(T,qn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var B,U=null===(B=this.vm.ethersProviderContext)||void 0===B?void 0:B.setChain;if(!U)throw new Error("The gateway doesn't support `setChain` operation");return U.apply(void 0,qn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var R=Rn(WebSocket,qn(r));return this.vm.websockets.push(R),R}throw new Error("Unsupported WebSocket method")}if(void 0===a){if("fetch"===e){var M;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(M=this.vm).cachedFetch.apply(M,qn(r))}if("asyncFetch"===e){var F;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(F=this.vm).asyncFetch.apply(F,qn(r))}if("useCache"===e){var q;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(q=this.vm).useCache.apply(q,qn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var G=r[0],D=this.hookIndex++,J=this.vm.hooks[D];if(J)return[J.state,J.setState];var $=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[D])||void 0===r?void 0:r.state)),i.vm.setReactHook(D,{state:e,setState:t}),e};return[$(G),$]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var z=r[0];if(!_(z))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var W=this.hookIndex++,K=r[1],X=this.vm.hooks[W];if(X){var H=X.dependencies;if(void 0!==H&&st(H,K))return}var V=null==X?void 0:X.cleanup;return _(V)&&V(),void this.vm.setReactHook(W,{cleanup:z(),dependencies:K})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var Y="useMemo"===e,Z=Y?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(Z,"'. Optional: 'dependencies'"));var Q=r[0];if(!_(Q))throw new Error("Method: ".concat(e,". The first argument '").concat(Z,"' must be a function"));var tt=this.hookIndex++,et=r[1],rt=this.vm.hooks[tt];if(rt){var nt=rt.dependencies;if(void 0!==nt&&st(nt,et))return rt.memoized}var ot=Y?Q():Q;return this.vm.setReactHook(tt,{memoized:ot,dependencies:et}),ot}if("setTimeout"===e){var it=$n(r,2),ct=it[0],ut=it[1],lt=setTimeout((function(){i.vm.alive&&ct()}),ut);return this.vm.timeouts.add(lt),lt}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var ft=$n(r,2),ht=ft[0],pt=ft[1],dt=setInterval((function(){i.vm.alive&&ht()}),pt);return this.vm.intervals.add(dt),dt}if("clearTimeout"===e){var yt=r[0];return this.vm.timeouts.delete(yt),clearTimeout(yt)}if("clearInterval"===e){var vt=r[0];return this.vm.intervals.delete(vt),clearInterval(vt)}}}}else{var mt=e===t?a:a[e];if("function"==typeof mt)return o?Rn(mt,qn(r)):mt.apply(void 0,qn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(lo(n),null!=e&&e.requireState&&n!==Zn)throw new Error("The top object should be ".concat(Zn));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(fo(o),o===this.stack.state&&n in oo){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in oo){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return fo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,qn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Kn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,P=I.key;if("++"===t.operator)return t.prefix?++L[P]:L[P]++;if("--"===t.operator)return t.prefix?--L[P]:L[P]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);fo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,A;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=po(B);if(!(0,Br.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Ur()(null!=U?U:B)}else{if("keyframes"===T)C=Br.keyframes;else{if(!(T in eo))throw new Error("Unsupported styled tag: "+T);C=Ur()(T)}A=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([A].concat(qn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(qn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(bo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);fo(s);var l,f=Un(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(bo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Kn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(vo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Un(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,P=!1,C=Un(I.consequent);try{for(C.s();!(L=C.n()).done;){var A=L.value,N=k.executeStatement(A);if(N){if(N.break){P=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(P)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),xo=function(){function t(e){var r,n=this;Gn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in uo?uo[o]:uo[o]=so.parse(o,co),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Jn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n,o){var i=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(a){return i.cache.socialGet(i.near,t,e,r,n,a,o)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.cachedViewCall(o.near,o.near.config.contractName,"keys",{keys:t,options:r},e,i,n)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedEthersCall(o.ethersProvider,t,e,r,n)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o,i){var a=this;return this.cachedPromise((function(o){return a.cache.cachedViewCall(a.near,t,e,r,n,o,i)}),o)}},{key:"cachedNearBlock",value:function(t,e,r){var n=this;return this.cachedPromise((function(e){return n.cache.cachedBlock(n.near,t,e,r)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.cachedFetch(t,e,o,r)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(i){return o.cache.socialIndex(o.near,t,e,r,i,n)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedCustomPromise({widgetSrc:o.widgetSrc,dataKey:e},t,r,n)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=$n(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Hn(Hn({},io),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=Qr()(Rr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new Eo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const So=require("react-error-boundary");function ko(t){return ko="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ko(t)}var Oo=["loading","src","code","depth","config","props"];function jo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Io(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Oo),p=Po((0,e.useState)(0),2),d=p[0],y=p[1],v=Po((0,e.useState)(null),2),m=v[0],g=v[1],b=Po((0,e.useState)(null),2),E=b[0],x=b[1],S=Po((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=Po((0,e.useState)(0),2),I=j[0],C=j[1],A=Po((0,e.useState)({}),2),B=A[0],U=A[1],R=Po((0,e.useState)(null),2),M=R[0],F=R[1],q=Po((0,e.useState)(null),2),G=q[0],D=q[1],J=Po((0,e.useState)(null),2),$=J[0],z=J[1],W=Po((0,e.useState)(null),2),K=W[0],X=W[1],H=Po((0,e.useState)(null),2),V=H[0],Y=H[1],Z=Po((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(on),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Er(rt),ot=Gt(rt),it=ue(rt),at=Po((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Co(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);st(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=Po(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),z(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new xo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ne()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Io(Io({},h),{},{ref:n})};if(!st(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=ut?r().createElement(So.ErrorBoundary,{FallbackComponent:P,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(_e,{transactions:G,onHide:function(){return D(null)},networkId:rt}),$&&r().createElement(Nr,{show:!0,widgetSrc:E,data:$.data,force:$.force,onHide:function(){return z(null)},onCommit:$.onCommit,onCancel:$.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file From d38745709affbe9184b28c1387d122ae4d2409ba Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Tue, 26 Sep 2023 12:17:07 -0700 Subject: [PATCH 09/25] Expose all VM functions into the state --- CHANGELOG.md | 1 + dist/index.js | 2 +- src/lib/vm/vm.js | 996 ++++++++++++++++++++++++----------------------- 3 files changed, 507 insertions(+), 492 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03a69b23..6ca2f39c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Pending +- Expose all VM functions into the state directly, it's simplifies VM readability and implementation. - Expose certain native objects directly into the state. It should improve access to the functions. - Update the way events and errors are passed to the functions. - For events, expose `preventDefault()` and `stopPropagation()` functions. diff --git a/dist/index.js b/dist/index.js index b4729de1..470da289 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Tr,EthersProviderContext:()=>on,Widget:()=>No,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Er,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>P,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>K,extractKeys:()=>X,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>W,isArray:()=>A,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>H});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),P=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var A=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!A(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return A(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),W=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},K=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},X=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},H=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Pt(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function At(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Pt(p,t)},p.contract=At(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,$t,zt,Wt,Kt=n.n(Dt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Kt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,accountId:null!==(zt=null!==(Wt=Kt().get(re))&&void 0!==Wt?Wt:Kt().get(ee))&&void 0!==zt?zt:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(ee,o),e.config.walletConnectCallback(o)):Kt().remove(ee),i=null!==(n=Kt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(re,n):Kt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Ht((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}var xe=["node","children"],Se=["node"],ke=["node"],Oe=["node"],je=["node"],Ie=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Ce=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Pe(t,xe);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Pe(t,Se);return e?r().createElement("a",Le({onClick:e},n)):r().createElement("a",Le({target:"_blank"},n))},img:function(t){t.node;var e=Pe(t,ke);return r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Pe(t,Oe);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Pe(t,je);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Pe(t,Ie),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Ae=require("react-uuid");var Ne=n.n(Ae);function Te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Je(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function $e(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Je(i,n,o,a,c,"next",t)}function c(t){Je(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ze=x.mul(2e3),We=x.mul(500),Ke=x.mul(500),Xe=x.mul(500),He=function(){var t=$e(De().mark((function t(e,r){var n;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=X(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),Ve=function(){var t=$e(De().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ge(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ge(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==qe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===qe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,He(e,h);case 18:p=t.sent,h=H(h,p);case 20:return d=x.mul(K(h,p)).add(s?u()(0):We).add(l?u()(0):Xe).add(Ke),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):ze),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ye=function(){var t=$e(De().mark((function t(e,r,n){return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ze=function(){var t=$e(De().mark((function t(e,r,n){var o,i;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Qe=require("react-bootstrap"),tr=require("idb");function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function rr(t,e){if(t){if("string"==typeof t)return nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nr(t,e):void 0}}function nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function ir(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ar(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ir(i,n,o,a,c,"next",t)}function c(t){ir(i,n,o,a,c,"throw",t)}a(void 0)}))}}function cr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,tr.openDB)(e,1,{upgrade:function(t){t.createObjectStore(yr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ar(or().mark((function t(e){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(yr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ar(or().mark((function t(e,r){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(yr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:fr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=dr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===hr||i.status===pr&&i.time+3e5>(new Date).getTime()||(i.status!==fr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===hr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=hr,e&&e().then((function(e){i.status=pr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=pr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===ur&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===sr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||rr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=dr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:ur,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=ar(or().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:sr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function jr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ir(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Lr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Lr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Sr),p=Ir((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",kr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Nr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const _r=require("react-bootstrap-typeahead"),Br=require("styled-components");var Ur=n.n(Br);const Rr=require("elliptic"),Mr=require("bn.js");var Fr=n.n(Mr);const qr=require("tweetnacl"),Gr=require("iframe-resizer-react");var Dr=n.n(Gr);function Jr(){return Jr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rn(t,e,r){return Rn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Mn(o,r.prototype),o},Rn.apply(null,arguments)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Br.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!eo[s.as]&&delete s.as,s.forwardedAs&&!eo[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=$n(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Re.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(qn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Hn(Hn({},s),{},{children:g}));if(u)return(0,Br.isStyledComponent)(u)?r().createElement.apply(r(),[u,Hn({},s)].concat(qn(g))):u(Hn({children:g},s));if("Widget"===o)return r().createElement(No,s);if("CommitButton"===o)return r().createElement(Tr,Fn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Fe(),s,g);if("Tooltip"===o)return r().createElement(Qe.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Qe.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(_r.Typeahead,s);if("Markdown"===o)return r().createElement(Ce,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:W(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ue(),Fn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ue(),s,g);if("iframe"===o)return r().createElement(Vr,s);if("Web3Connect"===o)return r().createElement(an,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Hn({},s)].concat(qn(g)));if(!1===i)return r().createElement(o,Hn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return lo(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=oo[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2],r[3])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2],r[3])}if("Social"===t&&"keys"===e){var c;if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return(c=this.vm).cachedSocialKeys.apply(c,qn(r))}if("Social"===t&&"index"===e){var u;if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return(u=this.vm).cachedIndex.apply(u,qn(r))}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe', 'cacheOptions'");var s=$n(r,6),l=s[0],f=s[1],h=s[2],p=s[3],d=s[4],y=s[5];return this.vm.cachedNearView(l,f,h,p,yo(d,p),y)}if("Near"===t&&"asyncView"===e){var v;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(v=this.vm).asyncNearView.apply(v,qn(r))}if("Near"===t&&"block"===e){var m=$n(r,3),g=m[0],b=m[1],w=m[2];return this.vm.cachedNearBlock(g,yo(b,g),w)}if("Near"===t&&"call"===e){if(1===r.length){if(N(r[0]))return this.vm.confirmTransactions([r[0]]);if(A(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var E;if(r.length<2||r.length>5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(E=r[2])&&void 0!==E?E:{},gas:r[3],deposit:r[4]}])}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return fo(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var x=JSON.parse(r[0]);return ho(x),x}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return fo(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return fo(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return fo(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return fo(t)}));var S=Object.assign.apply(Object,qn(r));return ho(S),S}if("fromEntries"===e){var k=Object.fromEntries(r[0]);return ho(k),k}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Kn(r[0])||at(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var O=r[0];this.vm.state.state=O,this.vm.setReactState(O)}return this.vm.state.state}if("State"===t&&"update"===e){var j;if(N(r[0]))this.vm.state.state=null!==(j=this.vm.state.state)&&void 0!==j?j:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var I;this.vm.state.state=null!==(I=this.vm.state.state)&&void 0!==I?I:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:Qn},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:Qn},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:to},r[0],r[1])}if("Storage"===t&&"get"===e){var L;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(L=r[1])&&void 0!==L?L:this.vm.widgetSrc,type:to},r[0])}var P,C,T;if("console"===t&&"log"===e)return(P=console).log.apply(P,[this.vm.widgetSrc].concat(qn(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(C=navigator.clipboard).writeText.apply(C,qn(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(T=this.vm).vmRequire.apply(T,qn(r));if("Ethers"===t){if("provider"===e)return this.vm.ethersProvider;if("setChain"===e){var B,U=null===(B=this.vm.ethersProviderContext)||void 0===B?void 0:B.setChain;if(!U)throw new Error("The gateway doesn't support `setChain` operation");return U.apply(void 0,qn(r))}return this.vm.cachedEthersCall(e,r)}if("WebSocket"===t){if("WebSocket"===e){var R=Rn(WebSocket,qn(r));return this.vm.websockets.push(R),R}throw new Error("Unsupported WebSocket method")}if(void 0===a){if("fetch"===e){var M;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(M=this.vm).cachedFetch.apply(M,qn(r))}if("asyncFetch"===e){var F;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(F=this.vm).asyncFetch.apply(F,qn(r))}if("useCache"===e){var q;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!_(r[0]))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(q=this.vm).useCache.apply(q,qn(r))}if("useState"===e){if(this.prevStack)throw new Error("Method: useState. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useState. Required arguments: 'initialState'");var G=r[0],D=this.hookIndex++,J=this.vm.hooks[D];if(J)return[J.state,J.setState];var $=function t(e){var r;return _(e)&&(e=e(null===(r=i.vm.hooks[D])||void 0===r?void 0:r.state)),i.vm.setReactHook(D,{state:e,setState:t}),e};return[$(G),$]}if("useEffect"===e){if(this.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");if(r.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");var z=r[0];if(!_(z))throw new Error("Method: useEffect. The first argument 'setup' must be a function");var W=this.hookIndex++,K=r[1],X=this.vm.hooks[W];if(X){var H=X.dependencies;if(void 0!==H&&st(H,K))return}var V=null==X?void 0:X.cleanup;return _(V)&&V(),void this.vm.setReactHook(W,{cleanup:z(),dependencies:K})}if("useMemo"===e||"useCallback"===e){if(this.prevStack)throw new Error("Method: ".concat(e,". The hook can only be called from the top of the stack"));if(!this.vm.hooks)throw new Error("Hooks are unavailable for modules");var Y="useMemo"===e,Z=Y?"factory":"callback";if(r.length<1)throw new Error("Method: ".concat(e,". Required arguments: '").concat(Z,"'. Optional: 'dependencies'"));var Q=r[0];if(!_(Q))throw new Error("Method: ".concat(e,". The first argument '").concat(Z,"' must be a function"));var tt=this.hookIndex++,et=r[1],rt=this.vm.hooks[tt];if(rt){var nt=rt.dependencies;if(void 0!==nt&&st(nt,et))return rt.memoized}var ot=Y?Q():Q;return this.vm.setReactHook(tt,{memoized:ot,dependencies:et}),ot}if("setTimeout"===e){var it=$n(r,2),ct=it[0],ut=it[1],lt=setTimeout((function(){i.vm.alive&&ct()}),ut);return this.vm.timeouts.add(lt),lt}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var ft=$n(r,2),ht=ft[0],pt=ft[1],dt=setInterval((function(){i.vm.alive&&ht()}),pt);return this.vm.intervals.add(dt),dt}if("clearTimeout"===e){var yt=r[0];return this.vm.timeouts.delete(yt),clearTimeout(yt)}if("clearInterval"===e){var vt=r[0];return this.vm.intervals.delete(vt),clearInterval(vt)}}}}else{var mt=e===t?a:a[e];if("function"==typeof mt)return o?Rn(mt,qn(r)):mt.apply(void 0,qn(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(lo(n),null!=e&&e.requireState&&n!==Zn)throw new Error("The top object should be ".concat(Zn));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(fo(o),o===this.stack.state&&n in oo){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in oo){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return fo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,qn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Kn(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,P=I.key;if("++"===t.operator)return t.prefix?++L[P]:L[P]++;if("--"===t.operator)return t.prefix?--L[P]:L[P]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);fo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,A;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var N=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=N.key;if("styled"!==N.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=po(B);if(!(0,Br.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Ur()(null!=U?U:B)}else{if("keyframes"===T)C=Br.keyframes;else{if(!(T in eo))throw new Error("Unsupported styled tag: "+T);C=Ur()(T)}A=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),M=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,F=JSON.stringify([A].concat(qn(R)));if(M&&this.vm.cachedStyledComponents.has(F))return this.vm.cachedStyledComponents.get(F);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(qn(q)));return M&&this.vm.cachedStyledComponents.set(F,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(bo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);fo(s);var l,f=Un(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(bo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Kn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(vo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Un(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,P=!1,C=Un(I.consequent);try{for(C.s();!(L=C.n()).done;){var A=L.value,N=k.executeStatement(A);if(N){if(N.break){P=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(P)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),xo=function(){function t(e){var r,n=this;Gn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in uo?uo[o]:uo[o]=so.parse(o,co),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId):this.alive=!1}return Jn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"cachedPromise",value:function(t,e){var r=this;return ct(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n,o){var i=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(a){return i.cache.socialGet(i.near,t,e,r,n,a,o)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.cachedViewCall(o.near,o.near.config.contractName,"keys",{keys:t,options:r},e,i,n)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedEthersCall(o.ethersProvider,t,e,r,n)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o,i){var a=this;return this.cachedPromise((function(o){return a.cache.cachedViewCall(a.near,t,e,r,n,o,i)}),o)}},{key:"cachedNearBlock",value:function(t,e,r){var n=this;return this.cachedPromise((function(e){return n.cache.cachedBlock(n.near,t,e,r)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.cachedFetch(t,e,o,r)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(i){return o.cache.socialIndex(o.near,t,e,r,i,n)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r,n){var o=this;return this.cachedPromise((function(r){return o.cache.cachedCustomPromise({widgetSrc:o.widgetSrc,dataKey:e},t,r,n)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=$n(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:ct(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances.get(r);if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return at(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.reactState,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Hn(Hn({},io),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=Qr()(Rr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new Eo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const So=require("react-error-boundary");function ko(t){return ko="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ko(t)}var Oo=["loading","src","code","depth","config","props"];function jo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Io(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Oo),p=Po((0,e.useState)(0),2),d=p[0],y=p[1],v=Po((0,e.useState)(null),2),m=v[0],g=v[1],b=Po((0,e.useState)(null),2),E=b[0],x=b[1],S=Po((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=Po((0,e.useState)(0),2),I=j[0],C=j[1],A=Po((0,e.useState)({}),2),B=A[0],U=A[1],R=Po((0,e.useState)(null),2),M=R[0],F=R[1],q=Po((0,e.useState)(null),2),G=q[0],D=q[1],J=Po((0,e.useState)(null),2),$=J[0],z=J[1],W=Po((0,e.useState)(null),2),K=W[0],X=W[1],H=Po((0,e.useState)(null),2),V=H[0],Y=H[1],Z=Po((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(on),rt=V&&(null===(o=V.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Er(rt),ot=Gt(rt),it=ue(rt),at=Po((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,V)||Y(t)}),[l,V]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Co(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,V);st(t,Q)||tt(t)}),[a,c,V,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=Po(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),z(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new xo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){C((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ne()(),widgetConfigs:V,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,V,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Io(Io({},h),{},{ref:n})};if(!st(t,K)){X(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,K,n,h]),null!=ut?r().createElement(So.ErrorBoundary,{FallbackComponent:P,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(_e,{transactions:G,onHide:function(){return D(null)},networkId:rt}),$&&r().createElement(Nr,{show:!0,widgetSrc:E,data:$.data,force:$.force,onHide:function(){return z(null)},onCommit:$.onCommit,onCancel:$.onCancel,networkId:rt}))):null!=i?i:L}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Tr,EthersProviderContext:()=>on,Widget:()=>No,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Er,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>A,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>P,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:A(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),A=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function P(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return At.apply(this,arguments)}function At(){return(At=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return Pt.apply(this,arguments)}function Pt(){return(Pt=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,$t,zt,Vt,Wt=n.n(Dt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==($t=Wt().get(re))&&void 0!==$t?$t:void 0,accountId:null!==(zt=null!==(Vt=Wt().get(re))&&void 0!==Vt?Vt:Wt().get(ee))&&void 0!==zt?zt:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(ee,o),e.config.walletConnectCallback(o)):Wt().remove(ee),i=null!==(n=Wt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(re,n):Wt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Xt((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}var xe=["node","children"],Se=["node"],ke=["node"],Oe=["node"],je=["node"],Ie=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Pe=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Le(t,xe);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Le(t,Se);return e?r().createElement("a",Ae({onClick:e},n)):r().createElement("a",Ae({target:"_blank"},n))},img:function(t){t.node;var e=Le(t,ke);return r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Le(t,Oe);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=Le(t,je);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Le(t,Ie),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ye.Prism,Ae({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ce=require("react-uuid");var Ne=n.n(Ce);function Te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Je(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function $e(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Je(i,n,o,a,c,"next",t)}function c(t){Je(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ze=x.mul(2e3),Ve=x.mul(500),We=x.mul(500),Ke=x.mul(500),Xe=function(){var t=$e(De().mark((function t(e,r){var n;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),He=function(){var t=$e(De().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ge(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ge(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==qe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===qe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Xe(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ve).add(l?u()(0):Ke).add(We),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):ze),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ye=function(){var t=$e(De().mark((function t(e,r,n){return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ze=function(){var t=$e(De().mark((function t(e,r,n){var o,i;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Qe=require("react-bootstrap"),tr=require("idb");function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function rr(t,e){if(t){if("string"==typeof t)return nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nr(t,e):void 0}}function nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function ir(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ar(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ir(i,n,o,a,c,"next",t)}function c(t){ir(i,n,o,a,c,"throw",t)}a(void 0)}))}}function cr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,tr.openDB)(e,1,{upgrade:function(t){t.createObjectStore(yr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ar(or().mark((function t(e){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(yr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ar(or().mark((function t(e,r){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(yr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:fr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=dr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===hr||i.status===pr&&i.time+3e5>(new Date).getTime()||(i.status!==fr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===hr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=hr,e&&e().then((function(e){i.status=pr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=pr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===ur&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===sr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||rr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=dr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:ur,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=ar(or().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:sr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function jr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ir(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ar(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ar(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ar(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Sr),p=Ir((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",kr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&A,i),r().createElement(Nr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const _r=require("react-bootstrap-typeahead"),Br=require("styled-components");var Ur=n.n(Br);const Rr=require("elliptic"),Mr=require("bn.js");var Fr=n.n(Mr);const qr=require("tweetnacl"),Gr=require("iframe-resizer-react");var Dr=n.n(Gr);function Jr(){return Jr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rn(t,e,r){return Rn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Mn(o,r.prototype),o},Rn.apply(null,arguments)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Br.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!eo[s.as]&&delete s.as,s.forwardedAs&&!eo[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=$n(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Re.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(qn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Xn(Xn({},s),{},{children:g}));if(u)return(0,Br.isStyledComponent)(u)?r().createElement.apply(r(),[u,Xn({},s)].concat(qn(g))):u(Xn({children:g},s));if("Widget"===o)return r().createElement(No,s);if("CommitButton"===o)return r().createElement(Tr,Fn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Fe(),s,g);if("Tooltip"===o)return r().createElement(Qe.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Qe.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(_r.Typeahead,s);if("Markdown"===o)return r().createElement(Pe,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ue(),Fn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,A," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ue(),s,g);if("iframe"===o)return r().createElement(Hr,s);if("Web3Connect"===o)return r().createElement(an,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Xn({},s)].concat(qn(g)));if(!1===i)return r().createElement(o,Xn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return lo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(lo(n),null!=e&&e.requireState&&n!==Zn)throw new Error("The top object should be ".concat(Zn));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(fo(o),o===this.stack.state&&n in oo){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in oo){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return fo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,qn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Wn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var A=this.resolveMemberExpression(t.argument,{left:!0}),L=A.obj,P=A.key;if("++"===t.operator)return t.prefix?++L[P]:L[P]++;if("--"===t.operator)return t.prefix?--L[P]:L[P]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);fo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=po(U);if(!(0,Br.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Ur()(null!=R?R:U)}else{if("keyframes"===_)C=Br.keyframes;else{if(!(_ in eo))throw new Error("Unsupported styled tag: "+_);C=Ur()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(qn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat(qn(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(bo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);fo(s);var l,f=Un(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(bo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Wn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(vo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Un(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var A,L=!1,P=Un(I.consequent);try{for(P.s();!(A=P.n()).done;){var C=A.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){P.e(t)}finally{P.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),xo=function(){function t(e){var r,n=this;Gn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in uo?uo[o]:uo[o]=so.parse(o,co),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Jn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return fo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return ho(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return fo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return fo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return fo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Xn(Xn(Xn({},io),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=Qr()(Rr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new Eo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const So=require("react-error-boundary");function ko(t){return ko="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ko(t)}var Oo=["loading","src","code","depth","config","props"];function jo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Io(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Oo),p=Lo((0,e.useState)(0),2),d=p[0],y=p[1],v=Lo((0,e.useState)(null),2),m=v[0],g=v[1],b=Lo((0,e.useState)(null),2),E=b[0],x=b[1],S=Lo((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=Lo((0,e.useState)(0),2),I=j[0],P=j[1],C=Lo((0,e.useState)({}),2),B=C[0],U=C[1],R=Lo((0,e.useState)(null),2),M=R[0],F=R[1],q=Lo((0,e.useState)(null),2),G=q[0],D=q[1],J=Lo((0,e.useState)(null),2),$=J[0],z=J[1],V=Lo((0,e.useState)(null),2),W=V[0],K=V[1],X=Lo((0,e.useState)(null),2),H=X[0],Y=X[1],Z=Lo((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(on),rt=H&&(null===(o=H.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Er(rt),ot=Gt(rt),it=ue(rt),at=Lo((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,H)||Y(t)}),[l,H]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Po(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,H);st(t,Q)||tt(t)}),[a,c,H,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=Lo(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),z(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new xo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){P((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ne()(),widgetConfigs:H,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,H,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Io(Io({},h),{},{ref:n})};if(!st(t,W)){K(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,W,n,h]),null!=ut?r().createElement(So.ErrorBoundary,{FallbackComponent:L,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(_e,{transactions:G,onHide:function(){return D(null)},networkId:rt}),$&&r().createElement(Nr,{show:!0,widgetSrc:E,data:$.data,force:$.force,onHide:function(){return z(null)},onCommit:$.onCommit,onCancel:$.onCancel,networkId:rt}))):null!=i?i:A}))})(),o})())); \ No newline at end of file diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index 69b7daec..c27a6af8 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -202,18 +202,7 @@ const ApprovedTags = { }; const Keywords = { - JSON: true, - Social: true, - Storage: true, - Near: true, - State: true, - console: true, styled: true, - Object: true, - clipboard: true, - Ethers: true, - WebSocket: true, - VM: true, }; const GlobalInjected = deepFreeze( @@ -738,476 +727,6 @@ class VmStack { return key; } - callFunction(keyword, callee, args, optional, isNew) { - const keywordType = Keywords[keyword]; - if (keywordType === true || keywordType === undefined) { - if ( - (keyword === "Social" && callee === "getr") || - callee === "socialGetr" - ) { - if (args.length < 1) { - throw new Error("Missing argument 'keys' for Social.getr"); - } - return this.vm.cachedSocialGet( - args[0], - true, - args[1], - args[2], - args[3] - ); - } else if ( - (keyword === "Social" && callee === "get") || - callee === "socialGet" - ) { - if (args.length < 1) { - throw new Error("Missing argument 'keys' for Social.get"); - } - return this.vm.cachedSocialGet( - args[0], - false, - args[1], - args[2], - args[3] - ); - } else if (keyword === "Social" && callee === "keys") { - if (args.length < 1) { - throw new Error("Missing argument 'keys' for Social.keys"); - } - return this.vm.cachedSocialKeys(...args); - } else if (keyword === "Social" && callee === "index") { - if (args.length < 2) { - throw new Error( - "Missing argument 'action' and 'key` for Social.index" - ); - } - return this.vm.cachedIndex(...args); - } else if (keyword === "Social" && callee === "set") { - if (args.length < 1) { - throw new Error("Missing argument 'data' for Social.set"); - } - return this.vm.socialSet(args[0], args[1]); - } else if (keyword === "Near" && callee === "view") { - if (args.length < 2) { - throw new Error( - "Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe', 'cacheOptions'" - ); - } - const [ - contractName, - methodName, - viewArg, - blockId, - subscribe, - cacheOptions, - ] = args; - - return this.vm.cachedNearView( - contractName, - methodName, - viewArg, - blockId, - maybeSubscribe(subscribe, blockId), - cacheOptions - ); - } else if (keyword === "Near" && callee === "asyncView") { - if (args.length < 2) { - throw new Error( - "Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'" - ); - } - return this.vm.asyncNearView(...args); - } else if (keyword === "Near" && callee === "block") { - const [blockId, subscribe, cacheOptions] = args; - return this.vm.cachedNearBlock( - blockId, - maybeSubscribe(subscribe, blockId), - cacheOptions - ); - } else if (keyword === "Near" && callee === "call") { - if (args.length === 1) { - if (isObject(args[0])) { - return this.vm.confirmTransactions([args[0]]); - } else if (isArray(args[0])) { - return this.vm.confirmTransactions(args[0]); - } else { - throw new Error( - "Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects." - ); - } - } else { - if (args.length < 2 || args.length > 5) { - throw new Error( - "Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)" - ); - } - - return this.vm.confirmTransactions([ - { - contractName: args[0], - methodName: args[1], - args: args[2] ?? {}, - gas: args[3], - deposit: args[4], - }, - ]); - } - } else if ( - (keyword === "JSON" && callee === "stringify") || - callee === "stringify" - ) { - if (args.length < 1) { - throw new Error("Missing argument 'obj' for JSON.stringify"); - } - assertNotReactObject(args[0]); - return JSON.stringify(args[0], args[1], args[2]); - } else if (keyword === "JSON" && callee === "parse") { - if (args.length < 1) { - throw new Error("Missing argument 's' for JSON.parse"); - } - try { - const obj = JSON.parse(args[0]); - assertValidObject(obj); - return obj; - } catch (e) { - return null; - } - } else if (keyword === "Object") { - if (callee === "keys") { - if (args.length < 1) { - throw new Error("Missing argument 'obj' for Object.keys"); - } - assertNotReactObject(args[0]); - return Object.keys(args[0]); - } else if (callee === "values") { - if (args.length < 1) { - throw new Error("Missing argument 'obj' for Object.values"); - } - assertNotReactObject(args[0]); - return Object.values(args[0]); - } else if (callee === "entries") { - if (args.length < 1) { - throw new Error("Missing argument 'obj' for Object.entries"); - } - assertNotReactObject(args[0]); - return Object.entries(args[0]); - } else if (callee === "assign") { - args.forEach((arg) => assertNotReactObject(arg)); - const obj = Object.assign(...args); - assertValidObject(obj); - return obj; - } else if (callee === "fromEntries") { - const obj = Object.fromEntries(args[0]); - assertValidObject(obj); - return obj; - } - } else if ( - (keyword === "State" && callee === "init") || - callee === "initState" - ) { - if (args.length < 1) { - throw new Error("Missing argument 'initialState' for State.init"); - } - if ( - args[0] === null || - typeof args[0] !== "object" || - isReactObject(args[0]) - ) { - throw new Error("'initialState' is not an object"); - } - if (this.vm.state.state === undefined) { - const newState = args[0]; - this.vm.state.state = newState; - this.vm.setReactState(newState); - } - return this.vm.state.state; - } else if (keyword === "State" && callee === "update") { - if (isObject(args[0])) { - this.vm.state.state = this.vm.state.state ?? {}; - Object.assign(this.vm.state.state, args[0]); - } else if (args[0] instanceof Function) { - this.vm.state.state = this.vm.state.state ?? {}; - this.vm.state.state = args[0](this.vm.state.state); - } - if (this.vm.state.state === undefined) { - throw new Error("The state was not initialized"); - } - this.vm.setReactState(this.vm.state.state); - return this.vm.state.state; - } else if (keyword === "State" && callee === "get") { - return this.vm.state.state; - } else if (keyword === "Storage" && callee === "privateSet") { - if (args.length < 2) { - throw new Error( - "Missing argument 'key' or 'value' for Storage.privateSet" - ); - } - return this.vm.storageSet( - { - src: this.vm.widgetSrc, - type: StorageType.Private, - }, - args[0], - args[1] - ); - } else if (keyword === "Storage" && callee === "privateGet") { - if (args.length < 1) { - throw new Error("Missing argument 'key' for Storage.privateGet"); - } - return this.vm.storageGet( - { - src: this.vm.widgetSrc, - type: StorageType.Private, - }, - args[0] - ); - } else if (keyword === "Storage" && callee === "set") { - if (args.length < 2) { - throw new Error("Missing argument 'key' or 'value' for Storage.set"); - } - return this.vm.storageSet( - { - src: this.vm.widgetSrc, - type: StorageType.Public, - }, - args[0], - args[1] - ); - } else if (keyword === "Storage" && callee === "get") { - if (args.length < 1) { - throw new Error("Missing argument 'key' for Storage.get"); - } - return this.vm.storageGet( - { - src: args[1] ?? this.vm.widgetSrc, - type: StorageType.Public, - }, - args[0] - ); - } else if (keyword === "console" && callee === "log") { - return console.log(this.vm.widgetSrc, ...args); - } else if (keyword === "clipboard" && callee === "writeText") { - return this.isTrusted - ? navigator.clipboard.writeText(...args) - : Promise.reject(new Error("Not trusted (not a click)")); - } else if (keyword === "VM" && callee === "require") { - return this.vm.vmRequire(...args); - } else if (keyword === "Ethers") { - if (callee === "provider") { - return this.vm.ethersProvider; - } else if (callee === "setChain") { - const f = this.vm.ethersProviderContext?.setChain; - if (!f) { - throw new Error("The gateway doesn't support `setChain` operation"); - } - return f(...args); - } - return this.vm.cachedEthersCall(callee, args); - } else if (keyword === "WebSocket") { - if (callee === "WebSocket") { - const websocket = new WebSocket(...args); - this.vm.websockets.push(websocket); - return websocket; - } else { - throw new Error("Unsupported WebSocket method"); - } - } else if (keywordType === undefined) { - if (callee === "fetch") { - if (args.length < 1) { - throw new Error( - "Method: fetch. Required arguments: 'url'. Optional: 'options'" - ); - } - return this.vm.cachedFetch(...args); - } else if (callee === "asyncFetch") { - if (args.length < 1) { - throw new Error( - "Method: asyncFetch. Required arguments: 'url'. Optional: 'options'" - ); - } - return this.vm.asyncFetch(...args); - } else if (callee === "useCache") { - if (args.length < 2) { - throw new Error( - "Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'" - ); - } - if (!isFunction(args[0])) { - throw new Error( - "Method: useCache. The first argument 'promiseGenerator' must be a function" - ); - } - return this.vm.useCache(...args); - } else if (callee === "useState") { - if (this.prevStack) { - throw new Error( - "Method: useState. The hook can an only be called from the top of the stack" - ); - } - if (!this.vm.hooks) { - throw new Error("Hooks are unavailable for modules"); - } - if (args.length < 1) { - throw new Error( - "Method: useState. Required arguments: 'initialState'" - ); - } - const initialState = args[0]; - const hookIndex = this.hookIndex++; - const hook = this.vm.hooks[hookIndex]; - if (hook) { - return [hook.state, hook.setState]; - } - - const getState = () => this.vm.hooks[hookIndex]?.state; - - const setState = (newState) => { - if (isFunction(newState)) { - newState = newState(getState()); - } - this.vm.setReactHook(hookIndex, { state: newState, setState }); - return newState; - }; - - return [setState(initialState), setState]; - } else if (callee === "useEffect") { - if (this.prevStack) { - throw new Error( - "Method: useEffect. The hook can an only be called from the top of the stack" - ); - } - if (!this.vm.hooks) { - throw new Error("Hooks are unavailable for modules"); - } - if (args.length < 1) { - throw new Error( - "Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'" - ); - } - const setup = args[0]; - if (!isFunction(setup)) { - throw new Error( - "Method: useEffect. The first argument 'setup' must be a function" - ); - } - const hookIndex = this.hookIndex++; - const dependencies = args[1]; - const hook = this.vm.hooks[hookIndex]; - if (hook) { - const oldDependencies = hook.dependencies; - if ( - oldDependencies !== undefined && - deepEqual(oldDependencies, dependencies) - ) { - return undefined; - } - } - const cleanup = hook?.cleanup; - if (isFunction(cleanup)) { - cleanup(); - } - this.vm.setReactHook(hookIndex, { - cleanup: setup(), - dependencies, - }); - - return undefined; - } else if (callee === "useMemo" || callee === "useCallback") { - if (this.prevStack) { - throw new Error( - `Method: ${callee}. The hook can only be called from the top of the stack` - ); - } - if (!this.vm.hooks) { - throw new Error("Hooks are unavailable for modules"); - } - const isMemo = callee === "useMemo"; - const fnArgName = isMemo ? "factory" : "callback"; - if (args.length < 1) { - throw new Error( - `Method: ${callee}. Required arguments: '${fnArgName}'. Optional: 'dependencies'` - ); - } - - const fn = args[0]; - if (!isFunction(fn)) { - throw new Error( - `Method: ${callee}. The first argument '${fnArgName}' must be a function` - ); - } - - const hookIndex = this.hookIndex++; - const dependencies = args[1]; - const hook = this.vm.hooks[hookIndex]; - - if (hook) { - const oldDependencies = hook.dependencies; - if ( - oldDependencies !== undefined && - deepEqual(oldDependencies, dependencies) - ) { - return hook.memoized; - } - } - - const memoized = isMemo ? fn() : fn; - this.vm.setReactHook(hookIndex, { - memoized, - dependencies, - }); - return memoized; - } else if (callee === "setTimeout") { - const [callback, timeout] = args; - const timer = setTimeout(() => { - if (!this.vm.alive) { - return; - } - callback(); - }, timeout); - this.vm.timeouts.add(timer); - return timer; - } else if (callee === "setInterval") { - if (this.vm.intervals.size >= MAX_INTERVALS) { - throw new Error( - `Too many intervals. Max allowed: ${MAX_INTERVALS}` - ); - } - const [callback, timeout] = args; - const timer = setInterval(() => { - if (!this.vm.alive) { - return; - } - callback(); - }, timeout); - this.vm.intervals.add(timer); - return timer; - } else if (callee === "clearTimeout") { - const timer = args[0]; - this.vm.timeouts.delete(timer); - return clearTimeout(timer); - } else if (callee === "clearInterval") { - const timer = args[0]; - this.vm.intervals.delete(timer); - return clearInterval(timer); - } - } - } else { - const f = callee === keyword ? keywordType : keywordType[callee]; - if (typeof f === "function") { - return isNew ? new f(...args) : f(...args); - } - } - - if (optional) { - return undefined; - } - - throw new Error( - keyword && keyword !== callee - ? `Unsupported callee method '${keyword}.${callee}'` - : `Unsupported callee method '${callee}'` - ); - } - /// Resolves the underlying object and the key to modify. /// Should only be used by left hand expressions for assignments. /// Options: @@ -1337,20 +856,15 @@ class VmStack { }); const args = this.getArray(code.arguments); if (!keyword && obj?.[key] instanceof Function) { - return isNew ? new obj[key](...args) : obj[key](...args); - } else if (keyword || obj === this.stack.state || obj === this.vm.state) { - return this.callFunction( - keyword ?? "", - key, - args, - code.optional, - isNew - ); + this.vm.currentVmStack = this; + const result = isNew ? new obj[key](...args) : obj[key](...args); + this.vm.currentVmStack = undefined; + return result; } else { if (code.optional) { return undefined; } - throw new Error("Not a function call expression"); + throw new Error(`"${key}" is not a function`); } } else if (type === "Literal" || type === "JSXText") { return code.value; @@ -1962,6 +1476,8 @@ export default class VM { this.networkId = widgetConfigs.findLast((config) => config && config.networkId) ?.networkId || near.config.networkId; + + this.globalFunctions = this.initGlobalFunctions(); } stop() { @@ -1975,6 +1491,503 @@ export default class VM { this.vmInstances.forEach((vm) => vm.stop()); } + initGlobalFunctions() { + const Social = { + getr: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'keys' for Social.getr"); + } + return this.cachedSocialGet(args[0], true, args[1], args[2], args[3]); + }, + get: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'keys' for Social.get"); + } + return this.cachedSocialGet(args[0], false, args[1], args[2], args[3]); + }, + keys: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'keys' for Social.keys"); + } + return this.cachedSocialKeys(...args); + }, + index: (...args) => { + if (args.length < 2) { + throw new Error( + "Missing argument 'action' and 'key` for Social.index" + ); + } + return this.cachedIndex(...args); + }, + set: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'data' for Social.set"); + } + return this.socialSet(args[0], args[1]); + }, + }; + + const Near = { + view: (...args) => { + if (args.length < 2) { + throw new Error( + "Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe', 'cacheOptions'" + ); + } + const [ + contractName, + methodName, + viewArg, + blockId, + subscribe, + cacheOptions, + ] = args; + + return this.cachedNearView( + contractName, + methodName, + viewArg, + blockId, + maybeSubscribe(subscribe, blockId), + cacheOptions + ); + }, + asyncView: (...args) => { + if (args.length < 2) { + throw new Error( + "Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'" + ); + } + return this.asyncNearView(...args); + }, + block: (...args) => { + const [blockId, subscribe, cacheOptions] = args; + return this.cachedNearBlock( + blockId, + maybeSubscribe(subscribe, blockId), + cacheOptions + ); + }, + call: (...args) => { + if (args.length === 1) { + if (isObject(args[0])) { + return this.confirmTransactions([args[0]]); + } else if (isArray(args[0])) { + return this.confirmTransactions(args[0]); + } else { + throw new Error( + "Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects." + ); + } + } else { + if (args.length < 2 || args.length > 5) { + throw new Error( + "Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)" + ); + } + + return this.confirmTransactions([ + { + contractName: args[0], + methodName: args[1], + args: args[2] ?? {}, + gas: args[3], + deposit: args[4], + }, + ]); + } + }, + }; + + const vmJSON = { + stringify: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'obj' for JSON.stringify"); + } + assertNotReactObject(args[0]); + return JSON.stringify(args[0], args[1], args[2]); + }, + parse: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 's' for JSON.parse"); + } + try { + const obj = JSON.parse(args[0]); + assertValidObject(obj); + return obj; + } catch (e) { + return null; + } + }, + }; + + const vmObject = { + keys: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'obj' for Object.keys"); + } + assertNotReactObject(args[0]); + return Object.keys(args[0]); + }, + values: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'obj' for Object.values"); + } + assertNotReactObject(args[0]); + return Object.values(args[0]); + }, + entries: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'obj' for Object.entries"); + } + assertNotReactObject(args[0]); + return Object.entries(args[0]); + }, + assign: (...args) => { + args.forEach((arg) => assertNotReactObject(arg)); + const obj = Object.assign(...args); + assertValidObject(obj); + return obj; + }, + fromEntries: (...args) => { + const obj = Object.fromEntries(args[0]); + assertValidObject(obj); + return obj; + }, + }; + + const State = { + init: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'initialState' for State.init"); + } + if ( + args[0] === null || + typeof args[0] !== "object" || + isReactObject(args[0]) + ) { + throw new Error("'initialState' is not an object"); + } + if (this.state.state === undefined) { + const newState = args[0]; + this.state.state = newState; + this.setReactState(newState); + } + return this.state.state; + }, + update: (...args) => { + if (isObject(args[0])) { + this.state.state = this.state.state ?? {}; + Object.assign(this.state.state, args[0]); + } else if (args[0] instanceof Function) { + this.state.state = this.state.state ?? {}; + this.state.state = args[0](this.state.state); + } + if (this.state.state === undefined) { + throw new Error("The state was not initialized"); + } + this.setReactState(this.state.state); + return this.state.state; + }, + get: (...args) => { + return this.state.state; + }, + }; + + const Storage = { + privateSet: (...args) => { + if (args.length < 2) { + throw new Error( + "Missing argument 'key' or 'value' for Storage.privateSet" + ); + } + return this.storageSet( + { + src: this.widgetSrc, + type: StorageType.Private, + }, + args[0], + args[1] + ); + }, + privateGet: (...args) => { + if (args.length < 1) { + throw new Error("Missing argument 'key' for Storage.privateGet"); + } + return this.storageGet( + { + src: this.widgetSrc, + type: StorageType.Private, + }, + args[0] + ); + }, + set: (...args) => { + if (args.length < 2) { + throw new Error("Missing argument 'key' or 'value' for Storage.set"); + } + return this.storageSet( + { + src: this.widgetSrc, + type: StorageType.Public, + }, + args[0], + args[1] + ); + }, + get: (...args) => { + if (args.length < 1) { + throw new Error( + "Missing argument 'key' for Storage.get. Optional argument: `widgetSrc`" + ); + } + return this.storageGet( + { + src: args[1] ?? this.widgetSrc, + type: StorageType.Public, + }, + args[0] + ); + }, + }; + + const vmConsole = { + log: (...args) => console.log(this.widgetSrc, ...args), + warn: (...args) => console.warn(this.widgetSrc, ...args), + error: (...args) => console.error(this.widgetSrc, ...args), + info: (...args) => console.info(this.widgetSrc, ...args), + }; + + const Ethers = { + provider: () => this.ethersProvider, + setChain: (...args) => { + const f = this.ethersProviderContext?.setChain; + if (!f) { + throw new Error("The gateway doesn't support `setChain` operation"); + } + return f(...args); + }, + }; + + const vmUseMemoOrCallback = (callee, ...args) => { + if (!this.currentVmStack || this.currentVmStack?.prevStack) { + throw new Error( + `Method: ${callee}. The hook can only be called from the top of the stack` + ); + } + if (!this.hooks) { + throw new Error("Hooks are unavailable for modules"); + } + const isMemo = callee === "useMemo"; + const fnArgName = isMemo ? "factory" : "callback"; + if (args.length < 1) { + throw new Error( + `Method: ${callee}. Required arguments: '${fnArgName}'. Optional: 'dependencies'` + ); + } + + const fn = args[0]; + if (!isFunction(fn)) { + throw new Error( + `Method: ${callee}. The first argument '${fnArgName}' must be a function` + ); + } + + const hookIndex = this.currentVmStack.hookIndex++; + const dependencies = args[1]; + const hook = this.hooks[hookIndex]; + + if (hook) { + const oldDependencies = hook.dependencies; + if ( + oldDependencies !== undefined && + deepEqual(oldDependencies, dependencies) + ) { + return hook.memoized; + } + } + + const memoized = isMemo ? fn() : fn; + this.setReactHook(hookIndex, { + memoized, + dependencies, + }); + return memoized; + }; + + return deepFreeze({ + socialGetr: Social.getr, + socialGet: Social.get, + Social, + Near, + stringify: vmJSON.stringify, + JSON: vmJSON, + Object: vmObject, + initState: State.init, + State, + Storage, + console: vmConsole, + clipboard: { + writeText: (...args) => { + return this.currentVmStack?.isTrusted + ? navigator.clipboard.writeText(...args) + : Promise.reject(new Error("Not trusted (not a click)")); + }, + }, + VM: { + require: this.vmRequire, + }, + Ethers, + WebSocket: (...args) => { + const websocket = new WebSocket(...args); + this.websockets.push(websocket); + return websocket; + }, + fetch: (...args) => { + if (args.length < 1) { + throw new Error( + "Method: fetch. Required arguments: 'url'. Optional: 'options'" + ); + } + return this.cachedFetch(...args); + }, + asyncFetch: (...args) => { + if (args.length < 1) { + throw new Error( + "Method: asyncFetch. Required arguments: 'url'. Optional: 'options'" + ); + } + return this.asyncFetch(...args); + }, + useCache: (...args) => { + if (args.length < 2) { + throw new Error( + "Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'" + ); + } + if (!isFunction(args[0])) { + throw new Error( + "Method: useCache. The first argument 'promiseGenerator' must be a function" + ); + } + return this.useCache(...args); + }, + useState: (...args) => { + if (!this.currentVmStack || this.currentVmStack?.prevStack) { + throw new Error( + "Method: useState. The hook can an only be called from the top of the stack" + ); + } + if (!this.hooks) { + throw new Error("Hooks are unavailable for modules"); + } + if (args.length < 1) { + throw new Error( + "Method: useState. Required arguments: 'initialState'" + ); + } + const initialState = args[0]; + const hookIndex = this.currentVmStack.hookIndex++; + const hook = this.hooks[hookIndex]; + if (hook) { + return [hook.state, hook.setState]; + } + + const getState = () => this.hooks[hookIndex]?.state; + + const setState = (newState) => { + if (isFunction(newState)) { + newState = newState(getState()); + } + this.setReactHook(hookIndex, { state: newState, setState }); + return newState; + }; + + return [setState(initialState), setState]; + }, + useEffect: (...args) => { + if (!this.currentVmStack || this.currentVmStack?.prevStack) { + throw new Error( + "Method: useEffect. The hook can an only be called from the top of the stack" + ); + } + if (!this.hooks) { + throw new Error("Hooks are unavailable for modules"); + } + if (args.length < 1) { + throw new Error( + "Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'" + ); + } + const setup = args[0]; + if (!isFunction(setup)) { + throw new Error( + "Method: useEffect. The first argument 'setup' must be a function" + ); + } + const hookIndex = this.currentVmStack.hookIndex++; + const dependencies = args[1]; + const hook = this.hooks[hookIndex]; + if (hook) { + const oldDependencies = hook.dependencies; + if ( + oldDependencies !== undefined && + deepEqual(oldDependencies, dependencies) + ) { + return undefined; + } + } + const cleanup = hook?.cleanup; + if (isFunction(cleanup)) { + cleanup(); + } + this.setReactHook(hookIndex, { + cleanup: setup(), + dependencies, + }); + + return undefined; + }, + useMemo: (...args) => vmUseMemoOrCallback("useMemo", ...args), + useCallback: (...args) => vmUseMemoOrCallback("useCallback", ...args), + setTimeout: (...args) => { + const [callback, timeout] = args; + const timer = setTimeout(() => { + if (!this.alive) { + return; + } + callback(); + }, timeout); + this.timeouts.add(timer); + return timer; + }, + setInterval: (...args) => { + if (this.intervals.size >= MAX_INTERVALS) { + throw new Error(`Too many intervals. Max allowed: ${MAX_INTERVALS}`); + } + const [callback, timeout] = args; + const timer = setInterval(() => { + if (!this.alive) { + return; + } + callback(); + }, timeout); + this.intervals.add(timer); + return timer; + }, + clearTimeout: (...args) => { + const timer = args[0]; + this.timeouts.delete(timer); + return clearTimeout(timer); + }, + clearInterval: (...args) => { + const timer = args[0]; + this.intervals.delete(timer); + return clearInterval(timer); + }, + }); + } + cachedPromise(promise, subscribe) { const invalidate = { onInvalidate: () => { @@ -2217,6 +2230,7 @@ export default class VM { this.hooks = hooks; this.state = { ...GlobalInjected, + ...this.globalFunctions, props: isObject(props) ? Object.assign({}, props) : props, context, state, From 61bc80c02ccf9e42d1792f913bd868194ae644fe Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Tue, 26 Sep 2023 12:17:30 -0700 Subject: [PATCH 10/25] Typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ca2f39c..6d37924b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Pending -- Expose all VM functions into the state directly, it's simplifies VM readability and implementation. +- Expose all VM functions into the state directly, it simplifies VM readability and implementation. - Expose certain native objects directly into the state. It should improve access to the functions. - Update the way events and errors are passed to the functions. - For events, expose `preventDefault()` and `stopPropagation()` functions. From 30630c4b0f12c909e215d57c75ba30add848de51 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Wed, 4 Oct 2023 20:01:04 -0700 Subject: [PATCH 11/25] Expose onLink and onImage on Markdown --- CHANGELOG.md | 1 + dist/index.js | 2 +- src/lib/components/Markdown.js | 22 ++++++++++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d37924b..63e42720 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Pending +- Add `onLink` and `onImage` to Markdown component. It allows to display links and images differently. - Expose all VM functions into the state directly, it simplifies VM readability and implementation. - Expose certain native objects directly into the state. It should improve access to the functions. - Update the way events and errors are passed to the functions. diff --git a/dist/index.js b/dist/index.js index 470da289..6899bd68 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Tr,EthersProviderContext:()=>on,Widget:()=>No,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Er,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>A,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>P,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:A(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),A=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function P(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return At.apply(this,arguments)}function At(){return(At=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return Pt.apply(this,arguments)}function Pt(){return(Pt=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,$t,zt,Vt,Wt=n.n(Dt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==($t=Wt().get(re))&&void 0!==$t?$t:void 0,accountId:null!==(zt=null!==(Vt=Wt().get(re))&&void 0!==Vt?Vt:Wt().get(ee))&&void 0!==zt?zt:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(ee,o),e.config.walletConnectCallback(o)):Wt().remove(ee),i=null!==(n=Wt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(re,n):Wt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Xt((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}var xe=["node","children"],Se=["node"],ke=["node"],Oe=["node"],je=["node"],Ie=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Pe=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Le(t,xe);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Le(t,Se);return e?r().createElement("a",Ae({onClick:e},n)):r().createElement("a",Ae({target:"_blank"},n))},img:function(t){t.node;var e=Le(t,ke);return r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Le(t,Oe);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=Le(t,je);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Le(t,Ie),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ye.Prism,Ae({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ce=require("react-uuid");var Ne=n.n(Ce);function Te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Je(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function $e(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Je(i,n,o,a,c,"next",t)}function c(t){Je(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ze=x.mul(2e3),Ve=x.mul(500),We=x.mul(500),Ke=x.mul(500),Xe=function(){var t=$e(De().mark((function t(e,r){var n;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),He=function(){var t=$e(De().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ge(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ge(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==qe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===qe(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Xe(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ve).add(l?u()(0):Ke).add(We),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):ze),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Ye=function(){var t=$e(De().mark((function t(e,r,n){return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Ze=function(){var t=$e(De().mark((function t(e,r,n){var o,i;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Qe=require("react-bootstrap"),tr=require("idb");function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function rr(t,e){if(t){if("string"==typeof t)return nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nr(t,e):void 0}}function nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function ir(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ar(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ir(i,n,o,a,c,"next",t)}function c(t){ir(i,n,o,a,c,"throw",t)}a(void 0)}))}}function cr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,tr.openDB)(e,1,{upgrade:function(t){t.createObjectStore(yr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=ar(or().mark((function t(e){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(yr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=ar(or().mark((function t(e,r){return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(yr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:fr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=dr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===hr||i.status===pr&&i.time+3e5>(new Date).getTime()||(i.status!==fr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===hr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=hr,e&&e().then((function(e){i.status=pr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=pr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===ur&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===sr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||rr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=dr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:ur,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=ar(or().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return or().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:sr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function jr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ir(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ar(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ar(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ar(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Sr),p=Ir((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",kr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&A,i),r().createElement(Nr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const _r=require("react-bootstrap-typeahead"),Br=require("styled-components");var Ur=n.n(Br);const Rr=require("elliptic"),Mr=require("bn.js");var Fr=n.n(Mr);const qr=require("tweetnacl"),Gr=require("iframe-resizer-react");var Dr=n.n(Gr);function Jr(){return Jr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rn(t,e,r){return Rn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Mn(o,r.prototype),o},Rn.apply(null,arguments)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Br.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!eo[s.as]&&delete s.as,s.forwardedAs&&!eo[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=$n(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Re.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(qn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Xn(Xn({},s),{},{children:g}));if(u)return(0,Br.isStyledComponent)(u)?r().createElement.apply(r(),[u,Xn({},s)].concat(qn(g))):u(Xn({children:g},s));if("Widget"===o)return r().createElement(No,s);if("CommitButton"===o)return r().createElement(Tr,Fn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Fe(),s,g);if("Tooltip"===o)return r().createElement(Qe.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(Qe.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(_r.Typeahead,s);if("Markdown"===o)return r().createElement(Pe,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ue(),Fn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,A," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ue(),s,g);if("iframe"===o)return r().createElement(Hr,s);if("Web3Connect"===o)return r().createElement(an,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Xn({},s)].concat(qn(g)));if(!1===i)return r().createElement(o,Xn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return lo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(lo(n),null!=e&&e.requireState&&n!==Zn)throw new Error("The top object should be ".concat(Zn));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(fo(o),o===this.stack.state&&n in oo){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in oo){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return fo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,qn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Wn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var A=this.resolveMemberExpression(t.argument,{left:!0}),L=A.obj,P=A.key;if("++"===t.operator)return t.prefix?++L[P]:L[P]++;if("--"===t.operator)return t.prefix?--L[P]:L[P]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);fo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=po(U);if(!(0,Br.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Ur()(null!=R?R:U)}else{if("keyframes"===_)C=Br.keyframes;else{if(!(_ in eo))throw new Error("Unsupported styled tag: "+_);C=Ur()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(qn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat(qn(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(bo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);fo(s);var l,f=Un(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(bo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Wn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(vo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Un(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var A,L=!1,P=Un(I.consequent);try{for(P.s();!(A=P.n()).done;){var C=A.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){P.e(t)}finally{P.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),xo=function(){function t(e){var r,n=this;Gn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in uo?uo[o]:uo[o]=so.parse(o,co),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Jn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return fo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return ho(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return fo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return fo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return fo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Xn(Xn(Xn({},io),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=Qr()(Rr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new Eo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const So=require("react-error-boundary");function ko(t){return ko="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ko(t)}var Oo=["loading","src","code","depth","config","props"];function jo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Io(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Oo),p=Lo((0,e.useState)(0),2),d=p[0],y=p[1],v=Lo((0,e.useState)(null),2),m=v[0],g=v[1],b=Lo((0,e.useState)(null),2),E=b[0],x=b[1],S=Lo((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=Lo((0,e.useState)(0),2),I=j[0],P=j[1],C=Lo((0,e.useState)({}),2),B=C[0],U=C[1],R=Lo((0,e.useState)(null),2),M=R[0],F=R[1],q=Lo((0,e.useState)(null),2),G=q[0],D=q[1],J=Lo((0,e.useState)(null),2),$=J[0],z=J[1],V=Lo((0,e.useState)(null),2),W=V[0],K=V[1],X=Lo((0,e.useState)(null),2),H=X[0],Y=X[1],Z=Lo((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(on),rt=H&&(null===(o=H.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Er(rt),ot=Gt(rt),it=ue(rt),at=Lo((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,H)||Y(t)}),[l,H]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Po(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,H);st(t,Q)||tt(t)}),[a,c,H,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=Lo(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),z(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new xo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){P((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ne()(),widgetConfigs:H,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,H,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Io(Io({},h),{},{ref:n})};if(!st(t,W)){K(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,W,n,h]),null!=ut?r().createElement(So.ErrorBoundary,{FallbackComponent:L,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(_e,{transactions:G,onHide:function(){return D(null)},networkId:rt}),$&&r().createElement(Nr,{show:!0,widgetSrc:E,data:$.data,force:$.force,onHide:function(){return z(null)},onCommit:$.onCommit,onCancel:$.onCancel,networkId:rt}))):null!=i?i:A}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Rr,EthersProviderContext:()=>sn,Widget:()=>Uo,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Or,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Pt.apply(this,arguments)}function Pt(){return(Pt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return At.apply(this,arguments)}function At(){return(At=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,$t,zt,Vt,Wt=n.n(Dt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==($t=Wt().get(re))&&void 0!==$t?$t:void 0,accountId:null!==(zt=null!==(Vt=Wt().get(re))&&void 0!==Vt?Vt:Wt().get(ee))&&void 0!==zt?zt:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(ee,o),e.config.walletConnectCallback(o)):Wt().remove(ee),i=null!==(n=Wt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(re,n):Wt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Xt((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}function xe(t){return xe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xe(t)}var Se=["node","children"],ke=["node"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var _e=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=Te(t,Se);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var o=Te(t,ke);return e?e(Ce({},o)):n?r().createElement("a",Le({onClick:n},o)):r().createElement("a",Le({target:"_blank"},o))},img:function(t){t.node;var e=Te(t,Oe);return c?c(Ce({},e)):r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Te(t,je);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Te(t,Ie);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Te(t,Pe),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Be=require("react-uuid");var Ue=n.n(Be);function Re(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function We(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ke(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){We(i,n,o,a,c,"next",t)}function c(t){We(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Xe=x.mul(2e3),He=x.mul(500),Ye=x.mul(500),Ze=x.mul(500),Qe=function(){var t=Ke(Ve().mark((function t(e,r){var n;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),tr=function(){var t=Ke(Ve().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return ze(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ze(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==$e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==$e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===$e(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Qe(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):He).add(l?u()(0):Ze).add(Ye),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):Xe),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),er=function(){var t=Ke(Ve().mark((function t(e,r,n){return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),rr=function(){var t=Ke(Ve().mark((function t(e,r,n){var o,i;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const nr=require("react-bootstrap"),or=require("idb");function ir(t){return ir="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ir(t)}function ar(t,e){if(t){if("string"==typeof t)return cr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?cr(t,e):void 0}}function cr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function sr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function lr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){sr(i,n,o,a,c,"next",t)}function c(t){sr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function fr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,or.openDB)(e,1,{upgrade:function(t){t.createObjectStore(br)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=lr(ur().mark((function t(e){return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(br,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=lr(ur().mark((function t(e,r){return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(br,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:yr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=gr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===vr||i.status===mr&&i.time+3e5>(new Date).getTime()||(i.status!==yr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===vr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=vr,e&&e().then((function(e){i.status=mr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=mr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===hr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===pr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||ar(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=gr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:hr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=lr(ur().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:pr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ar(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Cr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ir),p=Cr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Pr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Ur,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Mr=require("react-bootstrap-typeahead"),Fr=require("styled-components");var qr=n.n(Fr);const Gr=require("elliptic"),Dr=require("bn.js");var Jr=n.n(Dr);const $r=require("tweetnacl"),zr=require("iframe-resizer-react");var Vr=n.n(zr);function Wr(){return Wr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Dn(o,r.prototype),o},Gn.apply(null,arguments)}function Dn(t,e){return Dn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Dn(t,e)}function Jn(){return Jn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Fr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!io[s.as]&&delete s.as,s.forwardedAs&&!io[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Kn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat($n(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Qn(Qn({},s),{},{children:g}));if(u)return(0,Fr.isStyledComponent)(u)?r().createElement.apply(r(),[u,Qn({},s)].concat($n(g))):u(Qn({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Rr,Jn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Je(),s,g);if("Tooltip"===o)return r().createElement(nr.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(nr.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Mr.Typeahead,s);if("Markdown"===o)return r().createElement(_e,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(qe(),Jn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(qe(),s,g);if("iframe"===o)return r().createElement(tn,s);if("Web3Connect"===o)return r().createElement(ln,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Qn({},s)].concat($n(g)));if(!1===i)return r().createElement(o,Qn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return yo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(yo(n),null!=e&&e.requireState&&n!==ro)throw new Error("The top object should be ".concat(ro));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(vo(o),o===this.stack.state&&n in uo){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in uo){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return vo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,$n(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Yn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);vo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=go(U);if(!(0,Fr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=qr()(null!=R?R:U)}else{if("keyframes"===_)C=Fr.keyframes;else{if(!(_ in io))throw new Error("Unsupported styled tag: "+_);C=qr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat($n(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat($n(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(So),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);vo(s);var l,f=qn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(So(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Yn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(wo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=qn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=qn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),jo=function(){function t(e){var r,n=this;zn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in ho?ho[o]:ho[o]=po.parse(o,fo),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Wn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return vo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return mo(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return vo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return vo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return vo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Qn(Qn(Qn({},so),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=nn()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new Oo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Io=require("react-error-boundary");function Po(t){return Po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Po(t)}var Lo=["loading","src","code","depth","config","props"];function Ao(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Co(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Lo),p=To((0,e.useState)(0),2),d=p[0],y=p[1],v=To((0,e.useState)(null),2),m=v[0],g=v[1],b=To((0,e.useState)(null),2),E=b[0],x=b[1],S=To((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=To((0,e.useState)(0),2),I=j[0],A=j[1],C=To((0,e.useState)({}),2),B=C[0],U=C[1],R=To((0,e.useState)(null),2),M=R[0],F=R[1],q=To((0,e.useState)(null),2),G=q[0],D=q[1],J=To((0,e.useState)(null),2),$=J[0],z=J[1],V=To((0,e.useState)(null),2),W=V[0],K=V[1],X=To((0,e.useState)(null),2),H=X[0],Y=X[1],Z=To((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(sn),rt=H&&(null===(o=H.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Or(rt),ot=Gt(rt),it=ue(rt),at=To((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,H)||Y(t)}),[l,H]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_o(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,H);st(t,Q)||tt(t)}),[a,c,H,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=To(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),z(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new jo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ue()(),widgetConfigs:H,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,H,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Co(Co({},h),{},{ref:n})};if(!st(t,W)){K(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,W,n,h]),null!=ut?r().createElement(Io.ErrorBoundary,{FallbackComponent:L,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(Me,{transactions:G,onHide:function(){return D(null)},networkId:rt}),$&&r().createElement(Ur,{show:!0,widgetSrc:E,data:$.data,force:$.force,onHide:function(){return z(null)},onCommit:$.onCommit,onCancel:$.onCancel,networkId:rt}))):null!=i?i:P}))})(),o})())); \ No newline at end of file diff --git a/src/lib/components/Markdown.js b/src/lib/components/Markdown.js index 9443c9e4..b27e57fa 100644 --- a/src/lib/components/Markdown.js +++ b/src/lib/components/Markdown.js @@ -7,8 +7,15 @@ import mentions from "./remark/mentions"; import hashtags from "./remark/hashtags"; export const Markdown = (props) => { - const { onLinkClick, text, onMention, onHashtag, syntaxHighlighterProps } = - props; + const { + onLink, + onLinkClick, + text, + onMention, + onHashtag, + onImage, + syntaxHighlighterProps, + } = props; return ( { return {children}; }, a: ({ node, ...props }) => - onLinkClick ? ( + onLink ? ( + onLink({ ...props }) + ) : onLinkClick ? ( ) : ( ), - img: ({ node, ...props }) => , + img: ({ node, ...props }) => + onImage ? ( + onImage({ ...props }) + ) : ( + + ), blockquote: ({ node, ...props }) => (
), From 6fe310ce6a17d2a6a20cce328d942f97f4af6a72 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Thu, 5 Oct 2023 09:48:07 -0700 Subject: [PATCH 12/25] Support non-standard href for onLink call --- dist/index.js | 2 +- src/lib/components/Markdown.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6899bd68..890f0126 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Rr,EthersProviderContext:()=>sn,Widget:()=>Uo,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Or,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Pt.apply(this,arguments)}function Pt(){return(Pt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return At.apply(this,arguments)}function At(){return(At=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,$t,zt,Vt,Wt=n.n(Dt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==($t=Wt().get(re))&&void 0!==$t?$t:void 0,accountId:null!==(zt=null!==(Vt=Wt().get(re))&&void 0!==Vt?Vt:Wt().get(ee))&&void 0!==zt?zt:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(ee,o),e.config.walletConnectCallback(o)):Wt().remove(ee),i=null!==(n=Wt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(re,n):Wt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Xt((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}function xe(t){return xe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xe(t)}var Se=["node","children"],ke=["node"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var _e=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=Te(t,Se);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var o=Te(t,ke);return e?e(Ce({},o)):n?r().createElement("a",Le({onClick:n},o)):r().createElement("a",Le({target:"_blank"},o))},img:function(t){t.node;var e=Te(t,Oe);return c?c(Ce({},e)):r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Te(t,je);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Te(t,Ie);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Te(t,Pe),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Be=require("react-uuid");var Ue=n.n(Be);function Re(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function We(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ke(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){We(i,n,o,a,c,"next",t)}function c(t){We(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Xe=x.mul(2e3),He=x.mul(500),Ye=x.mul(500),Ze=x.mul(500),Qe=function(){var t=Ke(Ve().mark((function t(e,r){var n;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),tr=function(){var t=Ke(Ve().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return ze(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ze(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==$e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==$e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===$e(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Qe(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):He).add(l?u()(0):Ze).add(Ye),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):Xe),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),er=function(){var t=Ke(Ve().mark((function t(e,r,n){return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),rr=function(){var t=Ke(Ve().mark((function t(e,r,n){var o,i;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const nr=require("react-bootstrap"),or=require("idb");function ir(t){return ir="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ir(t)}function ar(t,e){if(t){if("string"==typeof t)return cr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?cr(t,e):void 0}}function cr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function sr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function lr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){sr(i,n,o,a,c,"next",t)}function c(t){sr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function fr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,or.openDB)(e,1,{upgrade:function(t){t.createObjectStore(br)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=lr(ur().mark((function t(e){return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(br,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=lr(ur().mark((function t(e,r){return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(br,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:yr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=gr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===vr||i.status===mr&&i.time+3e5>(new Date).getTime()||(i.status!==yr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===vr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=vr,e&&e().then((function(e){i.status=mr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=mr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===hr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===pr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||ar(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=gr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:hr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=lr(ur().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:pr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ar(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Cr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ir),p=Cr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Pr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Ur,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Mr=require("react-bootstrap-typeahead"),Fr=require("styled-components");var qr=n.n(Fr);const Gr=require("elliptic"),Dr=require("bn.js");var Jr=n.n(Dr);const $r=require("tweetnacl"),zr=require("iframe-resizer-react");var Vr=n.n(zr);function Wr(){return Wr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Dn(o,r.prototype),o},Gn.apply(null,arguments)}function Dn(t,e){return Dn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Dn(t,e)}function Jn(){return Jn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Fr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!io[s.as]&&delete s.as,s.forwardedAs&&!io[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Kn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat($n(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Qn(Qn({},s),{},{children:g}));if(u)return(0,Fr.isStyledComponent)(u)?r().createElement.apply(r(),[u,Qn({},s)].concat($n(g))):u(Qn({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Rr,Jn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Je(),s,g);if("Tooltip"===o)return r().createElement(nr.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(nr.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Mr.Typeahead,s);if("Markdown"===o)return r().createElement(_e,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(qe(),Jn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(qe(),s,g);if("iframe"===o)return r().createElement(tn,s);if("Web3Connect"===o)return r().createElement(ln,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Qn({},s)].concat($n(g)));if(!1===i)return r().createElement(o,Qn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return yo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(yo(n),null!=e&&e.requireState&&n!==ro)throw new Error("The top object should be ".concat(ro));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(vo(o),o===this.stack.state&&n in uo){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in uo){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return vo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,$n(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Yn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);vo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=go(U);if(!(0,Fr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=qr()(null!=R?R:U)}else{if("keyframes"===_)C=Fr.keyframes;else{if(!(_ in io))throw new Error("Unsupported styled tag: "+_);C=qr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat($n(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat($n(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(So),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);vo(s);var l,f=qn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(So(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Yn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(wo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=qn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=qn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),jo=function(){function t(e){var r,n=this;zn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in ho?ho[o]:ho[o]=po.parse(o,fo),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Wn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return vo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return mo(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return vo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return vo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return vo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Qn(Qn(Qn({},so),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=nn()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new Oo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Io=require("react-error-boundary");function Po(t){return Po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Po(t)}var Lo=["loading","src","code","depth","config","props"];function Ao(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Co(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Lo),p=To((0,e.useState)(0),2),d=p[0],y=p[1],v=To((0,e.useState)(null),2),m=v[0],g=v[1],b=To((0,e.useState)(null),2),E=b[0],x=b[1],S=To((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=To((0,e.useState)(0),2),I=j[0],A=j[1],C=To((0,e.useState)({}),2),B=C[0],U=C[1],R=To((0,e.useState)(null),2),M=R[0],F=R[1],q=To((0,e.useState)(null),2),G=q[0],D=q[1],J=To((0,e.useState)(null),2),$=J[0],z=J[1],V=To((0,e.useState)(null),2),W=V[0],K=V[1],X=To((0,e.useState)(null),2),H=X[0],Y=X[1],Z=To((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(sn),rt=H&&(null===(o=H.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Or(rt),ot=Gt(rt),it=ue(rt),at=To((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,H)||Y(t)}),[l,H]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_o(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,H);st(t,Q)||tt(t)}),[a,c,H,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=To(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),z(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new jo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ue()(),widgetConfigs:H,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,H,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Co(Co({},h),{},{ref:n})};if(!st(t,W)){K(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,W,n,h]),null!=ut?r().createElement(Io.ErrorBoundary,{FallbackComponent:L,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(Me,{transactions:G,onHide:function(){return D(null)},networkId:rt}),$&&r().createElement(Ur,{show:!0,widgetSrc:E,data:$.data,force:$.force,onHide:function(){return z(null)},onCommit:$.onCommit,onCancel:$.onCancel,networkId:rt}))):null!=i?i:P}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Rr,EthersProviderContext:()=>sn,Widget:()=>Uo,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Or,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Pt.apply(this,arguments)}function Pt(){return(Pt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return At.apply(this,arguments)}function At(){return(At=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,$t,zt,Vt,Wt=n.n(Dt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==($t=Wt().get(re))&&void 0!==$t?$t:void 0,accountId:null!==(zt=null!==(Vt=Wt().get(re))&&void 0!==Vt?Vt:Wt().get(ee))&&void 0!==zt?zt:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(ee,o),e.config.walletConnectCallback(o)):Wt().remove(ee),i=null!==(n=Wt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(re,n):Wt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Xt((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}function xe(t){return xe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xe(t)}var Se=["node","children"],ke=["node"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var _e=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=Te(t,Se);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=Te(t,ke);return e?e(Ce(Ce({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Le({onClick:n},a)):r().createElement("a",Le({target:"_blank"},a))},img:function(t){t.node;var e=Te(t,Oe);return c?c(Ce({},e)):r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Te(t,je);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Te(t,Ie);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Te(t,Pe),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Be=require("react-uuid");var Ue=n.n(Be);function Re(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function We(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ke(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){We(i,n,o,a,c,"next",t)}function c(t){We(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Xe=x.mul(2e3),He=x.mul(500),Ye=x.mul(500),Ze=x.mul(500),Qe=function(){var t=Ke(Ve().mark((function t(e,r){var n;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),tr=function(){var t=Ke(Ve().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return ze(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ze(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==$e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==$e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===$e(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Qe(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):He).add(l?u()(0):Ze).add(Ye),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):Xe),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),er=function(){var t=Ke(Ve().mark((function t(e,r,n){return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),rr=function(){var t=Ke(Ve().mark((function t(e,r,n){var o,i;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const nr=require("react-bootstrap"),or=require("idb");function ir(t){return ir="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ir(t)}function ar(t,e){if(t){if("string"==typeof t)return cr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?cr(t,e):void 0}}function cr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function sr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function lr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){sr(i,n,o,a,c,"next",t)}function c(t){sr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function fr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,or.openDB)(e,1,{upgrade:function(t){t.createObjectStore(br)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=lr(ur().mark((function t(e){return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(br,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=lr(ur().mark((function t(e,r){return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(br,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:yr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=gr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===vr||i.status===mr&&i.time+3e5>(new Date).getTime()||(i.status!==yr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===vr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=vr,e&&e().then((function(e){i.status=mr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=mr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===hr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===pr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||ar(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=gr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:hr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=lr(ur().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:pr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ar(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Cr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ir),p=Cr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Pr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Ur,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Mr=require("react-bootstrap-typeahead"),Fr=require("styled-components");var qr=n.n(Fr);const Gr=require("elliptic"),Dr=require("bn.js");var Jr=n.n(Dr);const $r=require("tweetnacl"),zr=require("iframe-resizer-react");var Vr=n.n(zr);function Wr(){return Wr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Dn(o,r.prototype),o},Gn.apply(null,arguments)}function Dn(t,e){return Dn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Dn(t,e)}function Jn(){return Jn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Fr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!io[s.as]&&delete s.as,s.forwardedAs&&!io[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Kn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat($n(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Qn(Qn({},s),{},{children:g}));if(u)return(0,Fr.isStyledComponent)(u)?r().createElement.apply(r(),[u,Qn({},s)].concat($n(g))):u(Qn({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Rr,Jn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Je(),s,g);if("Tooltip"===o)return r().createElement(nr.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(nr.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Mr.Typeahead,s);if("Markdown"===o)return r().createElement(_e,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(qe(),Jn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(qe(),s,g);if("iframe"===o)return r().createElement(tn,s);if("Web3Connect"===o)return r().createElement(ln,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Qn({},s)].concat($n(g)));if(!1===i)return r().createElement(o,Qn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return yo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(yo(n),null!=e&&e.requireState&&n!==ro)throw new Error("The top object should be ".concat(ro));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(vo(o),o===this.stack.state&&n in uo){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in uo){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return vo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,$n(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Yn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);vo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=go(U);if(!(0,Fr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=qr()(null!=R?R:U)}else{if("keyframes"===_)C=Fr.keyframes;else{if(!(_ in io))throw new Error("Unsupported styled tag: "+_);C=qr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat($n(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat($n(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(So),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);vo(s);var l,f=qn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(So(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Yn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(wo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=qn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=qn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),jo=function(){function t(e){var r,n=this;zn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in ho?ho[o]:ho[o]=po.parse(o,fo),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Wn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return vo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return mo(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return vo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return vo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return vo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Qn(Qn(Qn({},so),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=nn()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new Oo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Io=require("react-error-boundary");function Po(t){return Po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Po(t)}var Lo=["loading","src","code","depth","config","props"];function Ao(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Co(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Lo),p=To((0,e.useState)(0),2),d=p[0],y=p[1],v=To((0,e.useState)(null),2),m=v[0],g=v[1],b=To((0,e.useState)(null),2),E=b[0],x=b[1],S=To((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=To((0,e.useState)(0),2),I=j[0],A=j[1],C=To((0,e.useState)({}),2),B=C[0],U=C[1],R=To((0,e.useState)(null),2),M=R[0],F=R[1],q=To((0,e.useState)(null),2),G=q[0],D=q[1],J=To((0,e.useState)(null),2),$=J[0],z=J[1],V=To((0,e.useState)(null),2),W=V[0],K=V[1],X=To((0,e.useState)(null),2),H=X[0],Y=X[1],Z=To((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(sn),rt=H&&(null===(o=H.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Or(rt),ot=Gt(rt),it=ue(rt),at=To((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,H)||Y(t)}),[l,H]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_o(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,H);st(t,Q)||tt(t)}),[a,c,H,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=To(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),z(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new jo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ue()(),widgetConfigs:H,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,H,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Co(Co({},h),{},{ref:n})};if(!st(t,W)){K(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,W,n,h]),null!=ut?r().createElement(Io.ErrorBoundary,{FallbackComponent:L,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(Me,{transactions:G,onHide:function(){return D(null)},networkId:rt}),$&&r().createElement(Ur,{show:!0,widgetSrc:E,data:$.data,force:$.force,onHide:function(){return z(null)},onCommit:$.onCommit,onCancel:$.onCancel,networkId:rt}))):null!=i?i:P}))})(),o})())); \ No newline at end of file diff --git a/src/lib/components/Markdown.js b/src/lib/components/Markdown.js index b27e57fa..9eed095f 100644 --- a/src/lib/components/Markdown.js +++ b/src/lib/components/Markdown.js @@ -33,7 +33,7 @@ export const Markdown = (props) => { }, a: ({ node, ...props }) => onLink ? ( - onLink({ ...props }) + onLink({ ...props, href: node.properties?.href }) ) : onLinkClick ? ( ) : ( From 3d65d9870c3ffbaf57701a70b7cb54484bd0392c Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Sat, 7 Oct 2023 02:19:23 -0400 Subject: [PATCH 13/25] feature: adds redirect map support for VM.require updates CHANGELOG and increments to 2.4.3 fix: allow code chore: rebases to dev, fixes comments, adds to change log update build --- CHANGELOG.md | 1 + dist/index.js | 2 +- src/lib/components/Widget.js | 22 +--------------------- src/lib/data/utils.js | 21 +++++++++++++++++++++ src/lib/vm/vm.js | 28 ++++++++++++++++++---------- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63e42720..a2bd1cc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - For errors, expose `message`, `name` and `type`. - Fix `vm.depth` not being initialized. - Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes. +- Add support for VM.require when using redirectMap. ```jsx const data = [ diff --git a/dist/index.js b/dist/index.js index 890f0126..aaf2eef5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Rr,EthersProviderContext:()=>sn,Widget:()=>Uo,useAccount:()=>ce,useAccountId:()=>ue,useCache:()=>Or,useInitNear:()=>Mt,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=n(764).lW;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function pt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function gt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function bt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){gt(i,n,o,a,c,"next",t)}function c(t){gt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var wt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},Et={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},xt={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},St={get:!0,keys:!0},kt=function(){var t=bt(mt().mark((function t(e,r,n,o,i){return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in St){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ot(t,e,r,n,o,i){return jt.apply(this,arguments)}function jt(){return(jt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[wt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function It(t,e){return Pt.apply(this,arguments)}function Pt(){return(Pt=bt(mt().mark((function t(e,r){var n;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){return At.apply(this,arguments)}function At(){return(At=bt(mt().mark((function t(e,r){var n,o,i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=wt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Ct(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Nt(t,e,r,n,o,i){return Tt.apply(this,arguments)}function Tt(){return(Tt=bt(mt().mark((function t(e,r,n,o,i,a){var c;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:lt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(lt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e,r,n){return Bt.apply(this,arguments)}function Bt(){return(Bt=bt(mt().mark((function t(e,r,n,o){var i;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=yt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ut(t){return Rt.apply(this,arguments)}function Rt(){return(Rt=bt(mt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},xt,o):"testnet"===o.networkId&&(o=Object.assign({},Et,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Nt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?_t(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():kt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return Ot(p,t,e,r,n,o)},p.sendTransactions=function(t){return Lt(p,t)},p.contract=Ct(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return It(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Mt=(0,i.singletonHook)({},(function(){var t=yt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:pt(pt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:pt(pt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ut)).then((function(t){return t.map((function(t){return pt(pt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Ft=[],qt=(0,i.singletonHook)(Ft,(function(){var t=yt((0,e.useState)(Ft),2),r=t[0],n=t[1],o=Mt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return qt()[t||"default"]||null};const Dt=require("local-storage");var Jt,$t,zt,Vt,Wt=n.n(Dt);function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var te="near-social-vm:v01:",ee=te+":accountId:",re=te+":pretendAccountId:",ne={loading:!0,signedAccountId:null!==(Jt=Wt().get(ee))&&void 0!==Jt?Jt:void 0,pretendAccountId:null!==($t=Wt().get(re))&&void 0!==$t?$t:void 0,accountId:null!==(zt=null!==(Vt=Wt().get(re))&&void 0!==Vt?Vt:Wt().get(ee))&&void 0!==zt?zt:void 0,state:null,near:null};function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Qt(Yt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Wt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Wt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ae=function(){var t=Qt(Yt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Wt().set(ee,o),e.config.walletConnectCallback(o)):Wt().remove(ee),i=null!==(n=Wt().get(re))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=Qt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=Qt(Yt().mark((function t(n){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Wt().set(re,n):Wt().remove(re),t.next=3,ae(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Xt(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ce=(0,i.singletonHook)(ne,(function(){var t=Xt((0,e.useState)(ne),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=Qt(Yt().mark((function t(e){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,oe(o,e);case 2:return t.prev=2,t.next=5,ae(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),ue=function(t){var e=Gt(),r=ce();if(e&&(!t||e.config.networkId===t))return r.accountId};const se=require("react-bootstrap/Modal");var le=n.n(se);const fe=require("remark-gfm");var he=n.n(fe);const pe=require("react-markdown");var de=n.n(pe);const ye=require("react-syntax-highlighter"),ve=require("react-syntax-highlighter/dist/esm/styles/prism"),me=require("mdast-util-find-and-replace");var ge=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function be(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,me.findAndReplace)(e,ge,t),e}}var we=/#(\w+)/gi;function Ee(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,me.findAndReplace)(e,we,t),e}}function xe(t){return xe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xe(t)}var Se=["node","children"],ke=["node"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node","inline","className","children"];function Le(){return Le=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var _e=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(de(),{plugins:[],rehypePlugins:[],remarkPlugins:[he(),be,Ee],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=Te(t,Se);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=Te(t,ke);return e?e(Ce(Ce({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Le({onClick:n},a)):r().createElement("a",Le({target:"_blank"},a))},img:function(t){t.node;var e=Te(t,Oe);return c?c(Ce({},e)):r().createElement("img",Le({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Te(t,je);return r().createElement("blockquote",Le({className:"blockquote"},e))},table:function(t){t.node;var e=Te(t,Ie);return r().createElement("table",Le({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Te(t,Pe),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ye.Prism,Le({children:String(o).replace(/\n$/,""),style:ve.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Le({className:n},i),o)}}})};const Be=require("react-uuid");var Ue=n.n(Be);function Re(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function We(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Ke(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){We(i,n,o,a,c,"next",t)}function c(t){We(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Xe=x.mul(2e3),He=x.mul(500),Ye=x.mul(500),Ze=x.mul(500),Qe=function(){var t=Ke(Ve().mark((function t(e,r){var n;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),tr=function(){var t=Ke(Ve().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return ze(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ze(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==$e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==$e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===$e(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Qe(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):He).add(l?u()(0):Ze).add(Ye),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):Xe),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),er=function(){var t=Ke(Ve().mark((function t(e,r,n){return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),rr=function(){var t=Ke(Ve().mark((function t(e,r,n){var o,i;return Ve().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(wt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(wt("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const nr=require("react-bootstrap"),or=require("idb");function ir(t){return ir="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ir(t)}function ar(t,e){if(t){if("string"==typeof t)return cr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?cr(t,e):void 0}}function cr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function sr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function lr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){sr(i,n,o,a,c,"next",t)}function c(t){sr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function fr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,or.openDB)(e,1,{upgrade:function(t){t.createObjectStore(br)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=lr(ur().mark((function t(e){return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(br,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=lr(ur().mark((function t(e,r){return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(br,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:yr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=gr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===vr||i.status===mr&&i.time+3e5>(new Date).getTime()||(i.status!==yr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===vr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=vr,e&&e().then((function(e){i.status=mr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=mr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===hr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===pr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||ar(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=gr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:hr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=lr(ur().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return ur().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:pr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ar(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Cr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Nr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ir),p=Cr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Pr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Ur,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Mr=require("react-bootstrap-typeahead"),Fr=require("styled-components");var qr=n.n(Fr);const Gr=require("elliptic"),Dr=require("bn.js");var Jr=n.n(Dr);const $r=require("tweetnacl"),zr=require("iframe-resizer-react");var Vr=n.n(zr);function Wr(){return Wr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Dn(o,r.prototype),o},Gn.apply(null,arguments)}function Dn(t,e){return Dn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Dn(t,e)}function Jn(){return Jn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,Fr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!io[s.as]&&delete s.as,s.forwardedAs&&!io[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Kn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat($n(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Qn(Qn({},s),{},{children:g}));if(u)return(0,Fr.isStyledComponent)(u)?r().createElement.apply(r(),[u,Qn({},s)].concat($n(g))):u(Qn({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Rr,Jn({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Je(),s,g);if("Tooltip"===o)return r().createElement(nr.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(nr.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Mr.Typeahead,s);if("Markdown"===o)return r().createElement(_e,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(qe(),Jn({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(qe(),s,g);if("iframe"===o)return r().createElement(tn,s);if("Web3Connect"===o)return r().createElement(ln,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Qn({},s)].concat($n(g)));if(!1===i)return r().createElement(o,Qn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return yo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(yo(n),null!=e&&e.requireState&&n!==ro)throw new Error("The top object should be ".concat(ro));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(vo(o),o===this.stack.state&&n in uo){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in uo){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return vo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,$n(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Yn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);vo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=go(U);if(!(0,Fr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=qr()(null!=R?R:U)}else{if("keyframes"===_)C=Fr.keyframes;else{if(!(_ in io))throw new Error("Unsupported styled tag: "+_);C=qr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat($n(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat($n(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(So),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);vo(s);var l,f=qn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(So(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Yn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(wo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=qn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=qn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),jo=function(){function t(e){var r,n=this;zn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in ho?ho[o]:ho[o]=po.parse(o,fo),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Wn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return vo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return mo(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return vo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return vo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return vo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=Qn(Qn(Qn({},so),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=nn()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new Oo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Io=require("react-error-boundary");function Po(t){return Po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Po(t)}var Lo=["loading","src","code","depth","config","props"];function Ao(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Co(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Lo),p=To((0,e.useState)(0),2),d=p[0],y=p[1],v=To((0,e.useState)(null),2),m=v[0],g=v[1],b=To((0,e.useState)(null),2),E=b[0],x=b[1],S=To((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=To((0,e.useState)(0),2),I=j[0],A=j[1],C=To((0,e.useState)({}),2),B=C[0],U=C[1],R=To((0,e.useState)(null),2),M=R[0],F=R[1],q=To((0,e.useState)(null),2),G=q[0],D=q[1],J=To((0,e.useState)(null),2),$=J[0],z=J[1],V=To((0,e.useState)(null),2),W=V[0],K=V[1],X=To((0,e.useState)(null),2),H=X[0],Y=X[1],Z=To((0,e.useState)(null),2),Q=Z[0],tt=Z[1],et=(0,e.useContext)(sn),rt=H&&(null===(o=H.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),nt=Or(rt),ot=Gt(rt),it=ue(rt),at=To((0,e.useState)(null),2),ut=at[0],lt=at[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,H)||Y(t)}),[l,H]),(0,e.useEffect)((function(){var t=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_o(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(a,c,H);st(t,Q)||tt(t)}),[a,c,H,Q]),(0,e.useEffect)((function(){if(ot)if(null!=Q&&Q.src){var t=Q.src,e=To(t.split("@"),2),r=e[0],n=e[1],o=nt.socialGet(ot,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=Q&&Q.code&&(g(Q.code),x(null))}),[ot,Q,d]),(0,e.useEffect)((function(){F(null),lt(null),m||void 0===m&<(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var ft=(0,e.useCallback)((function(t){if(!ot||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),D(t)}),[ot]),ht=(0,e.useCallback)((function(t){if(!ot)return null;console.log("commit requested",t),z(t)}),[ot]);return(0,e.useEffect)((function(){if(ot&&m){O({hooks:[],state:void 0});var t=new jo({near:ot,rawCode:m,setReactState:O,cache:nt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:ft,depth:s,widgetSrc:E,requestCommit:ht,version:Ue()(),widgetConfigs:H,ethersProviderContext:et});return F(t),function(){t.stop()}}}),[E,ot,m,s,ht,ft,H,et]),(0,e.useEffect)((function(){ot&&U({loading:!1,accountId:null!=it?it:null,widgetSrc:E,networkId:ot.config.networkId})}),[ot,it,E]),(0,e.useLayoutEffect)((function(){if(M){var t={props:f||{},context:B,reactState:k,cacheNonce:I,version:M.version,forwardedProps:Co(Co({},h),{},{ref:n})};if(!st(t,W)){K(ct(t));try{var e;lt(null!==(e=M.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){lt(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[M,f,B,k,I,W,n,h]),null!=ut?r().createElement(Io.ErrorBoundary,{FallbackComponent:L,onReset:function(){lt(null)},resetKeys:[ut]},r().createElement(r().Fragment,null,ut,G&&r().createElement(Me,{transactions:G,onHide:function(){return D(null)},networkId:rt}),$&&r().createElement(Ur,{show:!0,widgetSrc:E,data:$.data,force:$.force,onHide:function(){return z(null)},onCommit:$.onCommit,onCancel:$.onCancel,networkId:rt}))):null!=i?i:P}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Dt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return jt(p,t,e,r,n,o)},p.sendTransactions=function(t){return At(p,t)},p.contract=Nt(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return Pt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Gt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Dt=function(t){return Gt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Dt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Dt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Gr=n.n(qr);const Dr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Dn(t,e,r){return Dn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Dn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,qr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!ao[s.as]&&delete s.as,s.forwardedAs&&!ao[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,De.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(to(to({},s),{},{children:g}));if(u)return(0,qr.isStyledComponent)(u)?r().createElement.apply(r(),[u,to({},s)].concat(zn(g))):u(to({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Mr,$n({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement($e(),s,g);if("Tooltip"===o)return r().createElement(or.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(or.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Fr.Typeahead,s);if("Markdown"===o)return r().createElement(Be,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ge(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ge(),s,g);if("iframe"===o)return r().createElement(en,s);if("Web3Connect"===o)return r().createElement(fn,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,to({},s)].concat(zn(g)));if(!1===i)return r().createElement(o,to({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Gr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Gr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat(zn(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Gn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Gn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Gn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Dr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),G=q[0],D=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Dt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),D(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),G&&r().createElement(Rr,{show:!0,widgetSrc:E,data:G.data,force:G.force,onHide:function(){return D(null)},onCommit:G.onCommit,onCancel:G.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file diff --git a/src/lib/components/Widget.js b/src/lib/components/Widget.js index 8e3f0793..653f6702 100644 --- a/src/lib/components/Widget.js +++ b/src/lib/components/Widget.js @@ -17,6 +17,7 @@ import { isFunction, Loading, TGas, + computeSrcOrCode, } from "../data/utils"; import { ErrorBoundary } from "react-error-boundary"; import { useCache } from "../data/cache"; @@ -26,27 +27,6 @@ import Big from "big.js"; import uuid from "react-uuid"; import { EthersProviderContext } from "./ethers"; -const computeSrcOrCode = (src, code, configs) => { - let srcOrCode = src ? { src } : code ? { code } : null; - for (const config of configs || []) { - if (srcOrCode?.src) { - const src = srcOrCode.src; - let value = isObject(config?.redirectMap) && config.redirectMap[src]; - if (!value) { - try { - value = isFunction(config?.redirect) && config.redirect(src); - } catch {} - } - if (isString(value)) { - srcOrCode = { src: value }; - } else if (isString(value?.code)) { - return { code: value.code }; - } - } - } - return srcOrCode; -}; - export const Widget = React.forwardRef((props, forwardedRef) => { const { loading, diff --git a/src/lib/data/utils.js b/src/lib/data/utils.js index 25b44db1..8d1a12b8 100644 --- a/src/lib/data/utils.js +++ b/src/lib/data/utils.js @@ -404,3 +404,24 @@ export const filterValues = (o) => { }; export const deepEqual = equal; + +export const computeSrcOrCode = (src, code, configs) => { + let srcOrCode = src ? { src } : code ? { code } : null; + for (const config of configs || []) { + if (srcOrCode?.src) { + const src = srcOrCode.src; + let value = isObject(config?.redirectMap) && config.redirectMap[src]; + if (!value) { + try { + value = isFunction(config?.redirect) && config.redirect(src); + } catch {} + } + if (isString(value)) { + srcOrCode = { src: value }; + } else if (isString(value?.code)) { + return { code: value.code }; + } + } + } + return srcOrCode; +}; diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index c27a6af8..caf8f182 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -1,6 +1,7 @@ import React from "react"; import { Widget } from "../components/Widget"; import { + computeSrcOrCode, deepCopy, deepEqual, deepFreeze, @@ -2149,17 +2150,24 @@ export default class VM { } vmRequire(src) { - const [srcPath, version] = src.split("@"); - const code = this.cachedSocialGet( - srcPath.toString(), - false, - version, // may be undefined, meaning `latest` - undefined - ); - if (!code) { - return code; + const srcOrCode = computeSrcOrCode(src, null, this.widgetConfigs); + let code; + if (srcOrCode?.src) { + const src = srcOrCode.src; + const [srcPath, version] = src.split("@"); + code = this.cachedSocialGet( + srcPath.toString(), + false, + version, // may be undefined, meaning `latest` + undefined + ); + if (!code) { + return code; + } + } else if (srcOrCode?.code) { + code = srcOrCode.code; } - const vm = this.getVmInstance(code, src); + const vm = this.getVmInstance(code, srcOrCode?.src); return vm.execCode({ context: deepCopy(this.context), forwardedProps: this.forwardedProps, From cfe0f1c8e2fc4b79e734eae1a2345cd8aac3eee7 Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Sat, 7 Oct 2023 15:33:21 -0400 Subject: [PATCH 14/25] fix: bind this to VM.require fix: changelog order --- CHANGELOG.md | 3 ++- dist/index.js | 2 +- src/lib/vm/vm.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2bd1cc9..4ab3a26c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Pending +- Add support for VM.require when using redirectMap. +- Fixes an issue with VM.require not retaining context in migration to initGlobalFunctions. - Add `onLink` and `onImage` to Markdown component. It allows to display links and images differently. - Expose all VM functions into the state directly, it simplifies VM readability and implementation. - Expose certain native objects directly into the state. It should improve access to the functions. @@ -11,7 +13,6 @@ - For errors, expose `message`, `name` and `type`. - Fix `vm.depth` not being initialized. - Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes. -- Add support for VM.require when using redirectMap. ```jsx const data = [ diff --git a/dist/index.js b/dist/index.js index aaf2eef5..0ef2bd39 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Dt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return jt(p,t,e,r,n,o)},p.sendTransactions=function(t){return At(p,t)},p.contract=Nt(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return Pt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Gt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Dt=function(t){return Gt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Dt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Dt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Gr=n.n(qr);const Dr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Dn(t,e,r){return Dn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Dn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,qr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!ao[s.as]&&delete s.as,s.forwardedAs&&!ao[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,De.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(to(to({},s),{},{children:g}));if(u)return(0,qr.isStyledComponent)(u)?r().createElement.apply(r(),[u,to({},s)].concat(zn(g))):u(to({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Mr,$n({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement($e(),s,g);if("Tooltip"===o)return r().createElement(or.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(or.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Fr.Typeahead,s);if("Markdown"===o)return r().createElement(Be,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ge(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ge(),s,g);if("iframe"===o)return r().createElement(en,s);if("Web3Connect"===o)return r().createElement(fn,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,to({},s)].concat(zn(g)));if(!1===i)return r().createElement(o,to({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Gr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Gr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat(zn(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Gn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Gn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Gn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Dr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),G=q[0],D=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Dt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),D(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),G&&r().createElement(Rr,{show:!0,widgetSrc:E,data:G.data,force:G.force,onHide:function(){return D(null)},onCommit:G.onCommit,onCancel:G.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Dt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return jt(p,t,e,r,n,o)},p.sendTransactions=function(t){return At(p,t)},p.contract=Nt(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return Pt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Gt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Dt=function(t){return Gt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Dt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Dt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Gr=n.n(qr);const Dr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Dn(t,e,r){return Dn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Dn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,qr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!ao[s.as]&&delete s.as,s.forwardedAs&&!ao[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,De.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(to(to({},s),{},{children:g}));if(u)return(0,qr.isStyledComponent)(u)?r().createElement.apply(r(),[u,to({},s)].concat(zn(g))):u(to({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Mr,$n({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement($e(),s,g);if("Tooltip"===o)return r().createElement(or.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(or.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Fr.Typeahead,s);if("Markdown"===o)return r().createElement(Be,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ge(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ge(),s,g);if("iframe"===o)return r().createElement(en,s);if("Web3Connect"===o)return r().createElement(fn,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,to({},s)].concat(zn(g)));if(!1===i)return r().createElement(o,to({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Gr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Gr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat(zn(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Gn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Gn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Gn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Dr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),G=q[0],D=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Dt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),D(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),G&&r().createElement(Rr,{show:!0,widgetSrc:E,data:G.data,force:G.force,onHide:function(){return D(null)},onCommit:G.onCommit,onCancel:G.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index caf8f182..86a15090 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -1836,7 +1836,7 @@ export default class VM { }, }, VM: { - require: this.vmRequire, + require: this.vmRequire.bind(this), }, Ethers, WebSocket: (...args) => { From d8022ce301fb81df42a480c43f155d82d59326a9 Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Mon, 9 Oct 2023 12:38:34 -0400 Subject: [PATCH 15/25] fix: switches src and code for getVmInstance --- dist/index.js | 2 +- src/lib/vm/vm.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0ef2bd39..86fb1bea 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Dt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return jt(p,t,e,r,n,o)},p.sendTransactions=function(t){return At(p,t)},p.contract=Nt(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return Pt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Gt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Dt=function(t){return Gt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Dt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Dt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Gr=n.n(qr);const Dr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Dn(t,e,r){return Dn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Dn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,qr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!ao[s.as]&&delete s.as,s.forwardedAs&&!ao[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,De.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(to(to({},s),{},{children:g}));if(u)return(0,qr.isStyledComponent)(u)?r().createElement.apply(r(),[u,to({},s)].concat(zn(g))):u(to({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Mr,$n({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement($e(),s,g);if("Tooltip"===o)return r().createElement(or.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(or.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Fr.Typeahead,s);if("Markdown"===o)return r().createElement(Be,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ge(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ge(),s,g);if("iframe"===o)return r().createElement(en,s);if("Web3Connect"===o)return r().createElement(fn,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,to({},s)].concat(zn(g)));if(!1===i)return r().createElement(o,to({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Gr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Gr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat(zn(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Gn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Gn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Gn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Dr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),G=q[0],D=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Dt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),D(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),G&&r().createElement(Rr,{show:!0,widgetSrc:E,data:G.data,force:G.force,onHide:function(){return D(null)},onCommit:G.onCommit,onCancel:G.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Dt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return jt(p,t,e,r,n,o)},p.sendTransactions=function(t){return At(p,t)},p.contract=Nt(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return Pt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Gt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Dt=function(t){return Gt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Dt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Dt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Gr=n.n(qr);const Dr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Dn(t,e,r){return Dn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Dn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,qr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!ao[s.as]&&delete s.as,s.forwardedAs&&!ao[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,De.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(to(to({},s),{},{children:g}));if(u)return(0,qr.isStyledComponent)(u)?r().createElement.apply(r(),[u,to({},s)].concat(zn(g))):u(to({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Mr,$n({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement($e(),s,g);if("Tooltip"===o)return r().createElement(or.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(or.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Fr.Typeahead,s);if("Markdown"===o)return r().createElement(Be,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ge(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ge(),s,g);if("iframe"===o)return r().createElement(en,s);if("Web3Connect"===o)return r().createElement(fn,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,to({},s)].concat(zn(g)));if(!1===i)return r().createElement(o,to({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Gr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Gr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat(zn(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Gn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Gn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Gn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Dr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),G=q[0],D=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Dt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),D(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),G&&r().createElement(Rr,{show:!0,widgetSrc:E,data:G.data,force:G.force,onHide:function(){return D(null)},onCommit:G.onCommit,onCancel:G.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index 86a15090..5f863b98 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -2175,13 +2175,13 @@ export default class VM { } getVmInstance(code, src) { - if (this.vmInstances.has(src)) { - const vm = this.vmInstances.get(src); + if (this.vmInstances.has(code)) { + const vm = this.vmInstances.get(code); if (vm.rawCode === code) { return vm; } vm.stop(); - this.vmInstances.delete(src); + this.vmInstances.delete(code); } const vm = new VM({ near: this.near, @@ -2197,7 +2197,7 @@ export default class VM { ethersProviderContext: this.ethersProviderContext, isModule: true, }); - this.vmInstances.set(src, vm); + this.vmInstances.set(code, vm); return vm; } From 947249c6c088d3177e87c7d1619910dd7428db70 Mon Sep 17 00:00:00 2001 From: Roshaan Siddiqui Date: Wed, 27 Sep 2023 10:30:02 -0500 Subject: [PATCH 16/25] feat: add property to widget DOM elements --- src/lib/vm/vm.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index 5f863b98..fcfd7871 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -583,6 +583,8 @@ class VmStack { }); attributes.key = attributes.key ?? `${this.vm.widgetSrc}-${element}-${this.vm.gIndex}`; + attributes["data-key"] = + attributes["data-key"] ?? this.vm.widgetSrc; delete attributes.dangerouslySetInnerHTML; const basicElement = (isStyledComponent(customComponent) && customComponent?.target) || From 44f0b232e049bd3a1990288333b578d36a17882a Mon Sep 17 00:00:00 2001 From: Roshaan Siddiqui Date: Tue, 3 Oct 2023 15:02:29 -0500 Subject: [PATCH 17/25] feat: put widgetSrc behind a feature flag --- src/lib/data/near.js | 2 ++ src/lib/vm/vm.js | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/data/near.js b/src/lib/data/near.js index 1aa9fa10..a7e4bb6c 100644 --- a/src/lib/data/near.js +++ b/src/lib/data/near.js @@ -218,6 +218,7 @@ async function _initNear({ selector, walletConnectCallback = () => {}, customElements = {}, + features = {}, }) { if (!config) { config = {}; @@ -250,6 +251,7 @@ async function _initNear({ selector, keyStore, nearConnection, + features }; _near.nearArchivalConnection = nearAPI.Connection.fromConfig({ diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index fcfd7871..ce3d9378 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -583,8 +583,11 @@ class VmStack { }); attributes.key = attributes.key ?? `${this.vm.widgetSrc}-${element}-${this.vm.gIndex}`; - attributes["data-key"] = - attributes["data-key"] ?? this.vm.widgetSrc; + + if (this.vm.near.features.enableWidgetSrcDataKey == true) { + attributes["data-key"] = attributes["data-key"] ?? this.vm.widgetSrc; + } + delete attributes.dangerouslySetInnerHTML; const basicElement = (isStyledComponent(customComponent) && customComponent?.target) || From 9a263e1689187d57b35f9dfe77bf8df31d4228ca Mon Sep 17 00:00:00 2001 From: Roshaan Siddiqui Date: Fri, 6 Oct 2023 13:11:47 -0500 Subject: [PATCH 18/25] Update src/lib/vm/vm.js Co-authored-by: Evgeny Kuzyakov --- src/lib/vm/vm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index ce3d9378..4bdb0ba1 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -584,7 +584,7 @@ class VmStack { attributes.key = attributes.key ?? `${this.vm.widgetSrc}-${element}-${this.vm.gIndex}`; - if (this.vm.near.features.enableWidgetSrcDataKey == true) { + if (this.vm.near?.features?.enableWidgetSrcDataKey == true) { attributes["data-key"] = attributes["data-key"] ?? this.vm.widgetSrc; } From 790aff277b7d2b604ba1b2ce991d270f824ac3ac Mon Sep 17 00:00:00 2001 From: Roshaan Siddiqui Date: Mon, 9 Oct 2023 12:47:11 -0500 Subject: [PATCH 19/25] docs: add comment about currently allowed features --- src/lib/data/near.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/data/near.js b/src/lib/data/near.js index a7e4bb6c..293a7411 100644 --- a/src/lib/data/near.js +++ b/src/lib/data/near.js @@ -211,6 +211,10 @@ async function web4ViewCall(contractId, methodName, args, fallback) { } } +/** + * Current VM Features: + * - enableWidgetSrcDataKey: Allows enabling the widget source data-key for rendered DOM elements. Disabled by default. +**/ async function _initNear({ networkId, config, From 0090f9339cbab63bd1c164cc743bb132dcc22d27 Mon Sep 17 00:00:00 2001 From: Roshaan Siddiqui Date: Mon, 9 Oct 2023 16:27:07 -0500 Subject: [PATCH 20/25] chore: check in dist/ --- dist/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 86fb1bea..129d2165 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Dt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>G,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>D,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},G=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},D=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return jt(p,t,e,r,n,o)},p.sendTransactions=function(t){return At(p,t)},p.contract=Nt(p,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),p.accountState=function(t){return Pt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Gt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Dt=function(t){return Gt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Dt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Dt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Gr=n.n(qr);const Dr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Dn(t,e,r){return Dn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Dn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},n.vm.setReactState(n.vm.state.state),z(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,qr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!ao[s.as]&&delete s.as,s.forwardedAs&&!ao[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,De.sanitizeUrl)(n))})):"Widget"===o?(s.depth=this.vm.depth+1,s.config=[s.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===o&&(s.networkId=this.vm.networkId),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(to(to({},s),{},{children:g}));if(u)return(0,qr.isStyledComponent)(u)?r().createElement.apply(r(),[u,to({},s)].concat(zn(g))):u(to({children:g},s));if("Widget"===o)return r().createElement(Uo,s);if("CommitButton"===o)return r().createElement(Mr,$n({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement($e(),s,g);if("Tooltip"===o)return r().createElement(or.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(or.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Fr.Typeahead,s);if("Markdown"===o)return r().createElement(Be,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Ge(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Ge(),s,g);if("iframe"===o)return r().createElement(en,s);if("Web3Connect"===o)return r().createElement(fn,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,to({},s)].concat(zn(g)));if(!1===i)return r().createElement(o,to({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Gr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Gr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var G=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var D=C.apply(void 0,[M].concat(zn(G)));return F&&this.vm.cachedStyledComponents.set(q,D),D}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Gn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Gn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Gn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Dr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),G=q[0],D=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Dt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),D(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),G&&r().createElement(Rr,{show:!0,widgetSrc:E,data:G.data,force:G.force,onHide:function(){return D(null)},onCommit:G.onCommit,onCancel:G.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=D(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>D,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>G,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},D=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},G=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d,y,v;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,h=e.features,p=void 0===h?{}:h,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return d=t.sent,(y={config:o,selector:c,keyStore:i,nearConnection:d,features:p}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),v=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},y.viewCall=function(t,e,r,n){var i=v(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?y.nearArchivalConnection.provider:y.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},y.block=function(t){var e=v(t);return(e.blockId?y.nearArchivalConnection.provider:y.nearConnection.connection.provider).block(e)},y.functionCall=function(t,e,r,n,o){return jt(y,t,e,r,n,o)},y.sendTransactions=function(t){return At(y,t)},y.contract=Nt(y,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),y.accountState=function(t){return Pt(y,t)},t.abrupt("return",y);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Dt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return Dt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Gt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Dr=n.n(qr);const Gr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Gn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},i.vm.setReactState(i.vm.state.state),z(t[0]).then((function(t){if(i.vm.alive){var e=i.vm.vmStack.resolveMemberExpression(n.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},i.vm.setReactState(i.vm.state.state)}}))):(c[u]=null,i.vm.setReactState(i.vm.state.state))}}}else{var s=i.resolveMemberExpression(n.expression,{requireState:!0,left:!0}),l=s.obj,p=s.key;f.value=(null==l?void 0:l[p])||"",f.onChange=function(t){t.preventDefault(),l[p]=t.target.value,i.vm.setReactState(i.vm.state.state)}}})),f.key=null!==(e=f.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(a,"-").concat(this.vm.gIndex),1==(null===(n=this.vm.near)||void 0===n||null===(o=n.features)||void 0===o?void 0:o.enableWidgetSrcDataKey)&&(f["data-key"]=null!==(p=f["data-key"])&&void 0!==p?p:this.vm.widgetSrc),delete f.dangerouslySetInnerHTML;var y,v=(0,qr.isStyledComponent)(l)&&(null==l?void 0:l.target)||a;if(f.as&&!ao[f.as]&&delete f.as,f.forwardedAs&&!ao[f.forwardedAs]&&delete f.forwardedAs,"img"===v?f.alt=null!==(y=f.alt)&&void 0!==y?y:"not defined":"a"===v?Object.entries(f).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(f[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===a?(f.depth=this.vm.depth+1,f.config=[f.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===a&&(f.networkId=this.vm.networkId),!1===c&&t.children.length)throw new Error("And element '"+a+"' contains children, but shouldn't");var m,g,b,w,E=t.children.map((function(t,e){return i.vm.gIndex=e,i.executeExpression(t)}));if(u)return u(to(to({},f),{},{children:E}));if(l)return(0,qr.isStyledComponent)(l)?r().createElement.apply(r(),[l,to({},f)].concat(zn(E))):l(to({children:E},f));if("Widget"===a)return r().createElement(Uo,f);if("CommitButton"===a)return r().createElement(Mr,$n({},f,{widgetSrc:this.vm.widgetSrc}),E);if("InfiniteScroll"===a)return r().createElement($e(),f,E);if("Tooltip"===a)return r().createElement(or.Tooltip,f,E);if("OverlayTrigger"===a)return r().createElement(or.OverlayTrigger,f,E.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===a)return r().createElement(Fr.Typeahead,f);if("Markdown"===a)return r().createElement(Be,f);if("Fragment"===a)return r().createElement(r().Fragment,f,E);if("IpfsImageUpload"===a)return r().createElement("div",{className:"d-inline-block",key:f.key},(null===(m=h.img)||void 0===m?void 0:m.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(g=h.img)||void 0===g?void 0:g.cid),alt:"upload preview"})),r().createElement(De(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},f),null!==(b=h.img)&&void 0!==b&&b.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(w=h.img)&&void 0!==w&&w.cid?"Replace":"Upload an Image"));if("Files"===a)return r().createElement(De(),f,E);if("iframe"===a)return r().createElement(en,f);if("Web3Connect"===a)return r().createElement(fn,f);if(s){if(a.includes("Portal"))throw new Error("Radix's \"".concat(a,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var x=E;return Array.isArray(x)&&(1===(x=x.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?x=x[0]:0===x.length&&(x=void 0)),r().createElement(s,f,x)}if(!0===c)return r().createElement.apply(r(),[a,to({},f)].concat(zn(E)));if(!1===c)return r().createElement(a,to({},f));throw new Error("Unsupported element: "+a)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Dr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Dr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var D=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[M].concat(zn(D)));return F&&this.vm.cachedStyledComponents.set(q,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Dn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Dn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Dn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),D=q[0],G=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Gt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),G(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),D&&r().createElement(Rr,{show:!0,widgetSrc:E,data:D.data,force:D.force,onHide:function(){return G(null)},onCommit:D.onCommit,onCancel:D.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file From 14b00b3d402da56bc43089d948e7e50c2840c1bb Mon Sep 17 00:00:00 2001 From: Roshaan Siddiqui Date: Tue, 10 Oct 2023 13:32:58 -0500 Subject: [PATCH 21/25] refactor: change `data-key` -> `data-component` --- CHANGELOG.md | 1 + dist/index.js | 2 +- src/lib/data/near.js | 2 +- src/lib/vm/vm.js | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ab3a26c..ac65d141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Pending +- Add a VM feature, `enableComponentSrcDataKey`, which adds the `data-component` attribute specifying the path of the comonent responsible for rendering the DOM element. - Add support for VM.require when using redirectMap. - Fixes an issue with VM.require not retaining context in migration to initGlobalFunctions. - Add `onLink` and `onImage` to Markdown component. It allows to display links and images differently. diff --git a/dist/index.js b/dist/index.js index 129d2165..8e847afc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=D(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>D,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>G,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},D=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},G=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d,y,v;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,h=e.features,p=void 0===h?{}:h,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return d=t.sent,(y={config:o,selector:c,keyStore:i,nearConnection:d,features:p}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),v=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},y.viewCall=function(t,e,r,n){var i=v(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?y.nearArchivalConnection.provider:y.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},y.block=function(t){var e=v(t);return(e.blockId?y.nearArchivalConnection.provider:y.nearConnection.connection.provider).block(e)},y.functionCall=function(t,e,r,n,o){return jt(y,t,e,r,n,o)},y.sendTransactions=function(t){return At(y,t)},y.contract=Nt(y,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),y.accountState=function(t){return Pt(y,t)},t.abrupt("return",y);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Dt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return Dt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Gt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Dr=n.n(qr);const Gr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Gn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},i.vm.setReactState(i.vm.state.state),z(t[0]).then((function(t){if(i.vm.alive){var e=i.vm.vmStack.resolveMemberExpression(n.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},i.vm.setReactState(i.vm.state.state)}}))):(c[u]=null,i.vm.setReactState(i.vm.state.state))}}}else{var s=i.resolveMemberExpression(n.expression,{requireState:!0,left:!0}),l=s.obj,p=s.key;f.value=(null==l?void 0:l[p])||"",f.onChange=function(t){t.preventDefault(),l[p]=t.target.value,i.vm.setReactState(i.vm.state.state)}}})),f.key=null!==(e=f.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(a,"-").concat(this.vm.gIndex),1==(null===(n=this.vm.near)||void 0===n||null===(o=n.features)||void 0===o?void 0:o.enableWidgetSrcDataKey)&&(f["data-key"]=null!==(p=f["data-key"])&&void 0!==p?p:this.vm.widgetSrc),delete f.dangerouslySetInnerHTML;var y,v=(0,qr.isStyledComponent)(l)&&(null==l?void 0:l.target)||a;if(f.as&&!ao[f.as]&&delete f.as,f.forwardedAs&&!ao[f.forwardedAs]&&delete f.forwardedAs,"img"===v?f.alt=null!==(y=f.alt)&&void 0!==y?y:"not defined":"a"===v?Object.entries(f).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(f[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===a?(f.depth=this.vm.depth+1,f.config=[f.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===a&&(f.networkId=this.vm.networkId),!1===c&&t.children.length)throw new Error("And element '"+a+"' contains children, but shouldn't");var m,g,b,w,E=t.children.map((function(t,e){return i.vm.gIndex=e,i.executeExpression(t)}));if(u)return u(to(to({},f),{},{children:E}));if(l)return(0,qr.isStyledComponent)(l)?r().createElement.apply(r(),[l,to({},f)].concat(zn(E))):l(to({children:E},f));if("Widget"===a)return r().createElement(Uo,f);if("CommitButton"===a)return r().createElement(Mr,$n({},f,{widgetSrc:this.vm.widgetSrc}),E);if("InfiniteScroll"===a)return r().createElement($e(),f,E);if("Tooltip"===a)return r().createElement(or.Tooltip,f,E);if("OverlayTrigger"===a)return r().createElement(or.OverlayTrigger,f,E.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===a)return r().createElement(Fr.Typeahead,f);if("Markdown"===a)return r().createElement(Be,f);if("Fragment"===a)return r().createElement(r().Fragment,f,E);if("IpfsImageUpload"===a)return r().createElement("div",{className:"d-inline-block",key:f.key},(null===(m=h.img)||void 0===m?void 0:m.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(g=h.img)||void 0===g?void 0:g.cid),alt:"upload preview"})),r().createElement(De(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},f),null!==(b=h.img)&&void 0!==b&&b.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(w=h.img)&&void 0!==w&&w.cid?"Replace":"Upload an Image"));if("Files"===a)return r().createElement(De(),f,E);if("iframe"===a)return r().createElement(en,f);if("Web3Connect"===a)return r().createElement(fn,f);if(s){if(a.includes("Portal"))throw new Error("Radix's \"".concat(a,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var x=E;return Array.isArray(x)&&(1===(x=x.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?x=x[0]:0===x.length&&(x=void 0)),r().createElement(s,f,x)}if(!0===c)return r().createElement.apply(r(),[a,to({},f)].concat(zn(E)));if(!1===c)return r().createElement(a,to({},f));throw new Error("Unsupported element: "+a)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Dr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Dr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var D=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[M].concat(zn(D)));return F&&this.vm.cachedStyledComponents.set(q,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Dn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Dn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Dn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),D=q[0],G=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Gt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),G(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),D&&r().createElement(Rr,{show:!0,widgetSrc:E,data:D.data,force:D.force,onHide:function(){return G(null)},onCommit:D.onCommit,onCancel:D.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=D(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>D,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>G,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},D=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},G=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d,y,v;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,h=e.features,p=void 0===h?{}:h,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return d=t.sent,(y={config:o,selector:c,keyStore:i,nearConnection:d,features:p}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),v=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},y.viewCall=function(t,e,r,n){var i=v(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?y.nearArchivalConnection.provider:y.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},y.block=function(t){var e=v(t);return(e.blockId?y.nearArchivalConnection.provider:y.nearConnection.connection.provider).block(e)},y.functionCall=function(t,e,r,n,o){return jt(y,t,e,r,n,o)},y.sendTransactions=function(t){return At(y,t)},y.contract=Nt(y,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),y.accountState=function(t){return Pt(y,t)},t.abrupt("return",y);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Dt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return Dt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Gt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Dr=n.n(qr);const Gr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Gn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},i.vm.setReactState(i.vm.state.state),z(t[0]).then((function(t){if(i.vm.alive){var e=i.vm.vmStack.resolveMemberExpression(n.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},i.vm.setReactState(i.vm.state.state)}}))):(c[u]=null,i.vm.setReactState(i.vm.state.state))}}}else{var s=i.resolveMemberExpression(n.expression,{requireState:!0,left:!0}),l=s.obj,p=s.key;f.value=(null==l?void 0:l[p])||"",f.onChange=function(t){t.preventDefault(),l[p]=t.target.value,i.vm.setReactState(i.vm.state.state)}}})),f.key=null!==(e=f.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(a,"-").concat(this.vm.gIndex),1==(null===(n=this.vm.near)||void 0===n||null===(o=n.features)||void 0===o?void 0:o.enableComponentSrcDataKey)&&(f["data-component"]=null!==(p=f["data-component"])&&void 0!==p?p:this.vm.widgetSrc),delete f.dangerouslySetInnerHTML;var y,v=(0,qr.isStyledComponent)(l)&&(null==l?void 0:l.target)||a;if(f.as&&!ao[f.as]&&delete f.as,f.forwardedAs&&!ao[f.forwardedAs]&&delete f.forwardedAs,"img"===v?f.alt=null!==(y=f.alt)&&void 0!==y?y:"not defined":"a"===v?Object.entries(f).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(f[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===a?(f.depth=this.vm.depth+1,f.config=[f.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===a&&(f.networkId=this.vm.networkId),!1===c&&t.children.length)throw new Error("And element '"+a+"' contains children, but shouldn't");var m,g,b,w,E=t.children.map((function(t,e){return i.vm.gIndex=e,i.executeExpression(t)}));if(u)return u(to(to({},f),{},{children:E}));if(l)return(0,qr.isStyledComponent)(l)?r().createElement.apply(r(),[l,to({},f)].concat(zn(E))):l(to({children:E},f));if("Widget"===a)return r().createElement(Uo,f);if("CommitButton"===a)return r().createElement(Mr,$n({},f,{widgetSrc:this.vm.widgetSrc}),E);if("InfiniteScroll"===a)return r().createElement($e(),f,E);if("Tooltip"===a)return r().createElement(or.Tooltip,f,E);if("OverlayTrigger"===a)return r().createElement(or.OverlayTrigger,f,E.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===a)return r().createElement(Fr.Typeahead,f);if("Markdown"===a)return r().createElement(Be,f);if("Fragment"===a)return r().createElement(r().Fragment,f,E);if("IpfsImageUpload"===a)return r().createElement("div",{className:"d-inline-block",key:f.key},(null===(m=h.img)||void 0===m?void 0:m.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(g=h.img)||void 0===g?void 0:g.cid),alt:"upload preview"})),r().createElement(De(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},f),null!==(b=h.img)&&void 0!==b&&b.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(w=h.img)&&void 0!==w&&w.cid?"Replace":"Upload an Image"));if("Files"===a)return r().createElement(De(),f,E);if("iframe"===a)return r().createElement(en,f);if("Web3Connect"===a)return r().createElement(fn,f);if(s){if(a.includes("Portal"))throw new Error("Radix's \"".concat(a,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var x=E;return Array.isArray(x)&&(1===(x=x.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?x=x[0]:0===x.length&&(x=void 0)),r().createElement(s,f,x)}if(!0===c)return r().createElement.apply(r(),[a,to({},f)].concat(zn(E)));if(!1===c)return r().createElement(a,to({},f));throw new Error("Unsupported element: "+a)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Dr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Dr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var D=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[M].concat(zn(D)));return F&&this.vm.cachedStyledComponents.set(q,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Dn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Dn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Dn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),D=q[0],G=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Gt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),G(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),D&&r().createElement(Rr,{show:!0,widgetSrc:E,data:D.data,force:D.force,onHide:function(){return G(null)},onCommit:D.onCommit,onCancel:D.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file diff --git a/src/lib/data/near.js b/src/lib/data/near.js index 293a7411..03c1a4f3 100644 --- a/src/lib/data/near.js +++ b/src/lib/data/near.js @@ -213,7 +213,7 @@ async function web4ViewCall(contractId, methodName, args, fallback) { /** * Current VM Features: - * - enableWidgetSrcDataKey: Allows enabling the widget source data-key for rendered DOM elements. Disabled by default. + * - enableComponentSrcDataKey: Allows enabling the component source `data-component` attribute for rendered DOM elements. Disabled by default. **/ async function _initNear({ networkId, diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index 4bdb0ba1..fab88b61 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -584,8 +584,8 @@ class VmStack { attributes.key = attributes.key ?? `${this.vm.widgetSrc}-${element}-${this.vm.gIndex}`; - if (this.vm.near?.features?.enableWidgetSrcDataKey == true) { - attributes["data-key"] = attributes["data-key"] ?? this.vm.widgetSrc; + if (this.vm.near?.features?.enableComponentSrcDataKey == true) { + attributes["data-component"] = attributes["data-component"] ?? this.vm.widgetSrc; } delete attributes.dangerouslySetInnerHTML; From 8a4c0a7f98947bb8231fce0480fd6aa17d3dbea0 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Fri, 13 Oct 2023 10:05:23 -0700 Subject: [PATCH 22/25] Support default case for switch --- dist/index.js | 2 +- src/lib/vm/vm.js | 35 +++++++++++++++++------------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/dist/index.js b/dist/index.js index 8e847afc..9a2f0ff9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=D(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>D,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>G,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},D=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},G=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d,y,v;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,h=e.features,p=void 0===h?{}:h,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return d=t.sent,(y={config:o,selector:c,keyStore:i,nearConnection:d,features:p}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),v=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},y.viewCall=function(t,e,r,n){var i=v(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?y.nearArchivalConnection.provider:y.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},y.block=function(t){var e=v(t);return(e.blockId?y.nearArchivalConnection.provider:y.nearConnection.connection.provider).block(e)},y.functionCall=function(t,e,r,n,o){return jt(y,t,e,r,n,o)},y.sendTransactions=function(t){return At(y,t)},y.contract=Nt(y,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),y.accountState=function(t){return Pt(y,t)},t.abrupt("return",y);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Dt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return Dt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Gt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Dr=n.n(qr);const Gr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Gn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},i.vm.setReactState(i.vm.state.state),z(t[0]).then((function(t){if(i.vm.alive){var e=i.vm.vmStack.resolveMemberExpression(n.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},i.vm.setReactState(i.vm.state.state)}}))):(c[u]=null,i.vm.setReactState(i.vm.state.state))}}}else{var s=i.resolveMemberExpression(n.expression,{requireState:!0,left:!0}),l=s.obj,p=s.key;f.value=(null==l?void 0:l[p])||"",f.onChange=function(t){t.preventDefault(),l[p]=t.target.value,i.vm.setReactState(i.vm.state.state)}}})),f.key=null!==(e=f.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(a,"-").concat(this.vm.gIndex),1==(null===(n=this.vm.near)||void 0===n||null===(o=n.features)||void 0===o?void 0:o.enableComponentSrcDataKey)&&(f["data-component"]=null!==(p=f["data-component"])&&void 0!==p?p:this.vm.widgetSrc),delete f.dangerouslySetInnerHTML;var y,v=(0,qr.isStyledComponent)(l)&&(null==l?void 0:l.target)||a;if(f.as&&!ao[f.as]&&delete f.as,f.forwardedAs&&!ao[f.forwardedAs]&&delete f.forwardedAs,"img"===v?f.alt=null!==(y=f.alt)&&void 0!==y?y:"not defined":"a"===v?Object.entries(f).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(f[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===a?(f.depth=this.vm.depth+1,f.config=[f.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===a&&(f.networkId=this.vm.networkId),!1===c&&t.children.length)throw new Error("And element '"+a+"' contains children, but shouldn't");var m,g,b,w,E=t.children.map((function(t,e){return i.vm.gIndex=e,i.executeExpression(t)}));if(u)return u(to(to({},f),{},{children:E}));if(l)return(0,qr.isStyledComponent)(l)?r().createElement.apply(r(),[l,to({},f)].concat(zn(E))):l(to({children:E},f));if("Widget"===a)return r().createElement(Uo,f);if("CommitButton"===a)return r().createElement(Mr,$n({},f,{widgetSrc:this.vm.widgetSrc}),E);if("InfiniteScroll"===a)return r().createElement($e(),f,E);if("Tooltip"===a)return r().createElement(or.Tooltip,f,E);if("OverlayTrigger"===a)return r().createElement(or.OverlayTrigger,f,E.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===a)return r().createElement(Fr.Typeahead,f);if("Markdown"===a)return r().createElement(Be,f);if("Fragment"===a)return r().createElement(r().Fragment,f,E);if("IpfsImageUpload"===a)return r().createElement("div",{className:"d-inline-block",key:f.key},(null===(m=h.img)||void 0===m?void 0:m.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(g=h.img)||void 0===g?void 0:g.cid),alt:"upload preview"})),r().createElement(De(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},f),null!==(b=h.img)&&void 0!==b&&b.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(w=h.img)&&void 0!==w&&w.cid?"Replace":"Upload an Image"));if("Files"===a)return r().createElement(De(),f,E);if("iframe"===a)return r().createElement(en,f);if("Web3Connect"===a)return r().createElement(fn,f);if(s){if(a.includes("Portal"))throw new Error("Radix's \"".concat(a,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var x=E;return Array.isArray(x)&&(1===(x=x.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?x=x[0]:0===x.length&&(x=void 0)),r().createElement(s,f,x)}if(!0===c)return r().createElement.apply(r(),[a,to({},f)].concat(zn(E)));if(!1===c)return r().createElement(a,to({},f));throw new Error("Unsupported element: "+a)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Dr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Dr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var D=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[M].concat(zn(D)));return F&&this.vm.cachedStyledComponents.set(q,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Dn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Dn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(!O&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var P,L=!1,A=Dn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),D=q[0],G=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Gt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),G(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),D&&r().createElement(Rr,{show:!0,widgetSrc:E,data:D.data,force:D.force,onHide:function(){return G(null)},onCommit:D.onCommit,onCancel:D.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=D(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>D,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>G,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},D=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},G=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d,y,v;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,h=e.features,p=void 0===h?{}:h,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return d=t.sent,(y={config:o,selector:c,keyStore:i,nearConnection:d,features:p}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),v=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},y.viewCall=function(t,e,r,n){var i=v(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?y.nearArchivalConnection.provider:y.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},y.block=function(t){var e=v(t);return(e.blockId?y.nearArchivalConnection.provider:y.nearConnection.connection.provider).block(e)},y.functionCall=function(t,e,r,n,o){return jt(y,t,e,r,n,o)},y.sendTransactions=function(t){return At(y,t)},y.contract=Nt(y,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),y.accountState=function(t){return Pt(y,t)},t.abrupt("return",y);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Dt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return Dt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Gt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Dr=n.n(qr);const Gr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Gn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},i.vm.setReactState(i.vm.state.state),z(t[0]).then((function(t){if(i.vm.alive){var e=i.vm.vmStack.resolveMemberExpression(n.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},i.vm.setReactState(i.vm.state.state)}}))):(c[u]=null,i.vm.setReactState(i.vm.state.state))}}}else{var s=i.resolveMemberExpression(n.expression,{requireState:!0,left:!0}),l=s.obj,p=s.key;f.value=(null==l?void 0:l[p])||"",f.onChange=function(t){t.preventDefault(),l[p]=t.target.value,i.vm.setReactState(i.vm.state.state)}}})),f.key=null!==(e=f.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(a,"-").concat(this.vm.gIndex),1==(null===(n=this.vm.near)||void 0===n||null===(o=n.features)||void 0===o?void 0:o.enableComponentSrcDataKey)&&(f["data-component"]=null!==(p=f["data-component"])&&void 0!==p?p:this.vm.widgetSrc),delete f.dangerouslySetInnerHTML;var y,v=(0,qr.isStyledComponent)(l)&&(null==l?void 0:l.target)||a;if(f.as&&!ao[f.as]&&delete f.as,f.forwardedAs&&!ao[f.forwardedAs]&&delete f.forwardedAs,"img"===v?f.alt=null!==(y=f.alt)&&void 0!==y?y:"not defined":"a"===v?Object.entries(f).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(f[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===a?(f.depth=this.vm.depth+1,f.config=[f.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===a&&(f.networkId=this.vm.networkId),!1===c&&t.children.length)throw new Error("And element '"+a+"' contains children, but shouldn't");var m,g,b,w,E=t.children.map((function(t,e){return i.vm.gIndex=e,i.executeExpression(t)}));if(u)return u(to(to({},f),{},{children:E}));if(l)return(0,qr.isStyledComponent)(l)?r().createElement.apply(r(),[l,to({},f)].concat(zn(E))):l(to({children:E},f));if("Widget"===a)return r().createElement(Uo,f);if("CommitButton"===a)return r().createElement(Mr,$n({},f,{widgetSrc:this.vm.widgetSrc}),E);if("InfiniteScroll"===a)return r().createElement($e(),f,E);if("Tooltip"===a)return r().createElement(or.Tooltip,f,E);if("OverlayTrigger"===a)return r().createElement(or.OverlayTrigger,f,E.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===a)return r().createElement(Fr.Typeahead,f);if("Markdown"===a)return r().createElement(Be,f);if("Fragment"===a)return r().createElement(r().Fragment,f,E);if("IpfsImageUpload"===a)return r().createElement("div",{className:"d-inline-block",key:f.key},(null===(m=h.img)||void 0===m?void 0:m.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(g=h.img)||void 0===g?void 0:g.cid),alt:"upload preview"})),r().createElement(De(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},f),null!==(b=h.img)&&void 0!==b&&b.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(w=h.img)&&void 0!==w&&w.cid?"Replace":"Upload an Image"));if("Files"===a)return r().createElement(De(),f,E);if("iframe"===a)return r().createElement(en,f);if("Web3Connect"===a)return r().createElement(fn,f);if(s){if(a.includes("Portal"))throw new Error("Radix's \"".concat(a,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var x=E;return Array.isArray(x)&&(1===(x=x.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?x=x[0]:0===x.length&&(x=void 0)),r().createElement(s,f,x)}if(!0===c)return r().createElement.apply(r(),[a,to({},f)].concat(zn(E)));if(!1===c)return r().createElement(a,to({},f));throw new Error("Unsupported element: "+a)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Dr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Dr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var D=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[M].concat(zn(D)));return F&&this.vm.cachedStyledComponents.set(q,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Dn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x=this.executeExpression(t.discriminant),S=this.newStack(),k=t.cases;console.log(t);var O,j=!1,I=Dn(k);try{for(I.s();!(O=I.n()).done;){var P=O.value;if("SwitchCase"!==P.type)throw new Error("Unknown switch case type '"+P.type+"'");if(!j){if(null!==P.test&&S.executeExpression(P.test)!==x)continue;j=!0}if(j){var L,A=!1,C=Dn(P.consequent);try{for(C.s();!(L=C.n()).done;){var N=L.value,T=S.executeStatement(N);if(T){if(T.break){A=!0;break}return T}}}catch(t){C.e(t)}finally{C.f()}if(A)break}}}catch(t){I.e(t)}finally{I.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),D=q[0],G=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Gt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),G(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),D&&r().createElement(Rr,{show:!0,widgetSrc:E,data:D.data,force:D.force,onHide:function(){return G(null)},onCommit:D.onCommit,onCancel:D.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index fab88b61..da7857ec 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -585,7 +585,8 @@ class VmStack { attributes.key ?? `${this.vm.widgetSrc}-${element}-${this.vm.gIndex}`; if (this.vm.near?.features?.enableComponentSrcDataKey == true) { - attributes["data-component"] = attributes["data-component"] ?? this.vm.widgetSrc; + attributes["data-component"] = + attributes["data-component"] ?? this.vm.widgetSrc; } delete attributes.dangerouslySetInnerHTML; @@ -1371,29 +1372,27 @@ class VmStack { if (caseToken.type !== "SwitchCase") { throw new Error("Unknown switch case type '" + caseToken.type + "'"); } - if (!found && caseToken.test) { + if (!found && caseToken.test !== null) { const test = stack.executeExpression(caseToken.test); if (test !== discriminant) { continue; } - found = true; - } - if (found) { - let isBreak = false; - for (const statement of caseToken.consequent) { - const result = stack.executeStatement(statement); - if (result) { - if (result.break) { - isBreak = true; - break; - } else { - return result; - } + } + found = true; + let isBreak = false; + for (const statement of caseToken.consequent) { + const result = stack.executeStatement(statement); + if (result) { + if (result.break) { + isBreak = true; + break; + } else { + return result; } } - if (isBreak) { - break; - } + } + if (isBreak) { + break; } } } else { From c69c103e8460f5c726d4d3176040650b3e3b32ca Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Fri, 13 Oct 2023 10:06:02 -0700 Subject: [PATCH 23/25] Add CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac65d141..5781936f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Pending +- Fix `default` case for the switch statement in `VM`. - Add a VM feature, `enableComponentSrcDataKey`, which adds the `data-component` attribute specifying the path of the comonent responsible for rendering the DOM element. - Add support for VM.require when using redirectMap. - Fixes an issue with VM.require not retaining context in migration to initGlobalFunctions. From e9d68505eb0d853fc86d484c369dfe5279d9e25b Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Fri, 13 Oct 2023 10:45:01 -0700 Subject: [PATCH 24/25] Rebuild --- dist/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 9a2f0ff9..b42f8e16 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=D(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>D,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>G,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},D=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},G=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d,y,v;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,h=e.features,p=void 0===h?{}:h,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return d=t.sent,(y={config:o,selector:c,keyStore:i,nearConnection:d,features:p}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),v=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},y.viewCall=function(t,e,r,n){var i=v(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?y.nearArchivalConnection.provider:y.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},y.block=function(t){var e=v(t);return(e.blockId?y.nearArchivalConnection.provider:y.nearConnection.connection.provider).block(e)},y.functionCall=function(t,e,r,n,o){return jt(y,t,e,r,n,o)},y.sendTransactions=function(t){return At(y,t)},y.contract=Nt(y,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),y.accountState=function(t){return Pt(y,t)},t.abrupt("return",y);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Dt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return Dt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Gt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Dr=n.n(qr);const Gr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Gn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},i.vm.setReactState(i.vm.state.state),z(t[0]).then((function(t){if(i.vm.alive){var e=i.vm.vmStack.resolveMemberExpression(n.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},i.vm.setReactState(i.vm.state.state)}}))):(c[u]=null,i.vm.setReactState(i.vm.state.state))}}}else{var s=i.resolveMemberExpression(n.expression,{requireState:!0,left:!0}),l=s.obj,p=s.key;f.value=(null==l?void 0:l[p])||"",f.onChange=function(t){t.preventDefault(),l[p]=t.target.value,i.vm.setReactState(i.vm.state.state)}}})),f.key=null!==(e=f.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(a,"-").concat(this.vm.gIndex),1==(null===(n=this.vm.near)||void 0===n||null===(o=n.features)||void 0===o?void 0:o.enableComponentSrcDataKey)&&(f["data-component"]=null!==(p=f["data-component"])&&void 0!==p?p:this.vm.widgetSrc),delete f.dangerouslySetInnerHTML;var y,v=(0,qr.isStyledComponent)(l)&&(null==l?void 0:l.target)||a;if(f.as&&!ao[f.as]&&delete f.as,f.forwardedAs&&!ao[f.forwardedAs]&&delete f.forwardedAs,"img"===v?f.alt=null!==(y=f.alt)&&void 0!==y?y:"not defined":"a"===v?Object.entries(f).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(f[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===a?(f.depth=this.vm.depth+1,f.config=[f.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===a&&(f.networkId=this.vm.networkId),!1===c&&t.children.length)throw new Error("And element '"+a+"' contains children, but shouldn't");var m,g,b,w,E=t.children.map((function(t,e){return i.vm.gIndex=e,i.executeExpression(t)}));if(u)return u(to(to({},f),{},{children:E}));if(l)return(0,qr.isStyledComponent)(l)?r().createElement.apply(r(),[l,to({},f)].concat(zn(E))):l(to({children:E},f));if("Widget"===a)return r().createElement(Uo,f);if("CommitButton"===a)return r().createElement(Mr,$n({},f,{widgetSrc:this.vm.widgetSrc}),E);if("InfiniteScroll"===a)return r().createElement($e(),f,E);if("Tooltip"===a)return r().createElement(or.Tooltip,f,E);if("OverlayTrigger"===a)return r().createElement(or.OverlayTrigger,f,E.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===a)return r().createElement(Fr.Typeahead,f);if("Markdown"===a)return r().createElement(Be,f);if("Fragment"===a)return r().createElement(r().Fragment,f,E);if("IpfsImageUpload"===a)return r().createElement("div",{className:"d-inline-block",key:f.key},(null===(m=h.img)||void 0===m?void 0:m.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(g=h.img)||void 0===g?void 0:g.cid),alt:"upload preview"})),r().createElement(De(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},f),null!==(b=h.img)&&void 0!==b&&b.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(w=h.img)&&void 0!==w&&w.cid?"Replace":"Upload an Image"));if("Files"===a)return r().createElement(De(),f,E);if("iframe"===a)return r().createElement(en,f);if("Web3Connect"===a)return r().createElement(fn,f);if(s){if(a.includes("Portal"))throw new Error("Radix's \"".concat(a,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var x=E;return Array.isArray(x)&&(1===(x=x.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?x=x[0]:0===x.length&&(x=void 0)),r().createElement(s,f,x)}if(!0===c)return r().createElement.apply(r(),[a,to({},f)].concat(zn(E)));if(!1===c)return r().createElement(a,to({},f));throw new Error("Unsupported element: "+a)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Dr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Dr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var D=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[M].concat(zn(D)));return F&&this.vm.cachedStyledComponents.set(q,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Dn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x=this.executeExpression(t.discriminant),S=this.newStack(),k=t.cases;console.log(t);var O,j=!1,I=Dn(k);try{for(I.s();!(O=I.n()).done;){var P=O.value;if("SwitchCase"!==P.type)throw new Error("Unknown switch case type '"+P.type+"'");if(!j){if(null!==P.test&&S.executeExpression(P.test)!==x)continue;j=!0}if(j){var L,A=!1,C=Dn(P.consequent);try{for(C.s();!(L=C.n()).done;){var N=L.value,T=S.executeStatement(N);if(T){if(T.break){A=!0;break}return T}}}catch(t){C.e(t)}finally{C.f()}if(A)break}}}catch(t){I.e(t)}finally{I.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),D=q[0],G=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Gt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),G(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),D&&r().createElement(Rr,{show:!0,widgetSrc:E,data:D.data,force:D.force,onHide:function(){return G(null)},onCommit:D.onCommit,onCancel:D.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(o)return n?-1:V(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=D(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>Mr,EthersProviderContext:()=>ln,Widget:()=>Uo,useAccount:()=>ue,useAccountId:()=>se,useCache:()=>jr,useInitNear:()=>Ft,useNear:()=>Gt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>L,Loading:()=>P,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>it,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>J,bigMax:()=>R,bigMin:()=>U,bigToString:()=>M,computeSrcOrCode:()=>lt,computeWritePermission:()=>nt,convertToStringLeaves:()=>Y,dateToString:()=>D,deepCopy:()=>ct,deepEqual:()=>st,deepFreeze:()=>ot,displayGas:()=>q,displayNear:()=>F,displayTime:()=>G,estimateDataSize:()=>W,extractKeys:()=>K,filterValues:()=>ut,indexMatch:()=>et,ipfsUpload:()=>z,ipfsUrl:()=>V,isArray:()=>C,isFunction:()=>_,isObject:()=>N,isReactObject:()=>at,isString:()=>T,isValidAccountId:()=>A,isoDate:()=>$,keysToCamel:()=>B,patternMatch:()=>tt,removeDuplicates:()=>X});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||v(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),P=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),L=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function A(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},N=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function(t){return"function"==typeof t},B=function t(e){if(N(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return C(e)?e.map((function(e){return t(e)})):e},U=function(t,e){return t&&e?t.lt(e)?t:e:t||e},R=function(t,e){return t&&e?t.gt(e)?t:e:t||e},M=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},F=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,M(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},q=function(t){return t?r().createElement(r().Fragment,null,M(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},D=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},G=function(t){return t.toLocaleString()},J=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},$=function(t){return t?new Date(t).toISOString().substring(0,10):""},z=function(){var t,e=(t=g().mark((function t(e){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),V=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return N(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),N(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return N(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=N(r)?r[i]:void 0;if(N(a)){var u=N(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},H=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return N(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[H(o)]=t(i),e}),{}):H(e)},Z=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return N(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Q=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||N(e)&&t(e,r.slice(1))}))},tt=function(t,e,r){var n=e.split("/");return"get"===t?Z(r,n):"keys"===t&&Q(r,n)},et=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},rt={graph:!0,post:!0,index:!0,settings:!0},nt=function(t,e){var r=N(t)?JSON.parse(JSON.stringify(t)):{};return N(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in rt)if(N(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ot=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},it="$$typeof",at=function(t){return null!==t&&"object"===d(t)&&!!t[it]},ct=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:N(e)?at(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ut=function(t){return N(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=y(t,2);return e[0],void 0!==e[1]}))):t},st=l(),lt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=v(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=N(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=_(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},ft=n(764).lW;function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function bt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){bt(i,n,o,a,c,"next",t)}function c(t){bt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Et=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},xt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},St={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},kt={get:!0,keys:!0},Ot=function(){var t=wt(gt().mark((function t(e,r,n,o,i){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in kt){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function jt(t,e,r,n,o,i){return It.apply(this,arguments)}function It(){return(It=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[Et(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Pt(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=wt(gt().mark((function t(e,r){var n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e){return Ct.apply(this,arguments)}function Ct(){return(Ct=wt(gt().mark((function t(e,r){var n,o,i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=Et(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).apply(this,arguments)}function Nt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function Tt(t,e,r,n,o,i){return _t.apply(this,arguments)}function _t(){return(_t=wt(gt().mark((function t(e,r,n,o,i,a){var c;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:ft.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(ft.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r,n){return Ut.apply(this,arguments)}function Ut(){return(Ut=wt(gt().mark((function t(e,r,n,o){var i;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=vt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Rt(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=wt(gt().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d,y,v;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,h=e.features,p=void 0===h?{}:h,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},St,o):"testnet"===o.networkId&&(o=Object.assign({},xt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return d=t.sent,(y={config:o,selector:c,keyStore:i,nearConnection:d,features:p}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),v=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},y.viewCall=function(t,e,r,n){var i=v(n),a=i.blockId,c=i.finality,u=function(){return Tt(a?y.nearArchivalConnection.provider:y.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Bt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Ot(o,e,r,a,s)},y.block=function(t){var e=v(t);return(e.blockId?y.nearArchivalConnection.provider:y.nearConnection.connection.provider).block(e)},y.functionCall=function(t,e,r,n,o){return jt(y,t,e,r,n,o)},y.sendTransactions=function(t){return At(y,t)},y.contract=Nt(y,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),y.accountState=function(t){return Pt(y,t)},t.abrupt("return",y);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ft=(0,i.singletonHook)({},(function(){var t=vt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:dt(dt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:dt(dt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Rt)).then((function(t){return t.map((function(t){return dt(dt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),qt=[],Dt=(0,i.singletonHook)(qt,(function(){var t=vt((0,e.useState)(qt),2),r=t[0],n=t[1],o=Ft().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),Gt=function(t){return Dt()[t||"default"]||null};const Jt=require("local-storage");var $t,zt,Vt,Wt,Kt=n.n(Jt);function Xt(t){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xt(t)}function Ht(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Qt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Qt(i,n,o,a,c,"next",t)}function c(t){Qt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ee="near-social-vm:v01:",re=ee+":accountId:",ne=ee+":pretendAccountId:",oe={loading:!0,signedAccountId:null!==($t=Kt().get(re))&&void 0!==$t?$t:void 0,pretendAccountId:null!==(zt=Kt().get(ne))&&void 0!==zt?zt:void 0,accountId:null!==(Vt=null!==(Wt=Kt().get(ne))&&void 0!==Wt?Wt:Kt().get(re))&&void 0!==Vt?Vt:void 0,state:null,near:null};function ie(t,e){return ae.apply(this,arguments)}function ae(){return(ae=te(Zt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=Kt().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(Kt().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ce=function(){var t=te(Zt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Kt().set(re,o),e.config.walletConnectCallback(o)):Kt().remove(re),i=null!==(n=Kt().get(ne))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=te(Zt().mark((function t(){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ce(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=te(Zt().mark((function t(n){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Kt().set(ne,n):Kt().remove(ne),t.next=3,ce(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=Ht(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),ue=(0,i.singletonHook)(oe,(function(){var t=Ht((0,e.useState)(oe),2),r=t[0],n=t[1],o=Gt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=te(Zt().mark((function t(e){return Zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie(o,e);case 2:return t.prev=2,t.next=5,ce(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),se=function(t){var e=Gt(),r=ue();if(e&&(!t||e.config.networkId===t))return r.accountId};const le=require("react-bootstrap/Modal");var fe=n.n(le);const he=require("remark-gfm");var pe=n.n(he);const de=require("react-markdown");var ye=n.n(de);const ve=require("react-syntax-highlighter"),me=require("react-syntax-highlighter/dist/esm/styles/prism"),ge=require("mdast-util-find-and-replace");var be=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function we(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,ge.findAndReplace)(e,be,t),e}}var Ee=/#(\w+)/gi;function xe(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,ge.findAndReplace)(e,Ee,t),e}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}var ke=["node","children"],Oe=["node"],je=["node"],Ie=["node"],Pe=["node"],Le=["node","inline","className","children"];function Ae(){return Ae=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var Be=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(ye(),{plugins:[],rehypePlugins:[],remarkPlugins:[pe(),we,xe],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=_e(t,ke);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=_e(t,Oe);return e?e(Ne(Ne({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Ae({onClick:n},a)):r().createElement("a",Ae({target:"_blank"},a))},img:function(t){t.node;var e=_e(t,je);return c?c(Ne({},e)):r().createElement("img",Ae({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=_e(t,Ie);return r().createElement("blockquote",Ae({className:"blockquote"},e))},table:function(t){t.node;var e=_e(t,Pe);return r().createElement("table",Ae({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=_e(t,Le),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(ve.Prism,Ae({children:String(o).replace(/\n$/,""),style:me.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Ae({className:n},i),o)}}})};const Ue=require("react-uuid");var Re=n.n(Ue);function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ke(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ke(i,n,o,a,c,"next",t)}function c(t){Ke(i,n,o,a,c,"throw",t)}a(void 0)}))}}var He=x.mul(2e3),Ye=x.mul(500),Ze=x.mul(500),Qe=x.mul(500),tr=function(){var t=Xe(We().mark((function t(e,r){var n;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),er=function(){var t=Xe(We().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=Y(n),(m=function(t){var e=function(t,e){if("object"!==ze(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==ze(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===ze(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,tr(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Ye).add(l?u()(0):Qe).add(Ze),y=R(d.sub(f.mul(x)),s?l?u()(0):u()(1):He),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),rr=function(){var t=Xe(We().mark((function t(e,r,n){return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},w.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),nr=function(){var t=Xe(We().mark((function t(e,r,n){var o,i;return We().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Et("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Et("set",{data:r},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const or=require("react-bootstrap"),ir=require("idb");function ar(t){return ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ar(t)}function cr(t,e){if(t){if("string"==typeof t)return ur(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(t,e):void 0}}function ur(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function lr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){lr(i,n,o,a,c,"next",t)}function c(t){lr(i,n,o,a,c,"throw",t)}a(void 0)}))}}function hr(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,ir.openDB)(e,1,{upgrade:function(t){t.createObjectStore(wr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=fr(sr().mark((function t(e){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(wr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=fr(sr().mark((function t(e,r){return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(wr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:vr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,N(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=br,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===mr||i.status===gr&&i.time+3e5>(new Date).getTime()||(i.status!==vr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===mr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=mr,e&&e().then((function(e){i.status=gr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=gr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action===pr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return tt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===dr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&et(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||cr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=br,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:pr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=fr(sr().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return sr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:dr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Cr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Pr),p=Nr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",Lr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&P,i),r().createElement(Rr,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Fr=require("react-bootstrap-typeahead"),qr=require("styled-components");var Dr=n.n(qr);const Gr=require("elliptic"),Jr=require("bn.js");var $r=n.n(Jr);const zr=require("tweetnacl"),Vr=require("iframe-resizer-react");var Wr=n.n(Vr);function Kr(){return Kr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Gn(t,e,r){return Gn=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Jn(o,r.prototype),o},Gn.apply(null,arguments)}function Jn(t,e){return Jn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jn(t,e)}function $n(){return $n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},i.vm.setReactState(i.vm.state.state),z(t[0]).then((function(t){if(i.vm.alive){var e=i.vm.vmStack.resolveMemberExpression(n.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},i.vm.setReactState(i.vm.state.state)}}))):(c[u]=null,i.vm.setReactState(i.vm.state.state))}}}else{var s=i.resolveMemberExpression(n.expression,{requireState:!0,left:!0}),l=s.obj,p=s.key;f.value=(null==l?void 0:l[p])||"",f.onChange=function(t){t.preventDefault(),l[p]=t.target.value,i.vm.setReactState(i.vm.state.state)}}})),f.key=null!==(e=f.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(a,"-").concat(this.vm.gIndex),1==(null===(n=this.vm.near)||void 0===n||null===(o=n.features)||void 0===o?void 0:o.enableComponentSrcDataKey)&&(f["data-component"]=null!==(p=f["data-component"])&&void 0!==p?p:this.vm.widgetSrc),delete f.dangerouslySetInnerHTML;var y,v=(0,qr.isStyledComponent)(l)&&(null==l?void 0:l.target)||a;if(f.as&&!ao[f.as]&&delete f.as,f.forwardedAs&&!ao[f.forwardedAs]&&delete f.forwardedAs,"img"===v?f.alt=null!==(y=f.alt)&&void 0!==y?y:"not defined":"a"===v?Object.entries(f).forEach((function(t){var e=Xn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(f[r]=(0,Ge.sanitizeUrl)(n))})):"Widget"===a?(f.depth=this.vm.depth+1,f.config=[f.config].concat(zn(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===a&&(f.networkId=this.vm.networkId),!1===c&&t.children.length)throw new Error("And element '"+a+"' contains children, but shouldn't");var m,g,b,w,E=t.children.map((function(t,e){return i.vm.gIndex=e,i.executeExpression(t)}));if(u)return u(to(to({},f),{},{children:E}));if(l)return(0,qr.isStyledComponent)(l)?r().createElement.apply(r(),[l,to({},f)].concat(zn(E))):l(to({children:E},f));if("Widget"===a)return r().createElement(Uo,f);if("CommitButton"===a)return r().createElement(Mr,$n({},f,{widgetSrc:this.vm.widgetSrc}),E);if("InfiniteScroll"===a)return r().createElement($e(),f,E);if("Tooltip"===a)return r().createElement(or.Tooltip,f,E);if("OverlayTrigger"===a)return r().createElement(or.OverlayTrigger,f,E.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===a)return r().createElement(Fr.Typeahead,f);if("Markdown"===a)return r().createElement(Be,f);if("Fragment"===a)return r().createElement(r().Fragment,f,E);if("IpfsImageUpload"===a)return r().createElement("div",{className:"d-inline-block",key:f.key},(null===(m=h.img)||void 0===m?void 0:m.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:V(null===(g=h.img)||void 0===g?void 0:g.cid),alt:"upload preview"})),r().createElement(De(),$n({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},f),null!==(b=h.img)&&void 0!==b&&b.uploading?r().createElement(r().Fragment,null,P," Uploading"):null!==(w=h.img)&&void 0!==w&&w.cid?"Replace":"Upload an Image"));if("Files"===a)return r().createElement(De(),f,E);if("iframe"===a)return r().createElement(en,f);if("Web3Connect"===a)return r().createElement(fn,f);if(s){if(a.includes("Portal"))throw new Error("Radix's \"".concat(a,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var x=E;return Array.isArray(x)&&(1===(x=x.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?x=x[0]:0===x.length&&(x=void 0)),r().createElement(s,f,x)}if(!0===c)return r().createElement.apply(r(),[a,to({},f)].concat(zn(E)));if(!1===c)return r().createElement(a,to({},f));throw new Error("Unsupported element: "+a)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return vo(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(vo(n),null!=e&&e.requireState&&n!==no)throw new Error("The top object should be ".concat(no));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(mo(o),o===this.stack.state&&n in so){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!(n in o)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(c in so){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return mo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,zn(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return Zn(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,A=P.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);mo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var T=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),_=T.key;if("styled"!==T.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B=this.getArray(t.tag.arguments),U=null==B?void 0:B[0],R=bo(U);if(!(0,qr.isStyledComponent)(U)&&!R)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Dr()(null!=R?R:U)}else{if("keyframes"===_)C=qr.keyframes;else{if(!(_ in ao))throw new Error("Unsupported styled tag: "+_);C=Dr()(_)}N=_}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var M=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,q=JSON.stringify([N].concat(zn(M)));if(F&&this.vm.cachedStyledComponents.has(q))return this.vm.cachedStyledComponents.get(q);var D=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[M].concat(zn(D)));return F&&this.vm.cachedStyledComponents.set(q,G),G}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(ko),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);mo(s);var l,f=Dn(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(ko(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===Zn(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Eo(t.handler.param),ct(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=Dn(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(O||null===I.test||k.executeExpression(I.test)===S){O=!0;var P,L=!1,A=Dn(I.consequent);try{for(A.s();!(P=A.n()).done;){var C=P.value,N=k.executeStatement(C);if(N){if(N.break){L=!0;break}return N}}}catch(t){A.e(t)}finally{A.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),Io=function(){function t(e){var r,n=this;Vn(this,t);var o,i=e.near,a=e.rawCode,c=e.setReactState,u=e.cache,s=e.refreshCache,l=e.confirmTransactions,h=e.depth,p=e.widgetSrc,d=e.requestCommit,y=e.version,v=e.widgetConfigs,m=e.ethersProviderContext,g=e.isModule;this.alive=!0,this.isModule=g,this.rawCode=a,this.near=i;try{this.code=(o=a)in po?po[o]:po[o]=yo.parse(o,ho),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=c?function(t){return c({hooks:n.hooks,state:N(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=c?function(t,e){n.hooks[t]=e,c({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=u,this.refreshCache=s,this.confirmTransactions=l,this.depth=null!=h?h:0,this.widgetSrc=p,this.requestCommit=d,this.version=y,this.cachedStyledComponents=new Map,this.widgetConfigs=v,this.ethersProviderContext=m,this.ethersProvider=null!=m&&m.provider?new f.ethers.providers.Web3Provider(m.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=v.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||i.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return Kn(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={view:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return mo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return go(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return mo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return mo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return mo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=to(to(to({},lo),this.globalFunctions),{},{props:N(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=on()(Gr),this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new jo(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const Po=require("react-error-boundary");function Lo(t){return Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lo(t)}var Ao=["loading","src","code","depth","config","props"];function Co(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function No(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Ao),p=_o((0,e.useState)(0),2),d=p[0],y=p[1],v=_o((0,e.useState)(null),2),m=v[0],g=v[1],b=_o((0,e.useState)(null),2),E=b[0],x=b[1],S=_o((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=_o((0,e.useState)(0),2),I=j[0],A=j[1],C=_o((0,e.useState)({}),2),N=C[0],T=C[1],_=_o((0,e.useState)(null),2),B=_[0],U=_[1],R=_o((0,e.useState)(null),2),M=R[0],F=R[1],q=_o((0,e.useState)(null),2),D=q[0],G=q[1],J=_o((0,e.useState)(null),2),$=J[0],z=J[1],V=_o((0,e.useState)(null),2),W=V[0],K=V[1],X=_o((0,e.useState)(null),2),H=X[0],Y=X[1],Z=(0,e.useContext)(ln),Q=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),tt=jr(Q),et=Gt(Q),rt=se(Q),nt=_o((0,e.useState)(null),2),ot=nt[0],it=nt[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];st(t,W)||K(t)}),[l,W]),(0,e.useEffect)((function(){var t=lt(a,c,W);st(t,H)||Y(t)}),[a,c,W,H]),(0,e.useEffect)((function(){if(et)if(null!=H&&H.src){var t=H.src,e=_o(t.split("@"),2),r=e[0],n=e[1],o=tt.socialGet(et,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),x(t)}else null!=H&&H.code&&(g(H.code),x(null))}),[et,H,d]),(0,e.useEffect)((function(){U(null),it(null),m||void 0===m&&it(r().createElement("div",{className:"alert alert-danger"},'Source code for "',E,'" is not found'))}),[m,E]);var at=(0,e.useCallback)((function(t){if(!et||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):w.mul(30)}})),console.log("confirm txs",t),F(t)}),[et]),ut=(0,e.useCallback)((function(t){if(!et)return null;console.log("commit requested",t),G(t)}),[et]);return(0,e.useEffect)((function(){if(et&&m){O({hooks:[],state:void 0});var t=new Io({near:et,rawCode:m,setReactState:O,cache:tt,refreshCache:function(){A((function(t){return t+1}))},confirmTransactions:at,depth:s,widgetSrc:E,requestCommit:ut,version:Re()(),widgetConfigs:W,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[E,et,m,s,ut,at,W,Z]),(0,e.useEffect)((function(){et&&T({loading:!1,accountId:null!=rt?rt:null,widgetSrc:E,networkId:et.config.networkId})}),[et,rt,E]),(0,e.useLayoutEffect)((function(){if(B){var t={props:f||{},context:N,reactState:k,cacheNonce:I,version:B.version,forwardedProps:No(No({},h),{},{ref:n})};if(!st(t,$)){z(ct(t));try{var e;it(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){it(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,f,N,k,I,$,n,h]),null!=ot?r().createElement(Po.ErrorBoundary,{FallbackComponent:L,onReset:function(){it(null)},resetKeys:[ot]},r().createElement(r().Fragment,null,ot,M&&r().createElement(Fe,{transactions:M,onHide:function(){return F(null)},networkId:Q}),D&&r().createElement(Rr,{show:!0,widgetSrc:E,data:D.data,force:D.force,onHide:function(){return G(null)},onCommit:D.onCommit,onCancel:D.onCancel,networkId:Q}))):null!=i?i:P}))})(),o})())); \ No newline at end of file From e3178b055ff6a3f421287c2b4caf081ef65a8c48 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Fri, 13 Oct 2023 14:16:32 -0700 Subject: [PATCH 25/25] 2.5.0 release --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5781936f..5faedc9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Pending +## 2.5.0 - Fix `default` case for the switch statement in `VM`. - Add a VM feature, `enableComponentSrcDataKey`, which adds the `data-component` attribute specifying the path of the comonent responsible for rendering the DOM element. diff --git a/package.json b/package.json index 7357f76a..7ab3ebed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "near-social-vm", - "version": "2.4.2", + "version": "2.5.0", "description": "Near Social VM", "main": "dist/index.js", "files": [