text: !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("queue-microtask"),require("@onflow/sdk")):"function"==typeof define&&define.amd?define(["exports","queue-microtask","@onflow/sdk"],r):r((e=e||self).fcl={},e.queueMicrotask,e.sdk)}(this,function(e,r,n){function t(){return(t=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;const i=function(){function e(){}return e.prototype.then=function(r,n){const t=new e,o=this.s;if(o){const e=1&o?r:n;if(e){try{u(t,1,e(this.v))}catch(e){u(t,2,e)}return t}return this}return this.o=function(e){try{const o=e.v;1&e.s?u(t,1,r?r(o):o):n?u(t,1,n(o)):u(t,2,o)}catch(e){u(t,2,e)}},t},e}();function u(e,r,n){if(!e.s){if(n instanceof i){if(!n.s)return void(n.o=u.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(u.bind(null,e,r),u.bind(null,e,2));e.s=r,e.v=n;const t=e.o;t&&t(e)}}function c(e){return e instanceof i&&1&e.s}function s(e,r,n){for(var t;;){var o=e();if(c(o)&&(o=o.v),!o)return s;if(o.then){t=0;break}var s=n();if(s&&s.then){if(!c(s)){t=1;break}s=s.s}if(r){var a=r();if(a&&a.then&&!c(a)){t=2;break}}}var f=new i,l=u.bind(null,f,2);return(0===t?o.then(d):1===t?s.then(v):a.then(h)).then(void 0,l),f;function v(t){s=t;do{if(r&&(a=r())&&a.then&&!c(a))return void a.then(h).then(void 0,l);if(!(o=e())||c(o)&&!o.v)return void u(f,1,s);if(o.then)return void o.then(d).then(void 0,l);c(s=n())&&(s=s.v)}while(!s||!s.then);s.then(v).then(void 0,l)}function d(e){e?(s=n())&&s.then?s.then(v).then(void 0,l):v(s):u(f,1,s)}function h(){(o=e())?o.then?o.then(d).then(void 0,l):d(o):u(f,1,s)}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var a={},f=0,l=function(e,r,n,t){return void 0===t&&(t={}),new Promise(function(o,i){var u=t.expectReply||!1,c=null!=t.timeout?t.timeout:5e3;u&&c&&setTimeout(function(){return i(new Error("Timeout: "+c+"ms passed without a response."))},c);var s={to:e,from:t.from,tag:r,data:n,timeout:c,reply:o,reject:i};try{a[e].mailbox.deliver(s),u||o(!0)}catch(e){console.error("FCL.Actor -- Could Not Deliver Message",s,e)}})},v=function(e,n){if(void 0===n&&(n=null),null==n&&(n=++f),null!=a[n])return n;var t,i;a[n]={addr:n,mailbox:(i=[],{deliver:function(e){try{return i.push(e),t&&(t(i.shift()),t=void 0),Promise.resolve()}catch(e){return Promise.reject(e)}},receive:function(){return new Promise(function(e){var r=i.shift();if(r)return e(r);t=e})}}),subs:new Set,kvs:{}};var u={self:function(){return n},receive:function(){return a[n].mailbox.receive()},send:function(e,r,t,o){return void 0===o&&(o={}),o.from=n,l(e,r,t,o)},broadcast:function(e,r,t){void 0===t&&(t={}),t.from=n;for(var i,u=function(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return o(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,void 0):void 0}}(e)))return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}(a[n].subs);!(i=u()).done;)l(i.value,e,r,t)},subscribe:function(e){return null!=e&&a[n].subs.add(e)},unsubscribe:function(e){return null!=e&&a[n].subs.delete(e)},put:function(e,r){null!=e&&(a[n].kvs[e]=r)},get:function(e,r){var t=a[n].kvs[e];return null==t?r:t},delete:function(e){delete a[n].kvs[e]},update:function(e,r){null!=e&&(a[n].kvs[e]=r(a[n].kvs[e]))},keys:function(){return Object.keys(a[n].kvs)}};return r(function(){try{return Promise.resolve(e(u)).then(function(){!function(e){delete a[e]}(n)})}catch(e){return Promise.reject(e)}}),n},d="config",h="PUT_CONFIG",m="GET_CONFIG",y="CONFIG/UPDATED";v(function(e){try{var r=function(r){return r.reduce(function(r,n){var o;return t({},r,((o={})[n]=e.get(n),o))},{})},n=s(function(){return 1},void 0,function(){return Promise.resolve(e.receive()).then(function(n){var t=n.data;try{switch(n.tag){case h:return void(null!=t.key&&(e.put(t.key,t.value),e.broadcast(y,r(e.keys()))));case m:return void(null!=t.key&&n.reply(e.get(t.key,t.fallback)));case"UPDATE_CONFIG":return void(null!=t.key&&(e.update(t.key,t.fn),e.broadcast(y,r(e.keys()))));case"DELETE_CONFIG":return void(null!=t.key&&(e.delete(t.key),e.broadcast(y,r(e.keys()))));case"WHERE_CONFIG":return void(null!=t.pattern&&n.reply(r(e.keys().filter(function(e){return t.pattern.test(e)}))));case"SUBSCRIBE":return e.subscribe(n.from),void e.send(n.from,y,r(e.keys()));case"UNSUBSCRIBE":return void e.unsubscribe(n.from);default:return}}catch(e){return void console.error("Config Error",n,e)}})});return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},d);var b=function(e){return e},p=function(){return{put:function(e,r){l(d,h,{key:e,value:r})},get:function(e,r){return l(d,m,{key:e,fallback:r},{expectReply:!0,timeout:10})},update:function(e,r){void 0===r&&(r=b),l(d,"UPDATE_CONFIG",{key:e,fn:r})},delete:function(e){l(d,"DELETE_CONFIG",{key:e})},where:function(e){return l(d,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})},subscribe:function(e){var r=v(function(r){try{var n=!1;return r.send(d,"SUBSCRIBE"),Promise.resolve(s(function(){return!n&&1},void 0,function(){return Promise.resolve(r.receive()).then(function(t){if("@EXIT"===t.tag)return r.send(d,"UNSUBSCRIBE"),void(n=!0);e(t.data)})}))}catch(e){return Promise.reject(e)}});return function(){return l(r,"@EXIT")}}}};p().put("accessNode.api","http://localhost:8080");var P,k=function(e){return"https://avatars.onflow.org/avatar/"+e+".svg"},S=function(e,r){return r.reduce(function(r,n){var o;return t({},r,((o={})[n]=e.get(n),o))},{})},E=((P={}).SUBSCRIBE=function(e,r){e.subscribe(r.from),e.send(r.from,"USER/UPDATED",S(e,e.keys()))},P.UNSUBSCRIBE=function(e,r){e.unsubscribe(r.from)},P.SNAPSHOT=function(e,r){try{return r.reply(S(e,e.keys())),Promise.resolve()}catch(e){return Promise.reject(e)}},P),g=function(e){try{return Promise.resolve(function(e){try{return Promise.resolve((void 0===r&&(r=10),new Promise(function(e){return setTimeout(e,r)}))).then(function(){return{acct:e,name:"bob the builder",avatar:k(),bio:"Can he fix it, yes he can.",hooks:{}}})}catch(e){return Promise.reject(e)}var r}(e.self())).then(function(r){!function(e,r){for(var n=0,t=Object.keys(r);n<t.length;n++){var o=t[n];e.put(o,r[o])}}(e,r);var n=s(function(){return 1},void 0,function(){return Promise.resolve(e.receive()).then(function(r){var n=function(n,t){try{var o=function(n,t){try{var o=Promise.resolve(E[r.tag](e,r)).then(function(){})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){console.error("User Error",r,e)})}catch(e){return}return o&&o.then?o.then(t.bind(null,!1),t.bind(null,!0)):void 0}(0,function(e,r){});if(n&&n.then)return n.then(function(){})})});return n&&n.then?n.then(function(){}):void 0})}catch(e){return Promise.reject(e)}},I=function(e){return v(g,e)};e.authenticate=function(){return Promise.resolve()},e.config=p,e.currentUser=function(){return{subscribe:function(e){return function(){}},authorization:function(){return Promise.resolve()},payerAuthorization:function(){return Promise.resolve()},param:function(){return Promise.resolve()}}},e.decode=function(e){return Promise.resolve()},e.event=function(e,r){return{subscribe:function(e){return function(){}}}},e.send=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{var t=function(t){return r.node=t,Array.isArray(e)&&(e=n.build(e)),Promise.resolve(n.pipe(e,[n.resolve([n.resolveParams,n.resolveAuthorizations])])).then(function(e){return n.send(e,r)})},o=r.node;return Promise.resolve(o?t(o):Promise.resolve(p().get("accessNode.api")).then(t))}catch(e){return Promise.reject(e)}},e.transaction=function(e){return{subscribe:function(e){return function(){}}}},e.unauthenticate=function(){return Promise.resolve()},e.user=function(e){return{authorization:function(){try{return I(e),Promise.resolve({acct:e,signFn:function(){try{throw new Error("fcl.user("+e+").payerAuthorization WIP error -- known missing functionality")}catch(e){return Promise.reject(e)}}})}catch(e){return Promise.reject(e)}},payerAuthorization:function(){try{return I(e),Promise.resolve({acct:e,signFn:function(){try{throw new Error("fcl.user("+e+").payerAuthorization WIP error -- known missing functionality")}catch(e){return Promise.reject(e)}}})}catch(e){return Promise.reject(e)}},snapshot:function(){try{return I(e),Promise.resolve(l(e,"SNAPSHOT",null,{expectReply:!0,timeout:0}))}catch(e){return Promise.reject(e)}},param:function(r){return{value:e,xform:{asParam:function(e){return e},asInjection:function(e){return e}}}},subscribe:function(r){I(e);var n=v(function(n){try{var t=!1;return n.send(e,"SUBSCRIBE"),Promise.resolve(s(function(){return!t&&1},void 0,function(){return Promise.resolve(n.receive()).then(function(o){if("@EXIT"===o.tag)return n.send(e,"UNSUBSCRIBE"),void(t=!0);r(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return l(n,"@EXIT")}}}}});
  //# sourceMappingURL=fcl.umd.js.map
  