Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onflow/fcl

Package Overview
Dependencies
Maintainers
12
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/fcl - npm Package Compare versions

Comparing version 0.0.79-alpha.1 to 0.0.79-alpha.2

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 0.0.79-alpha.2 - 2022-01-21
- 2022-01-21 -- [@JeffreyDoyle](https://github.com/JeffreyDoyle): VSN `@onflow/sdk` 0.0.57-alpha.1 -> 0.0.57-alpha.2
## 0.0.79-alpha.1 - 2022-01-21

@@ -2,0 +6,0 @@

2

dist/fcl.js

@@ -1,2 +0,2 @@

var e=require("@onflow/sdk"),n=require("@onflow/util-invariant"),t=require("@onflow/types"),r=require("@onflow/util-actor"),o=require("@onflow/util-address"),i=require("@onflow/rlp"),a=require("@onflow/util-uid"),s=require("@onflow/util-template");function u(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}}),n.default=e,n}var c=u(e),l=u(t),d=u(i),f="0.0.79-alpha.1",p=function(n){try{return Promise.resolve(e.config().where(n)).then(function(e){return Object.fromEntries(Object.entries(e).map(function(e){var t=e[1];return[e[0].replace(n,""),t]}))})}catch(e){return Promise.reject(e)}},h={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};e.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":h});var v=function(e){return function(n){return typeof n===e}},m=function(e){return null!=e},g=v("object"),y=v("string"),P=v("function"),E=v("number");function b(e){return P(e)?e(c.arg,l):[]}var w=function(e){return void 0===e&&(e={}),Promise.resolve(function(e){try{return n.invariant(m(e.cadence),"query({ cadence }) -- cadence is required"),n.invariant(y(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return c.send([c.script(e.cadence),c.args(b(e.args||[])),e.limit&&"number"==typeof e.limit&&c.limit(e.limit)]).then(c.decode)})};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)}function R(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function x(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return R(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?R(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;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.")}var C={f_type:"Service",f_vsn:"1.0.0"},I={f_type:"Identity",f_vsn:"1.0.0"},A={f_type:"USER",f_vsn:"1.0.0"},O={f_type:"PollingResponse",f_vsn:"1.0.0"},j={f_type:"CompositeSignature",f_vsn:"1.0.0"};function D(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({old:e},C,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function N(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function k(e){return null==e?null:(null==e.method&&(e=S({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:S({},C,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var L={"back-channel-rpc":N,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},I,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},I,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:o.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:D,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":k,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return d.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var T=function(e){try{var n=(e=function(e){return e.addr=e.addr?o.withPrefix(e.addr):null,e.paddr=e.paddr?o.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",n),Promise.resolve(fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var t,r=x(e.authorizations);!(t=r()).done;)n.push(S({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&n.push(S({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(t){var r,i,a=(r=n,i=t,void 0===r&&(r=[]),void 0===i&&(i=[]),[].concat(r,i)).map(function(n){return function(e,n){try{return L[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return S({},A,{addr:o.withPrefix(e.addr),cid:F(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function _(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function U(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}return n}function B(e,n){void 0===n&&(n={});var t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(U(e),{method:t,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(function(e){return e.json()})}function V(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:S({},O,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||S({},e)||{},updates:N(e.authorizationUpdates),local:D((e.local||[])[0])})}var M=function e(t,r){void 0===r&&(r=function(){return!0});try{if(n.invariant(t,"Missing Polling Service",{service:t}),!r())throw new Error("Externally Halted");return Promise.resolve(B(t,{method:z(t)}).then(V)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},H={"HTTP/GET":"GET","HTTP/POST":"POST"},z=function(e){return n.invariant(H[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),H[e.method]},W="FCL_IFRAME";function K(e){n.invariant(!document.getElementById(W),"Attempt at triggering multiple Frames",{src:e});var t=document.createElement("iframe");return t.src=e,t.id=W,t.allow="usb *; hid *",t.frameBorder="0",t.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(t),[t.contentWindow,function(){document.getElementById(W)&&document.getElementById(W).remove()}]}var Y=null,q=null;function J(e){var n,t;return null==Y||null!=(n=Y)&&n.closed?(t=window,Y=t.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(t.top.outerHeight/2+t.top.screenY-385)+", left="+(t.top.outerWidth/2+t.top.screenX-320))):q!==e?(Y.location.replace(e),Y.focus()):Y.focus(),q=e,[Y,function(){Y&&!Y.closed&&Y.close(),Y=null}]}var G=null,X=null;function Z(e){var n;return null==G||null!=(n=G)&&n.closed?G=window.open(e,"_blank"):X!==e?(G.location.replace(e),G.focus()):G.focus(),X=e,[G,function(){G&&!G.closed&&G.close(),G=null}]}var $,Q={"VIEW/IFRAME":K,"VIEW/POP":J,"VIEW/TAB":Z},ee=function(e,n,t,r){try{return Promise.resolve(B(e,{data:S({fclVersion:f,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(V)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var t=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(Q[e.method](U(e),n))}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}catch(e){return Promise.reject(e)}}(k(n.local))).then(function(e){var r=e[1],o=function(){try{r(),t=!1}catch(e){console.error("Frame Close Error",e)}};return M(n.updates,function(){return t}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},ne=function(e){return"string"==typeof e&&e.toLowerCase()},te=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),re=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},oe=function(e){var n=e.close,t=e.send,r=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(te.has(e.data.type))return;ne(e.data.type)===ne("FCL:VIEW:CLOSE")&&n(),ne(e.data.type)===ne("FCL:VIEW:READY")&&r(e,{send:t,close:n}),ne(e.data.type)===ne("FCL:VIEW:RESPONSE")&&o(e,{send:t,close:n}),i(e,{send:t,close:n}),ne(e.data.type)===ne("FCL:FRAME:READY")&&(re(e.data.type,"FCL:VIEW:READY"),r(e,{send:t,close:n})),ne(e.data.type)===ne("FCL:FRAME:RESPONSE")&&(re(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:t,close:n})),ne(e.data.type)===ne("FCL:FRAME:CLOSE")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n()),ne(e.data.type)===ne("FCL::CHALLENGE::RESPONSE")&&(re(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:t,close:n})),ne(e.data.type)===ne("FCL::AUTHZ_READY")&&(re(e.data.type,"FCL:VIEW:READY"),r(e,{send:t,close:n})),ne(e.data.type)===ne("FCL::CHALLENGE::CANCEL")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n()),ne(e.data.type)===ne("FCL::CANCEL")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ie=function(){},ae=function(){},se=function(){},ue=function(){},ce=function e(t){var r=t.service,o=t.msg,i=void 0===o?{}:o,a=t.opts,s=void 0===a?{}:a,u=t.config,c=void 0===u?{}:u;try{return Promise.resolve(p(/^service\./)).then(function(t){return Promise.resolve(p(/^app\.detail\./)).then(function(o){var a=S({},c,{services:t,app:o});return function(t,o){try{var u=Promise.resolve(le[r.method](r,i,s,a)).then(function(t){return"REDIRECT"===t.status?(n.invariant(r.type===t.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:t.data,msg:i,opts:s,config:a}))):t})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:r,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},le={"HTTP/RPC":ee,"HTTP/POST":ee,"IFRAME/RPC":function(e,n,t,r){return new Promise(function(o,i){var s,u=a.uid(),c=t.includeOlderJsonRpcCall;n.data=null!=(s=e.data)?s:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ie,close:ie};var t=n.onClose||ie;window.addEventListener("message",oe({close:a,send:s,onReady:n.onReady||ie,onResponse:n.onResponse||ie,onMessage:n.onMessage||ie}));var r=K(U(e)),o=r[0],i=r[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",oe),i(),t()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:f,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:u,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==u)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise(function(o,i){var s=a.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ae,close:ae};var t=n.onClose||ae;window.addEventListener("message",oe({close:s,send:u,onReady:n.onReady||ae,onResponse:n.onResponse||ae,onMessage:n.onMessage||ae}));var r=J(U(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",oe),clearInterval(a),i(),t()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise(function(o,i){var s=a.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:se,close:se};var t=n.onClose||se;window.addEventListener("message",oe({close:s,send:u,onReady:n.onReady||se,onResponse:n.onResponse||se,onMessage:n.onMessage||se}));var r=Z(U(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",oe),clearInterval(a),i(),t()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise(function(t,o){!function(e,n){void 0===n&&(n={});try{var t,r=function(){try{window.removeEventListener("message",oe),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:ue,close:ue});var i=e.endpoint,a=n.onClose||ue;window.addEventListener("message",oe({close:r,send:o,onReady:n.onReady||ue,onResponse:n.onResponse||ue,onMessage:n.onMessage||ue})),Promise.resolve(null==(t=window[i])?void 0:t.flow.enable()).then(function(){return{send:o,close:r}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=V(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},de=function(e,n){try{fe(e,n);var t=n[0].addr,r=[],o=[];return n.map(function(e){r.push(e.signature),o.push(e.keyId)}),Promise.resolve(w({cadence:pe,args:function(n,i){return[n(t,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(r,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},fe=function(e,t){return n.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),n.invariant(Array.isArray(t)&&t.every(function(e,n,t){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),n.invariant(t.map(function(e){return e.addr}).every(function(e,n,t){return e===t[0]}),"User signatures to be verified must be from a single account address"),!0},pe='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function he(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},j,{addr:o.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ve(e,n,t){if(!e.s){if(t instanceof ge){if(!t.s)return void(t.o=ve.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(ve.bind(null,e,n),ve.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var me=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(de(e,n))}catch(e){return Promise.reject(e)}},ge=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{ve(r,1,i(this.v))}catch(e){ve(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ve(r,1,n?n(o):o):t?ve(r,1,t(o)):ve(r,2,o)}catch(e){ve(r,2,e)}},r},e}();function ye(e){return e instanceof ge&&1&e.s}var Pe=function(e){try{return je(),Promise.resolve(Se({redir:!0})).then(function(t){var r=_(t.services,"user-signature");return n.invariant(r,"Current user must have authorized a signing service."),Ee(function(){return Promise.resolve(ce({service:r,msg:Fe(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return he(e)}):[he(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function Ee(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var be=function(){return Promise.resolve(Se()).then(function(n){return e.arg(o.withPrefix(n.addr),l.Address)})},we=function(e){try{return je(),Promise.resolve(S({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Se({redir:!0})).then(function(t){var r;function i(n){if(r)return n;if(a)return S({},e,{tempId:"CURRENT_USER",resolve:null,addr:o.sansPrefix(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(ce({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(he)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=_(t.services,"authz"),s=_(t.services,"pre-authz"),u=function(){if(s)return Promise.resolve(ce({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(var r,o=x(n.payer||[]);!(r=o()).done;)t.push(["PAYER",r.value]);for(var i,a=x(n.authorization||[]);!(i=a()).done;)t.push(["AUTHORIZER",i.value]);return t.map(function(e){var n=e[0],t=e[1];return{tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:function(e){return ce({service:t,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return r=1,n})}();return u&&u.then?u.then(i):i(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Se=function(t){var o=void 0===t?{}:t,i=o.service,a=o.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(t,o){try{return je(),Promise.resolve(ke()).then(function(o){return Promise.resolve(Re()).then(function(a){var u={redir:s};return Promise.resolve(function(){try{return Promise.resolve(e.config.first(["discovery.wallet","challenge.handshake"])).then(function(n){return Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(t){return Promise.resolve(e.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(e){return{type:"authn",endpoint:n,method:e,discoveryAuthnInclude:t}})})})}catch(e){return Promise.reject(e)}}()).then(function(c){var l=_(o.services,"authn-refresh");return Promise.resolve(e.config.get("fcl.warning.suppress.redir")).then(function(e){var d;function f(e){if(d)return e;var n=function(e,n){try{var t=Ee(function(){return Promise.resolve(ce({service:S({},i||c,{method:(null==c?void 0:c.method)||i.method||"IFRAME/RPC"}),msg:a,opts:u,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(T(e)).then(function(e){r.send(xe,Ie,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return t&&t.then?t.then(n.bind(null,!1),n.bind(null,!0)):n(!1,t)}(0,function(e,n){return Promise.resolve(ke()).then(function(r){if(t(r),e)throw n;return n})});return n&&n.then?n.then(function(){}):void 0}s&&!e&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),n.invariant(i||c.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var p=function(){if(o.loggedIn){if(l)return function(e,n){try{var t=Ee(function(){return Promise.resolve(ce({service:l,msg:a,opts:u})).then(function(e){return Promise.resolve(T(e)).then(function(e){r.send(xe,Ie,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(0,function(){return Promise.resolve(ke()).then(function(e){var n=t(e);return d=1,n})});var e=t(o);return d=1,e}}();return p&&p.then?p.then(f):f(p)})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Re=function(){try{var n=Date.now();return Promise.resolve(e.config.get("fcl.appDomainTag")).then(function(e){return{timestamp:n,appDomainTag:e,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},xe="CURRENT_USER",Ce="CURRENT_USER/UPDATED",Ie="SET_CURRENT_USER",Ae='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Oe=(($={})[r.INIT]=function(n){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),n.merge(JSON.parse(Ae)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){var t=function(){if(e.can)return Promise.resolve(function(e){try{var n=JSON.parse(Ae);return Promise.resolve(e.get(xe)).then(function(t){return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(xe),n):t||n})}catch(e){return Promise.reject(e)}}(e)).then(function(e){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(e)&&n.merge(e)})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},$[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,Ce,S({},e.all()))},$[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},$.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},$[Ie]=function(n,t,r){try{return n.merge(r),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(xe,n.all()),n.broadcast(Ce,S({},n.all()))})}catch(e){return Promise.reject(e)}},$.DEL_CURRENT_USER=function(n,t){try{return n.merge(JSON.parse(Ae)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(xe,n.all()),n.broadcast(Ce,S({},n.all()))})}catch(e){return Promise.reject(e)}},$),je=function(){return r.spawn(Oe,xe)};function De(){je(),r.send(xe,"DEL_CURRENT_USER")}function Ne(e){je();var n="@EXIT",t=r.spawn(function(t){try{var o;return t.send(xe,r.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(ye(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!ye(i)){r=1;break}i=i.s}}var a=new ge,s=ve.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):ve(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||ye(o)&&!o.v)return void ve(a,1,i);if(o.then)return void o.then(c).then(void 0,s);ye(i=t())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=t())&&i.then?i.then(u).then(void 0,s):u(i):ve(a,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(t.receive()).then(function(i){if(i.tag===n)return t.send(xe,r.UNSUBSCRIBE),void(o=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return r.send(t,n)}}function ke(){return je(),r.send(xe,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Le,Fe=function(e){return n.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Te=function(){return{authenticate:Se,unauthenticate:De,authorization:we,signUserMessage:Pe,verifyUserSignatures:me,subscribe:Ne,snapshot:ke,resolveArgument:be}};Te.authenticate=Se,Te.unauthenticate=De,Te.authorization=we,Te.signUserMessage=Pe,Te.verifyUserSignatures=me,Te.subscribe=Ne,Te.snapshot=ke,Te.resolveArgument=be;var _e=function(n){try{return Promise.resolve(e.send([e.getTransactionStatus(n)]).then(e.decode))}catch(e){return Promise.reject(e)}},Ue=function(e){return e.status>=4},Be=function(e){return e.status>=3},Ve=function(e){return e.status>=2},Me=((Le={})[r.INIT]=function(e){try{return Promise.resolve(_e(e.self())).then(function(n){Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Le[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,r.UPDATED,e.all())},Le[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Le[r.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Le.POLL=function(e){try{return Promise.resolve(_e(e.self())).then(function(n){var t,o;Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),o=n,JSON.stringify(t)!==JSON.stringify(o)&&e.broadcast(r.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Le),He=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},ze=function(e){return r.spawn(Me,He(e))};function We(e){function n(n){return r.subscriber(He(e),ze,n)}function t(e){return function(t){void 0===t&&(t={});var r=t.suppress||!1;return new Promise(function(t,o){var i=n(function(n){n.statusCode&&!r?(o(n.errorMessage),i()):e(n)&&(t(n),i())})})}}return{snapshot:function(){return r.snapshoter(e,ze)},subscribe:n,onceFinalized:t(Ve),onceExecuted:t(Be),onceSealed:t(Ue)}}We.isUnknown=function(e){return e.status>=0},We.isPending=function(e){return e.status>=1},We.isFinalized=Ve,We.isExecuted=Be,We.isSealed=Ue,We.isExpired=function(e){return 5===e.status};var Ke,Ye=function(n){try{var t=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return t(function(){return n.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},qe=((Ke={}).TICK=function(n){try{if(!n.hasSubs())return Promise.resolve();var t=n.get("hwm"),r=function(){if(null==t){var r=n.put;return Promise.resolve(e.latestBlock()).then(function(e){r.call(n,"hwm",e);var t=n.put;return Promise.resolve(Ye(n)).then(function(e){t.call(n,"tick",e)})})}return Promise.resolve(e.latestBlock()).then(function(r){return n.put("hwm",r),Promise.resolve(e.send([e.getEvents(n.self(),t.height,r.height-1)]).then(e.decode)).then(function(e){for(var t,r=x(e);!(t=r()).done;)n.broadcast("UPDATED",t.value.data);var o=n.put;return Promise.resolve(Ye(n)).then(function(e){o.call(n,"tick",e)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},Ke[r.SUBSCRIBE]=function(e,n){try{var t=function(){e.subscribe(n.from)},r=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Ye(e)).then(function(t){n.call(e,"tick",t)})}}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},Ke[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},Ke),Je=function(e){return r.spawn(qe,e)},Ge=function(t){void 0===t&&(t=[]);try{return Promise.resolve(e.config.get("discovery.authn.endpoint")).then(function(r){return n.invariant(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(e){var n=new URL(r);return fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:f,include:e})}).then(function(e){return e.json()}).then(function(e){return[].concat(t,e)})})})}catch(e){return Promise.reject(e)}};function Xe(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var Ze,$e=((Ze={})[r.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},t=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(Ge,Xe,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,t)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,t},Ze[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",S({},e.all()))},Ze[r.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},Ze.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(S({},e.all())))}catch(e){return Promise.reject(e)}},Ze),Qe=function(){return r.spawn($e,"authn")},en={authn:{subscribe:function(e){return r.subscriber("authn",Qe,e)},snapshot:function(){return r.snapshoter("authn",Qe)}}},nn=function(e,n){void 0===n&&(n=function(){});var t=function(t){var r=t.data;"object"==typeof r&&null!=typeof r&&r.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(r))};return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},tn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(S({},n,{type:e}),"*"):window.opener.postMessage(S({},n,{type:e}),"*")},rn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},on={__proto__:null,sendMsgToFCL:tn,ready:function(e,n){nn("FCL:VIEW:READY:RESPONSE",e),tn("FCL:VIEW:READY")},close:function(){tn("FCL:VIEW:CLOSE")},approve:function(e){tn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){tn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){tn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:nn,encodeMessageFromSignable:e.encodeMessageFromSignable,CompositeSignature:function(e,n,t){this.f_type=j.f_type,this.f_vsn=j.f_vsn,this.addr=o.withPrefix(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:function(e,t,r){void 0===r&&(r=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(t,"Encode Message From Provable Authn Error: timestamp must be defined");var a=rn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=rn(Buffer.from(r).toString("hex"),32).toString("hex");return a+(r?i.encode([s,o.withPrefix(e),t]).toString("hex"):i.encode([o.withPrefix(e),t]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,t,r){void 0===r&&(r=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(t,"Encode Message From Provable Authn Error: timestamp must be defined");var a,s=r?(a=Buffer.from(r).toString("hex"),Buffer.from(a.padEnd(64,0),"hex")).toString("hex"):null;return r?i.encode([s,o.withPrefix(e),t]).toString("hex"):i.encode([o.withPrefix(e),t]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},an=Te().authorization,sn=l;Object.defineProperty(exports,"TestUtils",{enumerable:!0,get:function(){return e.TestUtils}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return e.account}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return e.args}}),Object.defineProperty(exports,"atBlockHeight",{enumerable:!0,get:function(){return e.atBlockHeight}}),Object.defineProperty(exports,"atBlockId",{enumerable:!0,get:function(){return e.atBlockId}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return e.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return e.authorizations}}),Object.defineProperty(exports,"block",{enumerable:!0,get:function(){return e.block}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return e.build}}),Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"createSignableVoucher",{enumerable:!0,get:function(){return e.createSignableVoucher}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return e.decode}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return e.getAccount}}),Object.defineProperty(exports,"getBlock",{enumerable:!0,get:function(){return e.getBlock}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return e.getBlockByHeight}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return e.getBlockById}}),Object.defineProperty(exports,"getBlockHeader",{enumerable:!0,get:function(){return e.getBlockHeader}}),Object.defineProperty(exports,"getCollection",{enumerable:!0,get:function(){return e.getCollection}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return e.getEvents}}),Object.defineProperty(exports,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return e.getEventsAtBlockHeightRange}}),Object.defineProperty(exports,"getEventsAtBlockIds",{enumerable:!0,get:function(){return e.getEventsAtBlockIds}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return e.getLatestBlock}}),Object.defineProperty(exports,"getTransaction",{enumerable:!0,get:function(){return e.getTransaction}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return e.getTransactionStatus}}),Object.defineProperty(exports,"invariant",{enumerable:!0,get:function(){return e.invariant}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return e.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return e.isOk}}),Object.defineProperty(exports,"latestBlock",{enumerable:!0,get:function(){return e.latestBlock}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return e.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return e.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return e.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return e.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return e.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return e.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return e.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return e.script}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return e.send}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return e.transaction}}),Object.defineProperty(exports,"validator",{enumerable:!0,get:function(){return e.validator}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return e.why}}),Object.defineProperty(exports,"display",{enumerable:!0,get:function(){return o.display}}),Object.defineProperty(exports,"sansPrefix",{enumerable:!0,get:function(){return o.sansPrefix}}),Object.defineProperty(exports,"withPrefix",{enumerable:!0,get:function(){return o.withPrefix}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return s.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return s.template}}),exports.VERSION=f,exports.WalletUtils=on,exports.authenticate=function(e){return void 0===e&&(e={}),Te().authenticate(e)},exports.authz=an,exports.currentUser=Te,exports.discovery=en,exports.events=function(e){return{subscribe:function(n){return r.subscriber(e,Je,n)}}},exports.logIn=function(e){return void 0===e&&(e={}),Te().authenticate(e)},exports.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(t,r){try{var o=Promise.resolve(function(e){try{return n.invariant(m(e),"mutate(opts) -- opts is required"),n.invariant(g(e),"mutate(opts) -- opts must be an object"),n.invariant(m(e.cadence),"mutate({ cadence }) -- cadence is required"),n.invariant(y(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(c.config().get("fcl.authz",Te().authorization)).then(function(n){return c.send([c.transaction(e.cadence),c.args(b(e.args||[])),e.limit&&E(e.limit)&&c.limit(e.limit),c.proposer(e.proposer||e.authz||n),c.payer(e.payer||e.authz||n),c.authorizations(e.authorizations||[e.authz||n])]).then(c.decode)})})}catch(e){return r(e)}return o&&o.then?o.then(void 0,r):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},exports.query=w,exports.reauthenticate=function(e){return void 0===e&&(e={}),Te().unauthenticate(),Te().authenticate(e)},exports.serialize=function(n,t){void 0===n&&(n=[]),void 0===t&&(t={});try{return Promise.resolve(e.config.first(["sdk.resolve"],t.resolve||e.resolve)).then(function(t){function r(){return Promise.resolve(t(n)).then(function(n){return JSON.stringify(e.createSignableVoucher(n),null,2)})}var o=function(){if(Array.isArray(n))return Promise.resolve(e.pipe(e.interaction(),n)).then(function(e){n=e})}();return o&&o.then?o.then(r):r()})}catch(e){return Promise.reject(e)}},exports.signUp=function(e){return void 0===e&&(e={}),Te().authenticate(e)},exports.t=sn,exports.tx=We,exports.unauthenticate=function(){return Te().unauthenticate()},exports.verifyUserSignatures=de;
var e=require("@onflow/sdk"),n=require("@onflow/util-invariant"),t=require("@onflow/types"),r=require("@onflow/util-actor"),o=require("@onflow/util-address"),i=require("@onflow/rlp"),a=require("@onflow/util-uid"),s=require("@onflow/util-template");function u(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}}),n.default=e,n}var c=u(e),l=u(t),d=u(i),f="0.0.79-alpha.2",p=function(n){try{return Promise.resolve(e.config().where(n)).then(function(e){return Object.fromEntries(Object.entries(e).map(function(e){var t=e[1];return[e[0].replace(n,""),t]}))})}catch(e){return Promise.reject(e)}},h={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};e.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":h});var v=function(e){return function(n){return typeof n===e}},m=function(e){return null!=e},g=v("object"),y=v("string"),P=v("function"),E=v("number");function b(e){return P(e)?e(c.arg,l):[]}var w=function(e){return void 0===e&&(e={}),Promise.resolve(function(e){try{return n.invariant(m(e.cadence),"query({ cadence }) -- cadence is required"),n.invariant(y(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return c.send([c.script(e.cadence),c.args(b(e.args||[])),e.limit&&"number"==typeof e.limit&&c.limit(e.limit)]).then(c.decode)})};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)}function R(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function x(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return R(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?R(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;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.")}var C={f_type:"Service",f_vsn:"1.0.0"},I={f_type:"Identity",f_vsn:"1.0.0"},A={f_type:"USER",f_vsn:"1.0.0"},O={f_type:"PollingResponse",f_vsn:"1.0.0"},j={f_type:"CompositeSignature",f_vsn:"1.0.0"};function D(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({old:e},C,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function N(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function k(e){return null==e?null:(null==e.method&&(e=S({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:S({},C,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var L={"back-channel-rpc":N,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},I,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},I,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:o.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:D,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":k,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return d.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var T=function(e){try{var n=(e=function(e){return e.addr=e.addr?o.withPrefix(e.addr):null,e.paddr=e.paddr?o.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",n),Promise.resolve(fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var t,r=x(e.authorizations);!(t=r()).done;)n.push(S({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&n.push(S({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(t){var r,i,a=(r=n,i=t,void 0===r&&(r=[]),void 0===i&&(i=[]),[].concat(r,i)).map(function(n){return function(e,n){try{return L[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return S({},A,{addr:o.withPrefix(e.addr),cid:F(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function _(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function U(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}return n}function B(e,n){void 0===n&&(n={});var t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(U(e),{method:t,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(function(e){return e.json()})}function V(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:S({},O,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||S({},e)||{},updates:N(e.authorizationUpdates),local:D((e.local||[])[0])})}var M=function e(t,r){void 0===r&&(r=function(){return!0});try{if(n.invariant(t,"Missing Polling Service",{service:t}),!r())throw new Error("Externally Halted");return Promise.resolve(B(t,{method:z(t)}).then(V)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},H={"HTTP/GET":"GET","HTTP/POST":"POST"},z=function(e){return n.invariant(H[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),H[e.method]},W="FCL_IFRAME";function K(e){n.invariant(!document.getElementById(W),"Attempt at triggering multiple Frames",{src:e});var t=document.createElement("iframe");return t.src=e,t.id=W,t.allow="usb *; hid *",t.frameBorder="0",t.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(t),[t.contentWindow,function(){document.getElementById(W)&&document.getElementById(W).remove()}]}var Y=null,q=null;function J(e){var n,t;return null==Y||null!=(n=Y)&&n.closed?(t=window,Y=t.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(t.top.outerHeight/2+t.top.screenY-385)+", left="+(t.top.outerWidth/2+t.top.screenX-320))):q!==e?(Y.location.replace(e),Y.focus()):Y.focus(),q=e,[Y,function(){Y&&!Y.closed&&Y.close(),Y=null}]}var G=null,X=null;function Z(e){var n;return null==G||null!=(n=G)&&n.closed?G=window.open(e,"_blank"):X!==e?(G.location.replace(e),G.focus()):G.focus(),X=e,[G,function(){G&&!G.closed&&G.close(),G=null}]}var $,Q={"VIEW/IFRAME":K,"VIEW/POP":J,"VIEW/TAB":Z},ee=function(e,n,t,r){try{return Promise.resolve(B(e,{data:S({fclVersion:f,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(V)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var t=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(Q[e.method](U(e),n))}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}catch(e){return Promise.reject(e)}}(k(n.local))).then(function(e){var r=e[1],o=function(){try{r(),t=!1}catch(e){console.error("Frame Close Error",e)}};return M(n.updates,function(){return t}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},ne=function(e){return"string"==typeof e&&e.toLowerCase()},te=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),re=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},oe=function(e){var n=e.close,t=e.send,r=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(te.has(e.data.type))return;ne(e.data.type)===ne("FCL:VIEW:CLOSE")&&n(),ne(e.data.type)===ne("FCL:VIEW:READY")&&r(e,{send:t,close:n}),ne(e.data.type)===ne("FCL:VIEW:RESPONSE")&&o(e,{send:t,close:n}),i(e,{send:t,close:n}),ne(e.data.type)===ne("FCL:FRAME:READY")&&(re(e.data.type,"FCL:VIEW:READY"),r(e,{send:t,close:n})),ne(e.data.type)===ne("FCL:FRAME:RESPONSE")&&(re(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:t,close:n})),ne(e.data.type)===ne("FCL:FRAME:CLOSE")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n()),ne(e.data.type)===ne("FCL::CHALLENGE::RESPONSE")&&(re(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:t,close:n})),ne(e.data.type)===ne("FCL::AUTHZ_READY")&&(re(e.data.type,"FCL:VIEW:READY"),r(e,{send:t,close:n})),ne(e.data.type)===ne("FCL::CHALLENGE::CANCEL")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n()),ne(e.data.type)===ne("FCL::CANCEL")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ie=function(){},ae=function(){},se=function(){},ue=function(){},ce=function e(t){var r=t.service,o=t.msg,i=void 0===o?{}:o,a=t.opts,s=void 0===a?{}:a,u=t.config,c=void 0===u?{}:u;try{return Promise.resolve(p(/^service\./)).then(function(t){return Promise.resolve(p(/^app\.detail\./)).then(function(o){var a=S({},c,{services:t,app:o});return function(t,o){try{var u=Promise.resolve(le[r.method](r,i,s,a)).then(function(t){return"REDIRECT"===t.status?(n.invariant(r.type===t.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:t.data,msg:i,opts:s,config:a}))):t})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:r,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},le={"HTTP/RPC":ee,"HTTP/POST":ee,"IFRAME/RPC":function(e,n,t,r){return new Promise(function(o,i){var s,u=a.uid(),c=t.includeOlderJsonRpcCall;n.data=null!=(s=e.data)?s:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ie,close:ie};var t=n.onClose||ie;window.addEventListener("message",oe({close:a,send:s,onReady:n.onReady||ie,onResponse:n.onResponse||ie,onMessage:n.onMessage||ie}));var r=K(U(e)),o=r[0],i=r[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",oe),i(),t()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:f,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:u,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==u)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise(function(o,i){var s=a.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ae,close:ae};var t=n.onClose||ae;window.addEventListener("message",oe({close:s,send:u,onReady:n.onReady||ae,onResponse:n.onResponse||ae,onMessage:n.onMessage||ae}));var r=J(U(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",oe),clearInterval(a),i(),t()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise(function(o,i){var s=a.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:se,close:se};var t=n.onClose||se;window.addEventListener("message",oe({close:s,send:u,onReady:n.onReady||se,onResponse:n.onResponse||se,onMessage:n.onMessage||se}));var r=Z(U(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",oe),clearInterval(a),i(),t()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise(function(t,o){!function(e,n){void 0===n&&(n={});try{var t,r=function(){try{window.removeEventListener("message",oe),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:ue,close:ue});var i=e.endpoint,a=n.onClose||ue;window.addEventListener("message",oe({close:r,send:o,onReady:n.onReady||ue,onResponse:n.onResponse||ue,onMessage:n.onMessage||ue})),Promise.resolve(null==(t=window[i])?void 0:t.flow.enable()).then(function(){return{send:o,close:r}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=V(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},de=function(e,n){try{fe(e,n);var t=n[0].addr,r=[],o=[];return n.map(function(e){r.push(e.signature),o.push(e.keyId)}),Promise.resolve(w({cadence:pe,args:function(n,i){return[n(t,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(r,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},fe=function(e,t){return n.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),n.invariant(Array.isArray(t)&&t.every(function(e,n,t){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),n.invariant(t.map(function(e){return e.addr}).every(function(e,n,t){return e===t[0]}),"User signatures to be verified must be from a single account address"),!0},pe='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function he(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},j,{addr:o.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ve(e,n,t){if(!e.s){if(t instanceof ge){if(!t.s)return void(t.o=ve.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(ve.bind(null,e,n),ve.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var me=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(de(e,n))}catch(e){return Promise.reject(e)}},ge=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{ve(r,1,i(this.v))}catch(e){ve(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ve(r,1,n?n(o):o):t?ve(r,1,t(o)):ve(r,2,o)}catch(e){ve(r,2,e)}},r},e}();function ye(e){return e instanceof ge&&1&e.s}var Pe=function(e){try{return je(),Promise.resolve(Se({redir:!0})).then(function(t){var r=_(t.services,"user-signature");return n.invariant(r,"Current user must have authorized a signing service."),Ee(function(){return Promise.resolve(ce({service:r,msg:Fe(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return he(e)}):[he(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function Ee(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var be=function(){return Promise.resolve(Se()).then(function(n){return e.arg(o.withPrefix(n.addr),l.Address)})},we=function(e){try{return je(),Promise.resolve(S({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Se({redir:!0})).then(function(t){var r;function i(n){if(r)return n;if(a)return S({},e,{tempId:"CURRENT_USER",resolve:null,addr:o.sansPrefix(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(ce({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(he)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=_(t.services,"authz"),s=_(t.services,"pre-authz"),u=function(){if(s)return Promise.resolve(ce({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(var r,o=x(n.payer||[]);!(r=o()).done;)t.push(["PAYER",r.value]);for(var i,a=x(n.authorization||[]);!(i=a()).done;)t.push(["AUTHORIZER",i.value]);return t.map(function(e){var n=e[0],t=e[1];return{tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:function(e){return ce({service:t,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return r=1,n})}();return u&&u.then?u.then(i):i(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Se=function(t){var o=void 0===t?{}:t,i=o.service,a=o.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(t,o){try{return je(),Promise.resolve(ke()).then(function(o){return Promise.resolve(Re()).then(function(a){var u={redir:s};return Promise.resolve(function(){try{return Promise.resolve(e.config.first(["discovery.wallet","challenge.handshake"])).then(function(n){return Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(t){return Promise.resolve(e.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(e){return{type:"authn",endpoint:n,method:e,discoveryAuthnInclude:t}})})})}catch(e){return Promise.reject(e)}}()).then(function(c){var l=_(o.services,"authn-refresh");return Promise.resolve(e.config.get("fcl.warning.suppress.redir")).then(function(e){var d;function f(e){if(d)return e;var n=function(e,n){try{var t=Ee(function(){return Promise.resolve(ce({service:S({},i||c,{method:(null==c?void 0:c.method)||i.method||"IFRAME/RPC"}),msg:a,opts:u,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(T(e)).then(function(e){r.send(xe,Ie,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return t&&t.then?t.then(n.bind(null,!1),n.bind(null,!0)):n(!1,t)}(0,function(e,n){return Promise.resolve(ke()).then(function(r){if(t(r),e)throw n;return n})});return n&&n.then?n.then(function(){}):void 0}s&&!e&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),n.invariant(i||c.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var p=function(){if(o.loggedIn){if(l)return function(e,n){try{var t=Ee(function(){return Promise.resolve(ce({service:l,msg:a,opts:u})).then(function(e){return Promise.resolve(T(e)).then(function(e){r.send(xe,Ie,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(0,function(){return Promise.resolve(ke()).then(function(e){var n=t(e);return d=1,n})});var e=t(o);return d=1,e}}();return p&&p.then?p.then(f):f(p)})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Re=function(){try{var n=Date.now();return Promise.resolve(e.config.get("fcl.appDomainTag")).then(function(e){return{timestamp:n,appDomainTag:e,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},xe="CURRENT_USER",Ce="CURRENT_USER/UPDATED",Ie="SET_CURRENT_USER",Ae='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Oe=(($={})[r.INIT]=function(n){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),n.merge(JSON.parse(Ae)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){var t=function(){if(e.can)return Promise.resolve(function(e){try{var n=JSON.parse(Ae);return Promise.resolve(e.get(xe)).then(function(t){return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(xe),n):t||n})}catch(e){return Promise.reject(e)}}(e)).then(function(e){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(e)&&n.merge(e)})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},$[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,Ce,S({},e.all()))},$[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},$.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},$[Ie]=function(n,t,r){try{return n.merge(r),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(xe,n.all()),n.broadcast(Ce,S({},n.all()))})}catch(e){return Promise.reject(e)}},$.DEL_CURRENT_USER=function(n,t){try{return n.merge(JSON.parse(Ae)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(xe,n.all()),n.broadcast(Ce,S({},n.all()))})}catch(e){return Promise.reject(e)}},$),je=function(){return r.spawn(Oe,xe)};function De(){je(),r.send(xe,"DEL_CURRENT_USER")}function Ne(e){je();var n="@EXIT",t=r.spawn(function(t){try{var o;return t.send(xe,r.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(ye(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!ye(i)){r=1;break}i=i.s}}var a=new ge,s=ve.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):ve(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||ye(o)&&!o.v)return void ve(a,1,i);if(o.then)return void o.then(c).then(void 0,s);ye(i=t())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=t())&&i.then?i.then(u).then(void 0,s):u(i):ve(a,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(t.receive()).then(function(i){if(i.tag===n)return t.send(xe,r.UNSUBSCRIBE),void(o=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return r.send(t,n)}}function ke(){return je(),r.send(xe,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Le,Fe=function(e){return n.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Te=function(){return{authenticate:Se,unauthenticate:De,authorization:we,signUserMessage:Pe,verifyUserSignatures:me,subscribe:Ne,snapshot:ke,resolveArgument:be}};Te.authenticate=Se,Te.unauthenticate=De,Te.authorization=we,Te.signUserMessage=Pe,Te.verifyUserSignatures=me,Te.subscribe=Ne,Te.snapshot=ke,Te.resolveArgument=be;var _e=function(n){try{return Promise.resolve(e.send([e.getTransactionStatus(n)]).then(e.decode))}catch(e){return Promise.reject(e)}},Ue=function(e){return e.status>=4},Be=function(e){return e.status>=3},Ve=function(e){return e.status>=2},Me=((Le={})[r.INIT]=function(e){try{return Promise.resolve(_e(e.self())).then(function(n){Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Le[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,r.UPDATED,e.all())},Le[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Le[r.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Le.POLL=function(e){try{return Promise.resolve(_e(e.self())).then(function(n){var t,o;Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),o=n,JSON.stringify(t)!==JSON.stringify(o)&&e.broadcast(r.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Le),He=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},ze=function(e){return r.spawn(Me,He(e))};function We(e){function n(n){return r.subscriber(He(e),ze,n)}function t(e){return function(t){void 0===t&&(t={});var r=t.suppress||!1;return new Promise(function(t,o){var i=n(function(n){n.statusCode&&!r?(o(n.errorMessage),i()):e(n)&&(t(n),i())})})}}return{snapshot:function(){return r.snapshoter(e,ze)},subscribe:n,onceFinalized:t(Ve),onceExecuted:t(Be),onceSealed:t(Ue)}}We.isUnknown=function(e){return e.status>=0},We.isPending=function(e){return e.status>=1},We.isFinalized=Ve,We.isExecuted=Be,We.isSealed=Ue,We.isExpired=function(e){return 5===e.status};var Ke,Ye=function(n){try{var t=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return t(function(){return n.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},qe=((Ke={}).TICK=function(n){try{if(!n.hasSubs())return Promise.resolve();var t=n.get("hwm"),r=function(){if(null==t){var r=n.put;return Promise.resolve(e.latestBlock()).then(function(e){r.call(n,"hwm",e);var t=n.put;return Promise.resolve(Ye(n)).then(function(e){t.call(n,"tick",e)})})}return Promise.resolve(e.latestBlock()).then(function(r){return n.put("hwm",r),Promise.resolve(e.send([e.getEvents(n.self(),t.height,r.height-1)]).then(e.decode)).then(function(e){for(var t,r=x(e);!(t=r()).done;)n.broadcast("UPDATED",t.value.data);var o=n.put;return Promise.resolve(Ye(n)).then(function(e){o.call(n,"tick",e)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},Ke[r.SUBSCRIBE]=function(e,n){try{var t=function(){e.subscribe(n.from)},r=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Ye(e)).then(function(t){n.call(e,"tick",t)})}}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},Ke[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},Ke),Je=function(e){return r.spawn(qe,e)},Ge=function(t){void 0===t&&(t=[]);try{return Promise.resolve(e.config.get("discovery.authn.endpoint")).then(function(r){return n.invariant(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(e){var n=new URL(r);return fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:f,include:e})}).then(function(e){return e.json()}).then(function(e){return[].concat(t,e)})})})}catch(e){return Promise.reject(e)}};function Xe(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var Ze,$e=((Ze={})[r.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},t=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(Ge,Xe,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,t)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,t},Ze[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",S({},e.all()))},Ze[r.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},Ze.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(S({},e.all())))}catch(e){return Promise.reject(e)}},Ze),Qe=function(){return r.spawn($e,"authn")},en={authn:{subscribe:function(e){return r.subscriber("authn",Qe,e)},snapshot:function(){return r.snapshoter("authn",Qe)}}},nn=function(e,n){void 0===n&&(n=function(){});var t=function(t){var r=t.data;"object"==typeof r&&null!=typeof r&&r.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(r))};return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},tn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(S({},n,{type:e}),"*"):window.opener.postMessage(S({},n,{type:e}),"*")},rn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},on={__proto__:null,sendMsgToFCL:tn,ready:function(e,n){nn("FCL:VIEW:READY:RESPONSE",e),tn("FCL:VIEW:READY")},close:function(){tn("FCL:VIEW:CLOSE")},approve:function(e){tn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){tn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){tn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:nn,encodeMessageFromSignable:e.encodeMessageFromSignable,CompositeSignature:function(e,n,t){this.f_type=j.f_type,this.f_vsn=j.f_vsn,this.addr=o.withPrefix(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:function(e,t,r){void 0===r&&(r=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(t,"Encode Message From Provable Authn Error: timestamp must be defined");var a=rn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=rn(Buffer.from(r).toString("hex"),32).toString("hex");return a+(r?i.encode([s,o.withPrefix(e),t]).toString("hex"):i.encode([o.withPrefix(e),t]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,t,r){void 0===r&&(r=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(t,"Encode Message From Provable Authn Error: timestamp must be defined");var a,s=r?(a=Buffer.from(r).toString("hex"),Buffer.from(a.padEnd(64,0),"hex")).toString("hex"):null;return r?i.encode([s,o.withPrefix(e),t]).toString("hex"):i.encode([o.withPrefix(e),t]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},an=Te().authorization,sn=l;Object.defineProperty(exports,"TestUtils",{enumerable:!0,get:function(){return e.TestUtils}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return e.account}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return e.args}}),Object.defineProperty(exports,"atBlockHeight",{enumerable:!0,get:function(){return e.atBlockHeight}}),Object.defineProperty(exports,"atBlockId",{enumerable:!0,get:function(){return e.atBlockId}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return e.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return e.authorizations}}),Object.defineProperty(exports,"block",{enumerable:!0,get:function(){return e.block}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return e.build}}),Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"createSignableVoucher",{enumerable:!0,get:function(){return e.createSignableVoucher}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return e.decode}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return e.getAccount}}),Object.defineProperty(exports,"getBlock",{enumerable:!0,get:function(){return e.getBlock}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return e.getBlockByHeight}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return e.getBlockById}}),Object.defineProperty(exports,"getBlockHeader",{enumerable:!0,get:function(){return e.getBlockHeader}}),Object.defineProperty(exports,"getCollection",{enumerable:!0,get:function(){return e.getCollection}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return e.getEvents}}),Object.defineProperty(exports,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return e.getEventsAtBlockHeightRange}}),Object.defineProperty(exports,"getEventsAtBlockIds",{enumerable:!0,get:function(){return e.getEventsAtBlockIds}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return e.getLatestBlock}}),Object.defineProperty(exports,"getTransaction",{enumerable:!0,get:function(){return e.getTransaction}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return e.getTransactionStatus}}),Object.defineProperty(exports,"invariant",{enumerable:!0,get:function(){return e.invariant}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return e.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return e.isOk}}),Object.defineProperty(exports,"latestBlock",{enumerable:!0,get:function(){return e.latestBlock}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return e.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return e.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return e.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return e.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return e.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return e.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return e.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return e.script}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return e.send}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return e.transaction}}),Object.defineProperty(exports,"validator",{enumerable:!0,get:function(){return e.validator}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return e.why}}),Object.defineProperty(exports,"display",{enumerable:!0,get:function(){return o.display}}),Object.defineProperty(exports,"sansPrefix",{enumerable:!0,get:function(){return o.sansPrefix}}),Object.defineProperty(exports,"withPrefix",{enumerable:!0,get:function(){return o.withPrefix}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return s.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return s.template}}),exports.VERSION=f,exports.WalletUtils=on,exports.authenticate=function(e){return void 0===e&&(e={}),Te().authenticate(e)},exports.authz=an,exports.currentUser=Te,exports.discovery=en,exports.events=function(e){return{subscribe:function(n){return r.subscriber(e,Je,n)}}},exports.logIn=function(e){return void 0===e&&(e={}),Te().authenticate(e)},exports.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(t,r){try{var o=Promise.resolve(function(e){try{return n.invariant(m(e),"mutate(opts) -- opts is required"),n.invariant(g(e),"mutate(opts) -- opts must be an object"),n.invariant(m(e.cadence),"mutate({ cadence }) -- cadence is required"),n.invariant(y(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(c.config().get("fcl.authz",Te().authorization)).then(function(n){return c.send([c.transaction(e.cadence),c.args(b(e.args||[])),e.limit&&E(e.limit)&&c.limit(e.limit),c.proposer(e.proposer||e.authz||n),c.payer(e.payer||e.authz||n),c.authorizations(e.authorizations||[e.authz||n])]).then(c.decode)})})}catch(e){return r(e)}return o&&o.then?o.then(void 0,r):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},exports.query=w,exports.reauthenticate=function(e){return void 0===e&&(e={}),Te().unauthenticate(),Te().authenticate(e)},exports.serialize=function(n,t){void 0===n&&(n=[]),void 0===t&&(t={});try{return Promise.resolve(e.config.first(["sdk.resolve"],t.resolve||e.resolve)).then(function(t){function r(){return Promise.resolve(t(n)).then(function(n){return JSON.stringify(e.createSignableVoucher(n),null,2)})}var o=function(){if(Array.isArray(n))return Promise.resolve(e.pipe(e.interaction(),n)).then(function(e){n=e})}();return o&&o.then?o.then(r):r()})}catch(e){return Promise.reject(e)}},exports.signUp=function(e){return void 0===e&&(e={}),Te().authenticate(e)},exports.t=sn,exports.tx=We,exports.unauthenticate=function(){return Te().unauthenticate()},exports.verifyUserSignatures=de;
//# sourceMappingURL=fcl.js.map

@@ -1,2 +0,2 @@

import*as e from"@onflow/sdk";import{config as n,arg as t,send as r,getTransactionStatus as a,decode as s,resolve as o,pipe as i,interaction as c,createSignableVoucher as d,latestBlock as l,getEvents as u,encodeMessageFromSignable as p}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,why}from"@onflow/sdk";import{invariant as f}from"@onflow/util-invariant";import*as y from"@onflow/types";import{spawn as g,send as h,SUBSCRIBE as m,UNSUBSCRIBE as E,INIT as w,subscriber as R,snapshoter as v,UPDATED as S,SNAPSHOT as b}from"@onflow/util-actor";import{withPrefix as C,sansPrefix as A}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as P from"@onflow/rlp";import{encode as I}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";const L="0.0.79-alpha.1",N={can:!("undefined"==typeof window),get:async e=>JSON.parse(sessionStorage.getItem(e)),put:async(e,n)=>sessionStorage.setItem(e,JSON.stringify(n))};async function O(e){return Object.fromEntries(Object.entries(await n().where(e)).map(([n,t])=>[n.replace(e,""),t]))}n({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":N});const k=e=>n=>typeof n===e,F=e=>null!=e,x=k("object"),T=k("string"),_=k("function"),U=k("number");function V(n){return _(n)?n(e.arg,y):[]}async function M(n={}){return await async function(n){f(F(n.cadence),"query({ cadence }) -- cadence is required"),f(T(n.cadence),"query({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(n),e.send([e.script(n.cadence),e.args(V(n.args||[])),n.limit&&"number"==typeof n.limit&&e.limit(n.limit)]).then(e.decode)}function H(){return H=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},H.apply(this,arguments)}const j={f_type:"Service",f_vsn:"1.0.0"},z={f_type:"Identity",f_vsn:"1.0.0"},W={f_type:"USER",f_vsn:"1.0.0"},B={f_type:"PollingResponse",f_vsn:"1.0.0"},K={f_type:"CompositeSignature",f_vsn:"1.0.0"};function Y(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({old:e},j,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function J(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function $(e){return null==e?null:(null==e.method&&(e=H({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:H({},j,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}const q={"back-channel-rpc":J,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:H({},z,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:H({},z,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:C(e.addr),name:e.name,icon:e.icon}})},frame:Y,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":$,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function G(e){return P.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}async function X(e){var n=function(e=[],n=[]){return[...e,...n]}((e=function(e){return e.addr=e.addr?C(e.addr):null,e.paddr=e.paddr?C(e.paddr):null,e}(e)).services||[],await async function(e,n){if(null==e||null==n)return[];const t=new URL(e);t.searchParams.append("code",n);const r=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(r))return r;const a=[];if(Array.isArray(r.authorizations))for(let e of r.authorizations)a.push(H({type:"authz",keyId:r.keyId},e));return null!=r.provider&&a.push(H({type:"authn",id:"wallet-provider#authn"},r.provider)),a}(e.hks,e.code)).map(n=>function(e,n){try{return q[e.type](e,n)}catch(n){return console.error(`Unrecognized FCL Service Type [${e.type}]`,e,n),e}}(n,e));const t=function(e,n){return n.find(e=>"authn"===e.type)}(0,n);return H({},W,{addr:C(e.addr),cid:G(t),loggedIn:!0,services:n,expiresAt:e.expires})}function Z(e=[],n){return e.find(e=>e.type===n)}function Q(e){const n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(let[t,r]of Object.entries(e.params||{}))n.searchParams.append(t,r);return n}function ee(e,n={}){const t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(Q(e),{method:t,headers:H({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(e=>e.json())}function ne(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:H({},B,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||H({},e)||{},updates:J(e.authorizationUpdates),local:Y((e.local||[])[0])})}const te={"HTTP/GET":"GET","HTTP/POST":"POST"},re=e=>(f(te[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),te[e.method]);async function ae(e,n=(()=>!0)){if(f(e,"Missing Polling Service",{service:e}),!n())throw new Error("Externally Halted");const t=await ee(e,{method:re(e)}).then(ne);switch(t.status){case"APPROVED":return t.data;case"DECLINED":throw new Error(`Declined: ${t.reason||"No reason supplied."}`);default:return await new Promise(e=>setTimeout(e,500)),ae(t.updates,n)}}const se="FCL_IFRAME";function oe(e){f(!document.getElementById(se),"Attempt at triggering multiple Frames",{src:e});const n=document.createElement("iframe");return n.src=e,n.id=se,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,()=>{document.getElementById(se)&&document.getElementById(se).remove()}]}let ie=null,ce=null;function de(e){var n,t;return null==ie||null!=(n=ie)&&n.closed?(t=window,ie=t.open(e,"FCL_POP",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top=${t.top.outerHeight/2+t.top.screenY-385}, left=${t.top.outerWidth/2+t.top.screenX-320}`)):ce!==e?(ie.location.replace(e),ie.focus()):ie.focus(),ce=e,[ie,()=>{ie&&!ie.closed&&ie.close(),ie=null}]}let le=null,ue=null;function pe(e){var n;return null==le||null!=(n=le)&&n.closed?le=window.open(e,"_blank"):ue!==e?(le.location.replace(e),le.focus()):le.focus(),ue=e,[le,()=>{le&&!le.closed&&le.close(),le=null}]}const fe={"VIEW/IFRAME":oe,"VIEW/POP":de,"VIEW/TAB":pe};async function ye(e,n,t,r){const a=await ee(e,{data:H({fclVersion:L,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(ne);if("APPROVED"===a.status)return a.data;if("DECLINED"===a.status)throw new Error(`Declined: ${a.reason||"No reason supplied."}`);if("REDIRECT"===a.status)return a;if("PENDING"===a.status){var s=!0;const[e,n]=await async function(e,n={}){try{return fe[e.method](Q(e),n)}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}($(a.local)),t=()=>{try{n(),s=!1}catch(e){console.error("Frame Close Error",e)}};return ae(a.updates,()=>s).then(e=>(t(),e)).catch(e=>{throw console.error(e),t(),e})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:a}),new Error("Auto Decline: Invalid Response")}const ge=e=>"string"==typeof e&&e.toLowerCase(),he=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),me=(e,n)=>console.warn("DEPRECATION NOTICE",`Received ${e}, please use ${n} for this and future versions of FCL`),Ee=({close:e,send:n,onReady:t,onResponse:r,onMessage:a})=>s=>{try{if("object"!=typeof s.data)return;if(he.has(s.data.type))return;ge(s.data.type)===ge("FCL:VIEW:CLOSE")&&e(),ge(s.data.type)===ge("FCL:VIEW:READY")&&t(s,{send:n,close:e}),ge(s.data.type)===ge("FCL:VIEW:RESPONSE")&&r(s,{send:n,close:e}),a(s,{send:n,close:e}),ge(s.data.type)===ge("FCL:FRAME:READY")&&(me(s.data.type,"FCL:VIEW:READY"),t(s,{send:n,close:e})),ge(s.data.type)===ge("FCL:FRAME:RESPONSE")&&(me(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:n,close:e})),ge(s.data.type)===ge("FCL:FRAME:CLOSE")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e()),ge(s.data.type)===ge("FCL::CHALLENGE::RESPONSE")&&(me(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:n,close:e})),ge(s.data.type)===ge("FCL::AUTHZ_READY")&&(me(s.data.type,"FCL:VIEW:READY"),t(s,{send:n,close:e})),ge(s.data.type)===ge("FCL::CHALLENGE::CANCEL")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e()),ge(s.data.type)===ge("FCL::CANCEL")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e())}catch(n){console.error("Frame Callback Error",n),e()}},we=()=>{},Re=()=>{},ve=()=>{},Se=()=>{},be={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,n,t,r){return new Promise((a,s)=>{var o;const i=D(),c=t.includeOlderJsonRpcCall;n.data=null!=(o=e.data)?o:null,function(e,n={}){if(null==e)return{send:we,close:we};const t=n.onClose||we;window.addEventListener("message",Ee({close:s,send:o,onReady:n.onReady||we,onResponse:n.onResponse||we,onMessage:n.onMessage||we}));const[r,a]=oe(Q(e));return{send:o,close:s};function s(){try{window.removeEventListener("message",Ee),a(),t()}catch(e){console.error("Frame Close Error",e)}}function o(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{async onReady(t,{send:a}){try{a({type:"FCL:VIEW:READY:RESPONSE",fclVersion:L,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const t=ne(e.data);switch(t.status){case"APPROVED":a(t.data),n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage(e,{close:n}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;const t=ne(e.data.result);switch(t.status){case"APPROVED":a(t.data),n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise((a,s)=>{const o=D(),{redir:i,includeOlderJsonRpcCall:c}=t;n.data=e.data,function(e,n={}){if(null==e)return{send:Re,close:Re};const t=n.onClose||Re;window.addEventListener("message",Ee({close:o,send:i,onReady:n.onReady||Re,onResponse:n.onResponse||Re,onMessage:n.onMessage||Re}));const[r,a]=de(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",Ee),clearInterval(s),a(),t()}catch(e){console.error("Popup Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{async onReady(t,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const t=ne(e.data);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:n}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const t=ne(e.data.result);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise((a,s)=>{const o=D(),{redir:i,includeOlderJsonRpcCall:c}=t;n.data=e.data,function(e,n={}){if(null==e)return{send:ve,close:ve};const t=n.onClose||ve;window.addEventListener("message",Ee({close:o,send:i,onReady:n.onReady||ve,onResponse:n.onResponse||ve,onMessage:n.onMessage||ve}));const[r,a]=pe(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",Ee),clearInterval(s),a(),t()}catch(e){console.error("Tab Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{async onReady(t,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const t=ne(e.data);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:n}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const t=ne(e.data.result);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise((t,a)=>{!async function(e,n={}){var t;if(null==e)return{send:Se,close:Se};const{endpoint:r}=e,a=n.onClose||Se;window.addEventListener("message",Ee({close:function(){try{window.removeEventListener("message",Ee),a()}catch(e){console.error("Extension Close Error",e)}},send:function(e){try{var n;null==(n=window[r])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}},onReady:n.onReady||Se,onResponse:n.onResponse||Se,onMessage:n.onMessage||Se})),await(null==(t=window[r])?void 0:t.flow.enable())}(e,{async onReady(t,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const r=ne(e.data);switch(r.status){case"APPROVED":t(r.data),n();break;case"DECLINED":a(`Declined: ${r.reason||"No reason supplied"}`),n();break;case"REDIRECT":t(r),n();break;default:a("Declined: No reason supplied"),n()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose(){a("Declined: Externally Halted")}})})}};async function Ce({service:e,msg:n={},opts:t={},config:r={}}){const a=H({},r,{services:await O(/^service\./),app:await O(/^app\.detail\./)});try{const r=await be[e.method](e,n,t,a);return"REDIRECT"===r.status?(f(e.type===r.data.type,"Cannot shift recursive service type in execService"),await Ce({service:r.data,msg:n,opts:t,config:a})):r}catch(a){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",a,{service:e,msg:n,opts:t,config:r}),a}}async function Ae(e,n){((e,n)=>{f(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),f(Array.isArray(n)&&n.every((e,n,t)=>"CompositeSignature"===e.f_type),"Must include an Array of CompositeSignatures to verify"),f(n.map(e=>e.addr).every((e,n,t)=>e===t[0]),"User signatures to be verified must be from a single account address")})(e,n);const t=n[0].addr;let r=[],a=[];return n.map(e=>{r.push(e.signature),a.push(e.keyId)}),await M({cadence:Pe,args:(n,s)=>[n(t,s.Address),n(e,s.String),n(a,s.Array([s.Int])),n(r,s.Array([s.String]))]})}const Pe='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function Ie(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},K,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}const De="CURRENT_USER",Le="CURRENT_USER/UPDATED",Ne='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Oe={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Ne));const t=await n.first(["fcl.storage","fcl.storage.default"]);if(t.can){const n=await(async e=>{const n=JSON.parse(Ne),t=await e.get(De);return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(De),n):t||n})(t);(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)}},[m]:(e,n)=>{e.subscribe(n.from),e.send(n.from,Le,H({},e.all()))},[E]:(e,n)=>{e.unsubscribe(n.from)},SNAPSHOT:async(e,n)=>{n.reply(H({},e.all()))},SET_CURRENT_USER:async(e,t,r)=>{e.merge(r);const a=await n.first(["fcl.storage","fcl.storage.default"]);a.can&&a.put(De,e.all()),e.broadcast(Le,H({},e.all()))},DEL_CURRENT_USER:async(e,t)=>{e.merge(JSON.parse(Ne));const r=await n.first(["fcl.storage","fcl.storage.default"]);r.can&&r.put(De,e.all()),e.broadcast(Le,H({},e.all()))}},ke=()=>g(Oe,De);async function Fe({service:e,redir:t=!1}={}){return new Promise(async(r,a)=>{ke();const s=await Ue(),o=await async function(){return{timestamp:Date.now(),appDomainTag:await n.get("fcl.appDomainTag"),extensions:window.fcl_extensions||[]}}(),i={redir:t},c=await async function(){const e=await n.first(["discovery.wallet","challenge.handshake"]),t=await n.get("discovery.authn.include",[]);return{type:"authn",endpoint:e,method:await n.first(["discovery.wallet.method","discovery.wallet.method.default"]),discoveryAuthnInclude:t}}(),d=Z(s.services,"authn-refresh"),l=await n.get("fcl.warning.suppress.redir");if(t&&!l&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),f(e||c.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),s.loggedIn){if(!d)return r(s);try{const e=await Ce({service:d,msg:o,opts:i});h(De,"SET_CURRENT_USER",await X(e))}catch(e){console.error("Error: Could not refresh authentication.",e)}finally{return r(await Ue())}}try{const n=await Ce({service:H({},e||c,{method:(null==c?void 0:c.method)||e.method||"IFRAME/RPC"}),msg:o,opts:i,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}});h(De,"SET_CURRENT_USER",await X(n))}catch(e){console.error("Error while authenticating",e)}finally{r(await Ue())}})}function xe(){ke(),h(De,"DEL_CURRENT_USER")}async function Te(e){return ke(),H({},e,{tempId:"CURRENT_USER",async resolve(e,n){const t=await Fe({redir:!0}),r=Z(t.services,"authz"),a=Z(t.services,"pre-authz");if(a)return function(e){const n=(e=>({f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}))(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(let e of n.payer||[])t.push(["PAYER",e]);for(let e of n.authorization||[])t.push(["AUTHORIZER",e]);return t.map(([e,n])=>({tempId:[n.identity.address,n.identity.keyId].join("|"),addr:n.identity.address,keyId:n.identity.keyId,signingFunction:e=>Ce({service:n,msg:e}),role:{proposer:"PROPOSER"===e,payer:"PAYER"===e,authorizer:"AUTHORIZER"===e}}))}(await Ce({service:a,msg:n}));if(r)return H({},e,{tempId:"CURRENT_USER",resolve:null,addr:A(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:async e=>Ie(await Ce({service:r,msg:e,opts:{includeOlderJsonRpcCall:!0}}))});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}})}function _e(e){ke();const n="@EXIT",t=g(async t=>{for(t.send(De,m);;){const r=await t.receive();if(r.tag===n)return void t.send(De,E);e(r.data)}});return()=>h(t,n)}function Ue(){return ke(),h(De,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function Ve(){const{addr:e}=await Fe();return t(C(e),y.Address)}const Me=e=>(f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e});async function He(e){ke();const n=Z((await Fe({redir:!0})).services,"user-signature");f(n,"Current user must have authorized a signing service.");try{const t=await Ce({service:n,msg:Me(e)});return Array.isArray(t)?t.map(e=>Ie(e)):[Ie(t)]}catch(e){return e}}async function je(e,n){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Ae(e,n)}let ze=()=>({authenticate:Fe,unauthenticate:xe,authorization:Te,signUserMessage:He,verifyUserSignatures:je,subscribe:_e,snapshot:Ue,resolveArgument:Ve});ze.authenticate=Fe,ze.unauthenticate=xe,ze.authorization=Te,ze.signUserMessage=He,ze.verifyUserSignatures=je,ze.subscribe=_e,ze.snapshot=Ue,ze.resolveArgument=Ve;const We=async e=>r([a(e)]).then(s),Be=e=>e.status>=4,Ke=e=>e.status>=3,Ye=e=>e.status>=2,Je={[w]:async e=>{const n=await We(e.self());Be(n)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(n)},[m]:(e,n)=>{e.subscribe(n.from),e.send(n.from,S,e.all())},[E]:(e,n)=>{e.unsubscribe(n.from)},[b]:async(e,n)=>{n.reply(e.all())},POLL:async e=>{const n=await We(e.self());var t,r;Be(n)||setTimeout(()=>e.sendSelf("POLL"),2500),t=e.all(),r=n,JSON.stringify(t)!==JSON.stringify(r)&&e.broadcast(S,n),e.merge(n)}},$e=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},qe=e=>g(Je,$e(e));function Ge(e){function n(n){return R($e(e),qe,n)}function t(e){return function(t={}){const r=t.suppress||!1;return new Promise((t,a)=>{const s=n(n=>{n.statusCode&&!r?(a(n.errorMessage),s()):e(n)&&(t(n),s())})})}}return{snapshot:function(){return v(e,qe)},subscribe:n,onceFinalized:t(Ye),onceExecuted:t(Ke),onceSealed:t(Be)}}async function Xe(n={}){var t;try{await async function(n){f(F(n),"mutate(opts) -- opts is required"),f(x(n),"mutate(opts) -- opts must be an object"),f(F(n.cadence),"mutate({ cadence }) -- cadence is required"),f(T(n.cadence),"mutate({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(n);const r=await e.config().get("fcl.authz",ze().authorization);return t=e.send([e.transaction(n.cadence),e.args(V(n.args||[])),n.limit&&U(n.limit)&&e.limit(n.limit),e.proposer(n.proposer||n.authz||r),e.payer(n.payer||n.authz||r),e.authorizations(n.authorizations||[n.authz||r])]).then(e.decode),t}catch(e){throw e}}Ge.isUnknown=e=>e.status>=0,Ge.isPending=e=>e.status>=1,Ge.isFinalized=Ye,Ge.isExecuted=Ke,Ge.isSealed=Be,Ge.isExpired=e=>5===e.status;const Ze=async(e=[],t={})=>{const r=await n.first(["sdk.resolve"],t.resolve||o);return Array.isArray(e)&&(e=await i(c(),e)),JSON.stringify(d(await r(e)),null,2)},Qe=async e=>setTimeout(()=>e.sendSelf("TICK"),await n().get("fcl.eventPollRate",1e4)),en={TICK:async e=>{if(!e.hasSubs())return;let n=e.get("hwm");if(null==n)e.put("hwm",await l()),e.put("tick",await Qe(e));else{let t=await l();e.put("hwm",t);const a=await r([u(e.self(),n.height,t.height-1)]).then(s);for(let n of a)e.broadcast("UPDATED",n.data);e.put("tick",await Qe(e))}},[m]:async(e,n)=>{e.hasSubs()||e.put("tick",await Qe(e)),e.subscribe(n.from)},[E]:(e,n)=>{e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},nn=e=>g(en,e);function tn(e){return{subscribe:n=>R(e,nn,n)}}async function rn(e=[]){const t=await n.get("discovery.authn.endpoint");f(Boolean(t),'"discovery.authn.endpoint" in config must be defined.');const r=await n.get("discovery.authn.include",[]),a=new URL(t);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:L,include:r})}).then(e=>e.json()).then(n=>[...e,...n])}function an(e=[]){return[...window.fcl_extensions||[],...e]}const sn={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;");const n=await(({type:e})=>((...e)=>n=>e.reduce((e,n)=>e.then(n),Promise.resolve(n)))(rn,an,n=>function(e=[],n){return e.filter(e=>e.type===n)}(n,e))([]))({type:"authn"});e.put("results",n)},[m]:(e,n)=>{e.subscribe(n.from),e.send(n.from,"UPDATED",H({},e.all()))},[E]:(e,n)=>e.unsubscribe(n.from),SNAPSHOT:async(e,n)=>n.reply(H({},e.all()))},on=()=>g(sn,"authn"),cn={authn:{subscribe:e=>R("authn",on,e),snapshot:()=>v("authn",on)}},dn=(e,n=(()=>{}))=>{const t=t=>{const{data:r}=t;"object"==typeof r&&null!=typeof r&&r.type===e&&n((e=>{var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e})(r))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},ln=(e,n={})=>{window.location!==window.parent.location?window.parent.postMessage(H({},n,{type:e}),"*"):window.opener.postMessage(H({},n,{type:e}),"*")},un=(e,n)=>Buffer.from(e.padEnd(2*n,0),"hex");var pn={__proto__:null,sendMsgToFCL:ln,ready:(e,n={})=>{dn("FCL:VIEW:READY:RESPONSE",e),ln("FCL:VIEW:READY")},close:()=>{ln("FCL:VIEW:CLOSE")},approve:e=>{ln("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:e=>{ln("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:e=>{ln("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:dn,encodeMessageFromSignable:p,CompositeSignature:function(e,n,t){this.f_type=K.f_type,this.f_vsn=K.f_vsn,this.addr=C(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:(e,n,t="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(n,"Encode Message From Provable Authn Error: timestamp must be defined");const r=un(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),a=un(Buffer.from(t).toString("hex"),32).toString("hex");return r+(t?I([a,C(e),n]).toString("hex"):I([C(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:(e,n,t="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(n,"Encode Message From Provable Authn Error: timestamp must be defined");const r=t?(a=Buffer.from(t).toString("hex"),Buffer.from(a.padEnd(64,0),"hex")).toString("hex"):null;var a;return t?I([r,C(e),n]).toString("hex"):I([C(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}};const fn=(e={})=>ze().authenticate(e),yn=()=>ze().unauthenticate(),gn=(e={})=>(ze().unauthenticate(),ze().authenticate(e)),hn=(e={})=>ze().authenticate(e),mn=(e={})=>ze().authenticate(e),En=ze().authorization,wn=y;export{L as VERSION,pn as WalletUtils,fn as authenticate,En as authz,ze as currentUser,cn as discovery,tn as events,mn as logIn,Xe as mutate,M as query,gn as reauthenticate,Ze as serialize,hn as signUp,wn as t,Ge as tx,yn as unauthenticate,Ae as verifyUserSignatures};
import*as e from"@onflow/sdk";import{config as n,arg as t,send as r,getTransactionStatus as a,decode as s,resolve as o,pipe as i,interaction as c,createSignableVoucher as d,latestBlock as l,getEvents as u,encodeMessageFromSignable as p}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,why}from"@onflow/sdk";import{invariant as f}from"@onflow/util-invariant";import*as y from"@onflow/types";import{spawn as g,send as h,SUBSCRIBE as m,UNSUBSCRIBE as E,INIT as w,subscriber as R,snapshoter as v,UPDATED as S,SNAPSHOT as b}from"@onflow/util-actor";import{withPrefix as C,sansPrefix as A}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as P from"@onflow/rlp";import{encode as I}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";const L="0.0.79-alpha.2",N={can:!("undefined"==typeof window),get:async e=>JSON.parse(sessionStorage.getItem(e)),put:async(e,n)=>sessionStorage.setItem(e,JSON.stringify(n))};async function O(e){return Object.fromEntries(Object.entries(await n().where(e)).map(([n,t])=>[n.replace(e,""),t]))}n({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":N});const k=e=>n=>typeof n===e,F=e=>null!=e,x=k("object"),T=k("string"),_=k("function"),U=k("number");function V(n){return _(n)?n(e.arg,y):[]}async function M(n={}){return await async function(n){f(F(n.cadence),"query({ cadence }) -- cadence is required"),f(T(n.cadence),"query({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(n),e.send([e.script(n.cadence),e.args(V(n.args||[])),n.limit&&"number"==typeof n.limit&&e.limit(n.limit)]).then(e.decode)}function H(){return H=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},H.apply(this,arguments)}const j={f_type:"Service",f_vsn:"1.0.0"},z={f_type:"Identity",f_vsn:"1.0.0"},W={f_type:"USER",f_vsn:"1.0.0"},B={f_type:"PollingResponse",f_vsn:"1.0.0"},K={f_type:"CompositeSignature",f_vsn:"1.0.0"};function Y(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({old:e},j,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function J(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function $(e){return null==e?null:(null==e.method&&(e=H({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:H({},j,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}const q={"back-channel-rpc":J,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:H({},z,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:H({},z,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:C(e.addr),name:e.name,icon:e.icon}})},frame:Y,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":$,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function G(e){return P.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}async function X(e){var n=function(e=[],n=[]){return[...e,...n]}((e=function(e){return e.addr=e.addr?C(e.addr):null,e.paddr=e.paddr?C(e.paddr):null,e}(e)).services||[],await async function(e,n){if(null==e||null==n)return[];const t=new URL(e);t.searchParams.append("code",n);const r=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(r))return r;const a=[];if(Array.isArray(r.authorizations))for(let e of r.authorizations)a.push(H({type:"authz",keyId:r.keyId},e));return null!=r.provider&&a.push(H({type:"authn",id:"wallet-provider#authn"},r.provider)),a}(e.hks,e.code)).map(n=>function(e,n){try{return q[e.type](e,n)}catch(n){return console.error(`Unrecognized FCL Service Type [${e.type}]`,e,n),e}}(n,e));const t=function(e,n){return n.find(e=>"authn"===e.type)}(0,n);return H({},W,{addr:C(e.addr),cid:G(t),loggedIn:!0,services:n,expiresAt:e.expires})}function Z(e=[],n){return e.find(e=>e.type===n)}function Q(e){const n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(let[t,r]of Object.entries(e.params||{}))n.searchParams.append(t,r);return n}function ee(e,n={}){const t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(Q(e),{method:t,headers:H({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(e=>e.json())}function ne(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:H({},B,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||H({},e)||{},updates:J(e.authorizationUpdates),local:Y((e.local||[])[0])})}const te={"HTTP/GET":"GET","HTTP/POST":"POST"},re=e=>(f(te[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),te[e.method]);async function ae(e,n=(()=>!0)){if(f(e,"Missing Polling Service",{service:e}),!n())throw new Error("Externally Halted");const t=await ee(e,{method:re(e)}).then(ne);switch(t.status){case"APPROVED":return t.data;case"DECLINED":throw new Error(`Declined: ${t.reason||"No reason supplied."}`);default:return await new Promise(e=>setTimeout(e,500)),ae(t.updates,n)}}const se="FCL_IFRAME";function oe(e){f(!document.getElementById(se),"Attempt at triggering multiple Frames",{src:e});const n=document.createElement("iframe");return n.src=e,n.id=se,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,()=>{document.getElementById(se)&&document.getElementById(se).remove()}]}let ie=null,ce=null;function de(e){var n,t;return null==ie||null!=(n=ie)&&n.closed?(t=window,ie=t.open(e,"FCL_POP",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top=${t.top.outerHeight/2+t.top.screenY-385}, left=${t.top.outerWidth/2+t.top.screenX-320}`)):ce!==e?(ie.location.replace(e),ie.focus()):ie.focus(),ce=e,[ie,()=>{ie&&!ie.closed&&ie.close(),ie=null}]}let le=null,ue=null;function pe(e){var n;return null==le||null!=(n=le)&&n.closed?le=window.open(e,"_blank"):ue!==e?(le.location.replace(e),le.focus()):le.focus(),ue=e,[le,()=>{le&&!le.closed&&le.close(),le=null}]}const fe={"VIEW/IFRAME":oe,"VIEW/POP":de,"VIEW/TAB":pe};async function ye(e,n,t,r){const a=await ee(e,{data:H({fclVersion:L,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(ne);if("APPROVED"===a.status)return a.data;if("DECLINED"===a.status)throw new Error(`Declined: ${a.reason||"No reason supplied."}`);if("REDIRECT"===a.status)return a;if("PENDING"===a.status){var s=!0;const[e,n]=await async function(e,n={}){try{return fe[e.method](Q(e),n)}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}($(a.local)),t=()=>{try{n(),s=!1}catch(e){console.error("Frame Close Error",e)}};return ae(a.updates,()=>s).then(e=>(t(),e)).catch(e=>{throw console.error(e),t(),e})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:a}),new Error("Auto Decline: Invalid Response")}const ge=e=>"string"==typeof e&&e.toLowerCase(),he=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),me=(e,n)=>console.warn("DEPRECATION NOTICE",`Received ${e}, please use ${n} for this and future versions of FCL`),Ee=({close:e,send:n,onReady:t,onResponse:r,onMessage:a})=>s=>{try{if("object"!=typeof s.data)return;if(he.has(s.data.type))return;ge(s.data.type)===ge("FCL:VIEW:CLOSE")&&e(),ge(s.data.type)===ge("FCL:VIEW:READY")&&t(s,{send:n,close:e}),ge(s.data.type)===ge("FCL:VIEW:RESPONSE")&&r(s,{send:n,close:e}),a(s,{send:n,close:e}),ge(s.data.type)===ge("FCL:FRAME:READY")&&(me(s.data.type,"FCL:VIEW:READY"),t(s,{send:n,close:e})),ge(s.data.type)===ge("FCL:FRAME:RESPONSE")&&(me(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:n,close:e})),ge(s.data.type)===ge("FCL:FRAME:CLOSE")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e()),ge(s.data.type)===ge("FCL::CHALLENGE::RESPONSE")&&(me(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:n,close:e})),ge(s.data.type)===ge("FCL::AUTHZ_READY")&&(me(s.data.type,"FCL:VIEW:READY"),t(s,{send:n,close:e})),ge(s.data.type)===ge("FCL::CHALLENGE::CANCEL")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e()),ge(s.data.type)===ge("FCL::CANCEL")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e())}catch(n){console.error("Frame Callback Error",n),e()}},we=()=>{},Re=()=>{},ve=()=>{},Se=()=>{},be={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,n,t,r){return new Promise((a,s)=>{var o;const i=D(),c=t.includeOlderJsonRpcCall;n.data=null!=(o=e.data)?o:null,function(e,n={}){if(null==e)return{send:we,close:we};const t=n.onClose||we;window.addEventListener("message",Ee({close:s,send:o,onReady:n.onReady||we,onResponse:n.onResponse||we,onMessage:n.onMessage||we}));const[r,a]=oe(Q(e));return{send:o,close:s};function s(){try{window.removeEventListener("message",Ee),a(),t()}catch(e){console.error("Frame Close Error",e)}}function o(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{async onReady(t,{send:a}){try{a({type:"FCL:VIEW:READY:RESPONSE",fclVersion:L,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const t=ne(e.data);switch(t.status){case"APPROVED":a(t.data),n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage(e,{close:n}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;const t=ne(e.data.result);switch(t.status){case"APPROVED":a(t.data),n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise((a,s)=>{const o=D(),{redir:i,includeOlderJsonRpcCall:c}=t;n.data=e.data,function(e,n={}){if(null==e)return{send:Re,close:Re};const t=n.onClose||Re;window.addEventListener("message",Ee({close:o,send:i,onReady:n.onReady||Re,onResponse:n.onResponse||Re,onMessage:n.onMessage||Re}));const[r,a]=de(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",Ee),clearInterval(s),a(),t()}catch(e){console.error("Popup Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{async onReady(t,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const t=ne(e.data);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:n}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const t=ne(e.data.result);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise((a,s)=>{const o=D(),{redir:i,includeOlderJsonRpcCall:c}=t;n.data=e.data,function(e,n={}){if(null==e)return{send:ve,close:ve};const t=n.onClose||ve;window.addEventListener("message",Ee({close:o,send:i,onReady:n.onReady||ve,onResponse:n.onResponse||ve,onMessage:n.onMessage||ve}));const[r,a]=pe(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",Ee),clearInterval(s),a(),t()}catch(e){console.error("Tab Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{async onReady(t,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const t=ne(e.data);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:n}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const t=ne(e.data.result);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise((t,a)=>{!async function(e,n={}){var t;if(null==e)return{send:Se,close:Se};const{endpoint:r}=e,a=n.onClose||Se;window.addEventListener("message",Ee({close:function(){try{window.removeEventListener("message",Ee),a()}catch(e){console.error("Extension Close Error",e)}},send:function(e){try{var n;null==(n=window[r])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}},onReady:n.onReady||Se,onResponse:n.onResponse||Se,onMessage:n.onMessage||Se})),await(null==(t=window[r])?void 0:t.flow.enable())}(e,{async onReady(t,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const r=ne(e.data);switch(r.status){case"APPROVED":t(r.data),n();break;case"DECLINED":a(`Declined: ${r.reason||"No reason supplied"}`),n();break;case"REDIRECT":t(r),n();break;default:a("Declined: No reason supplied"),n()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose(){a("Declined: Externally Halted")}})})}};async function Ce({service:e,msg:n={},opts:t={},config:r={}}){const a=H({},r,{services:await O(/^service\./),app:await O(/^app\.detail\./)});try{const r=await be[e.method](e,n,t,a);return"REDIRECT"===r.status?(f(e.type===r.data.type,"Cannot shift recursive service type in execService"),await Ce({service:r.data,msg:n,opts:t,config:a})):r}catch(a){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",a,{service:e,msg:n,opts:t,config:r}),a}}async function Ae(e,n){((e,n)=>{f(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),f(Array.isArray(n)&&n.every((e,n,t)=>"CompositeSignature"===e.f_type),"Must include an Array of CompositeSignatures to verify"),f(n.map(e=>e.addr).every((e,n,t)=>e===t[0]),"User signatures to be verified must be from a single account address")})(e,n);const t=n[0].addr;let r=[],a=[];return n.map(e=>{r.push(e.signature),a.push(e.keyId)}),await M({cadence:Pe,args:(n,s)=>[n(t,s.Address),n(e,s.String),n(a,s.Array([s.Int])),n(r,s.Array([s.String]))]})}const Pe='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function Ie(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},K,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}const De="CURRENT_USER",Le="CURRENT_USER/UPDATED",Ne='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Oe={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Ne));const t=await n.first(["fcl.storage","fcl.storage.default"]);if(t.can){const n=await(async e=>{const n=JSON.parse(Ne),t=await e.get(De);return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(De),n):t||n})(t);(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)}},[m]:(e,n)=>{e.subscribe(n.from),e.send(n.from,Le,H({},e.all()))},[E]:(e,n)=>{e.unsubscribe(n.from)},SNAPSHOT:async(e,n)=>{n.reply(H({},e.all()))},SET_CURRENT_USER:async(e,t,r)=>{e.merge(r);const a=await n.first(["fcl.storage","fcl.storage.default"]);a.can&&a.put(De,e.all()),e.broadcast(Le,H({},e.all()))},DEL_CURRENT_USER:async(e,t)=>{e.merge(JSON.parse(Ne));const r=await n.first(["fcl.storage","fcl.storage.default"]);r.can&&r.put(De,e.all()),e.broadcast(Le,H({},e.all()))}},ke=()=>g(Oe,De);async function Fe({service:e,redir:t=!1}={}){return new Promise(async(r,a)=>{ke();const s=await Ue(),o=await async function(){return{timestamp:Date.now(),appDomainTag:await n.get("fcl.appDomainTag"),extensions:window.fcl_extensions||[]}}(),i={redir:t},c=await async function(){const e=await n.first(["discovery.wallet","challenge.handshake"]),t=await n.get("discovery.authn.include",[]);return{type:"authn",endpoint:e,method:await n.first(["discovery.wallet.method","discovery.wallet.method.default"]),discoveryAuthnInclude:t}}(),d=Z(s.services,"authn-refresh"),l=await n.get("fcl.warning.suppress.redir");if(t&&!l&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),f(e||c.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),s.loggedIn){if(!d)return r(s);try{const e=await Ce({service:d,msg:o,opts:i});h(De,"SET_CURRENT_USER",await X(e))}catch(e){console.error("Error: Could not refresh authentication.",e)}finally{return r(await Ue())}}try{const n=await Ce({service:H({},e||c,{method:(null==c?void 0:c.method)||e.method||"IFRAME/RPC"}),msg:o,opts:i,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}});h(De,"SET_CURRENT_USER",await X(n))}catch(e){console.error("Error while authenticating",e)}finally{r(await Ue())}})}function xe(){ke(),h(De,"DEL_CURRENT_USER")}async function Te(e){return ke(),H({},e,{tempId:"CURRENT_USER",async resolve(e,n){const t=await Fe({redir:!0}),r=Z(t.services,"authz"),a=Z(t.services,"pre-authz");if(a)return function(e){const n=(e=>({f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}))(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(let e of n.payer||[])t.push(["PAYER",e]);for(let e of n.authorization||[])t.push(["AUTHORIZER",e]);return t.map(([e,n])=>({tempId:[n.identity.address,n.identity.keyId].join("|"),addr:n.identity.address,keyId:n.identity.keyId,signingFunction:e=>Ce({service:n,msg:e}),role:{proposer:"PROPOSER"===e,payer:"PAYER"===e,authorizer:"AUTHORIZER"===e}}))}(await Ce({service:a,msg:n}));if(r)return H({},e,{tempId:"CURRENT_USER",resolve:null,addr:A(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:async e=>Ie(await Ce({service:r,msg:e,opts:{includeOlderJsonRpcCall:!0}}))});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}})}function _e(e){ke();const n="@EXIT",t=g(async t=>{for(t.send(De,m);;){const r=await t.receive();if(r.tag===n)return void t.send(De,E);e(r.data)}});return()=>h(t,n)}function Ue(){return ke(),h(De,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function Ve(){const{addr:e}=await Fe();return t(C(e),y.Address)}const Me=e=>(f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e});async function He(e){ke();const n=Z((await Fe({redir:!0})).services,"user-signature");f(n,"Current user must have authorized a signing service.");try{const t=await Ce({service:n,msg:Me(e)});return Array.isArray(t)?t.map(e=>Ie(e)):[Ie(t)]}catch(e){return e}}async function je(e,n){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Ae(e,n)}let ze=()=>({authenticate:Fe,unauthenticate:xe,authorization:Te,signUserMessage:He,verifyUserSignatures:je,subscribe:_e,snapshot:Ue,resolveArgument:Ve});ze.authenticate=Fe,ze.unauthenticate=xe,ze.authorization=Te,ze.signUserMessage=He,ze.verifyUserSignatures=je,ze.subscribe=_e,ze.snapshot=Ue,ze.resolveArgument=Ve;const We=async e=>r([a(e)]).then(s),Be=e=>e.status>=4,Ke=e=>e.status>=3,Ye=e=>e.status>=2,Je={[w]:async e=>{const n=await We(e.self());Be(n)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(n)},[m]:(e,n)=>{e.subscribe(n.from),e.send(n.from,S,e.all())},[E]:(e,n)=>{e.unsubscribe(n.from)},[b]:async(e,n)=>{n.reply(e.all())},POLL:async e=>{const n=await We(e.self());var t,r;Be(n)||setTimeout(()=>e.sendSelf("POLL"),2500),t=e.all(),r=n,JSON.stringify(t)!==JSON.stringify(r)&&e.broadcast(S,n),e.merge(n)}},$e=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},qe=e=>g(Je,$e(e));function Ge(e){function n(n){return R($e(e),qe,n)}function t(e){return function(t={}){const r=t.suppress||!1;return new Promise((t,a)=>{const s=n(n=>{n.statusCode&&!r?(a(n.errorMessage),s()):e(n)&&(t(n),s())})})}}return{snapshot:function(){return v(e,qe)},subscribe:n,onceFinalized:t(Ye),onceExecuted:t(Ke),onceSealed:t(Be)}}async function Xe(n={}){var t;try{await async function(n){f(F(n),"mutate(opts) -- opts is required"),f(x(n),"mutate(opts) -- opts must be an object"),f(F(n.cadence),"mutate({ cadence }) -- cadence is required"),f(T(n.cadence),"mutate({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(n);const r=await e.config().get("fcl.authz",ze().authorization);return t=e.send([e.transaction(n.cadence),e.args(V(n.args||[])),n.limit&&U(n.limit)&&e.limit(n.limit),e.proposer(n.proposer||n.authz||r),e.payer(n.payer||n.authz||r),e.authorizations(n.authorizations||[n.authz||r])]).then(e.decode),t}catch(e){throw e}}Ge.isUnknown=e=>e.status>=0,Ge.isPending=e=>e.status>=1,Ge.isFinalized=Ye,Ge.isExecuted=Ke,Ge.isSealed=Be,Ge.isExpired=e=>5===e.status;const Ze=async(e=[],t={})=>{const r=await n.first(["sdk.resolve"],t.resolve||o);return Array.isArray(e)&&(e=await i(c(),e)),JSON.stringify(d(await r(e)),null,2)},Qe=async e=>setTimeout(()=>e.sendSelf("TICK"),await n().get("fcl.eventPollRate",1e4)),en={TICK:async e=>{if(!e.hasSubs())return;let n=e.get("hwm");if(null==n)e.put("hwm",await l()),e.put("tick",await Qe(e));else{let t=await l();e.put("hwm",t);const a=await r([u(e.self(),n.height,t.height-1)]).then(s);for(let n of a)e.broadcast("UPDATED",n.data);e.put("tick",await Qe(e))}},[m]:async(e,n)=>{e.hasSubs()||e.put("tick",await Qe(e)),e.subscribe(n.from)},[E]:(e,n)=>{e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},nn=e=>g(en,e);function tn(e){return{subscribe:n=>R(e,nn,n)}}async function rn(e=[]){const t=await n.get("discovery.authn.endpoint");f(Boolean(t),'"discovery.authn.endpoint" in config must be defined.');const r=await n.get("discovery.authn.include",[]),a=new URL(t);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:L,include:r})}).then(e=>e.json()).then(n=>[...e,...n])}function an(e=[]){return[...window.fcl_extensions||[],...e]}const sn={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;");const n=await(({type:e})=>((...e)=>n=>e.reduce((e,n)=>e.then(n),Promise.resolve(n)))(rn,an,n=>function(e=[],n){return e.filter(e=>e.type===n)}(n,e))([]))({type:"authn"});e.put("results",n)},[m]:(e,n)=>{e.subscribe(n.from),e.send(n.from,"UPDATED",H({},e.all()))},[E]:(e,n)=>e.unsubscribe(n.from),SNAPSHOT:async(e,n)=>n.reply(H({},e.all()))},on=()=>g(sn,"authn"),cn={authn:{subscribe:e=>R("authn",on,e),snapshot:()=>v("authn",on)}},dn=(e,n=(()=>{}))=>{const t=t=>{const{data:r}=t;"object"==typeof r&&null!=typeof r&&r.type===e&&n((e=>{var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e})(r))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},ln=(e,n={})=>{window.location!==window.parent.location?window.parent.postMessage(H({},n,{type:e}),"*"):window.opener.postMessage(H({},n,{type:e}),"*")},un=(e,n)=>Buffer.from(e.padEnd(2*n,0),"hex");var pn={__proto__:null,sendMsgToFCL:ln,ready:(e,n={})=>{dn("FCL:VIEW:READY:RESPONSE",e),ln("FCL:VIEW:READY")},close:()=>{ln("FCL:VIEW:CLOSE")},approve:e=>{ln("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:e=>{ln("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:e=>{ln("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:dn,encodeMessageFromSignable:p,CompositeSignature:function(e,n,t){this.f_type=K.f_type,this.f_vsn=K.f_vsn,this.addr=C(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:(e,n,t="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(n,"Encode Message From Provable Authn Error: timestamp must be defined");const r=un(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),a=un(Buffer.from(t).toString("hex"),32).toString("hex");return r+(t?I([a,C(e),n]).toString("hex"):I([C(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:(e,n,t="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(n,"Encode Message From Provable Authn Error: timestamp must be defined");const r=t?(a=Buffer.from(t).toString("hex"),Buffer.from(a.padEnd(64,0),"hex")).toString("hex"):null;var a;return t?I([r,C(e),n]).toString("hex"):I([C(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}};const fn=(e={})=>ze().authenticate(e),yn=()=>ze().unauthenticate(),gn=(e={})=>(ze().unauthenticate(),ze().authenticate(e)),hn=(e={})=>ze().authenticate(e),mn=(e={})=>ze().authenticate(e),En=ze().authorization,wn=y;export{L as VERSION,pn as WalletUtils,fn as authenticate,En as authz,ze as currentUser,cn as discovery,tn as events,mn as logIn,Xe as mutate,M as query,gn as reauthenticate,Ze as serialize,hn as signUp,wn as t,Ge as tx,yn as unauthenticate,Ae as verifyUserSignatures};
//# sourceMappingURL=fcl.modern.js.map

@@ -1,2 +0,2 @@

import*as e from"@onflow/sdk";import{config as n,arg as r,send as t,getTransactionStatus as o,decode as i,resolve as s,createSignableVoucher as a,pipe as c,interaction as u,latestBlock as l,getEvents as d,encodeMessageFromSignable as f}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,why}from"@onflow/sdk";import{invariant as p}from"@onflow/util-invariant";import*as h from"@onflow/types";import{INIT as v,SUBSCRIBE as m,UNSUBSCRIBE as y,spawn as g,send as E,UPDATED as P,SNAPSHOT as w,subscriber as R,snapshoter as S}from"@onflow/util-actor";import{withPrefix as b,sansPrefix as A}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as C from"@onflow/rlp";import{encode as I}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";var L="0.0.79-alpha.1",N=function(e){try{return Promise.resolve(n().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var r=n[1];return[n[0].replace(e,""),r]}))})}catch(e){return Promise.reject(e)}},O={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":O});var k=function(e){return function(n){return typeof n===e}},j=function(e){return null!=e},F=k("object"),x=k("string"),T=k("function"),_=k("number");function M(n){return T(n)?n(e.arg,h):[]}var V=function(n){return void 0===n&&(n={}),Promise.resolve(function(n){try{return p(j(n.cadence),"query({ cadence }) -- cadence is required"),p(x(n.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return e.send([e.script(n.cadence),e.args(M(n.args||[])),n.limit&&"number"==typeof n.limit&&e.limit(n.limit)]).then(e.decode)})};function U(){return U=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},U.apply(this,arguments)}function H(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function z(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return H(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?H(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}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 W={f_type:"Service",f_vsn:"1.0.0"},B={f_type:"Identity",f_vsn:"1.0.0"},K={f_type:"USER",f_vsn:"1.0.0"},Y={f_type:"PollingResponse",f_vsn:"1.0.0"},J={f_type:"CompositeSignature",f_vsn:"1.0.0"};function q(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({old:e},W,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function G(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function X(e){return null==e?null:(null==e.method&&(e=U({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:U({},W,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var Z={"back-channel-rpc":G,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},B,{address:b(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},B,{address:b(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:b(e.addr),name:e.name,icon:e.icon}})},frame:q,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":X,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function $(e){return C.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var Q=function(e){try{var n=(e=function(e){return e.addr=e.addr?b(e.addr):null,e.paddr=e.paddr?b(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=z(e.authorizations);!(r=t()).done;)n.push(U({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(U({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,o,i=(t=n,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(n){return function(e,n){try{return Z[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,i);return U({},K,{addr:b(e.addr),cid:$(s),loggedIn:!0,services:i,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function ee(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function ne(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function re(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(ne(e),{method:r,headers:U({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function te(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:U({},Y,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||U({},e)||{},updates:G(e.authorizationUpdates),local:q((e.local||[])[0])})}var oe=function e(n,r){void 0===r&&(r=function(){return!0});try{if(p(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(re(n,{method:se(n)}).then(te)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},ie={"HTTP/GET":"GET","HTTP/POST":"POST"},se=function(e){return p(ie[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),ie[e.method]},ae="FCL_IFRAME";function ce(e){p(!document.getElementById(ae),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=ae,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(ae)&&document.getElementById(ae).remove()}]}var ue=null,le=null;function de(e){var n,r;return null==ue||null!=(n=ue)&&n.closed?(r=window,ue=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):le!==e?(ue.location.replace(e),ue.focus()):ue.focus(),le=e,[ue,function(){ue&&!ue.closed&&ue.close(),ue=null}]}var fe=null,pe=null;function he(e){var n;return null==fe||null!=(n=fe)&&n.closed?fe=window.open(e,"_blank"):pe!==e?(fe.location.replace(e),fe.focus()):fe.focus(),pe=e,[fe,function(){fe&&!fe.closed&&fe.close(),fe=null}]}var ve,me={"VIEW/IFRAME":ce,"VIEW/POP":de,"VIEW/TAB":he},ye=function(e,n,r,t){try{return Promise.resolve(re(e,{data:U({fclVersion:L,service:{params:e.params,data:e.data,type:e.type},config:t},n)}).then(te)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(me[e.method](ne(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(X(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return oe(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},ge=function(e){return"string"==typeof e&&e.toLowerCase()},Ee=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),Pe=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},we=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(Ee.has(e.data.type))return;ge(e.data.type)===ge("FCL:VIEW:CLOSE")&&n(),ge(e.data.type)===ge("FCL:VIEW:READY")&&t(e,{send:r,close:n}),ge(e.data.type)===ge("FCL:VIEW:RESPONSE")&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),ge(e.data.type)===ge("FCL:FRAME:READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ge(e.data.type)===ge("FCL:FRAME:RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ge(e.data.type)===ge("FCL:FRAME:CLOSE")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n()),ge(e.data.type)===ge("FCL::CHALLENGE::RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ge(e.data.type)===ge("FCL::AUTHZ_READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ge(e.data.type)===ge("FCL::CHALLENGE::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n()),ge(e.data.type)===ge("FCL::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},Re=function(){},Se=function(){},be=function(){},Ae=function(){},Ce=function e(n){var r=n.service,t=n.msg,o=void 0===t?{}:t,i=n.opts,s=void 0===i?{}:i,a=n.config,c=void 0===a?{}:a;try{return Promise.resolve(N(/^service\./)).then(function(n){return Promise.resolve(N(/^app\.detail\./)).then(function(t){var i=U({},c,{services:n,app:t});return function(n,t){try{var a=Promise.resolve(Ie[r.method](r,o,s,i)).then(function(n){return"REDIRECT"===n.status?(p(r.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:o,opts:s,config:i}))):n})}catch(e){return t(e)}return a&&a.then?a.then(void 0,t):a}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:r,msg:o,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},Ie={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,n,r,t){return new Promise(function(o,i){var s,a=D(),c=r.includeOlderJsonRpcCall;n.data=null!=(s=e.data)?s:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Re,close:Re};var r=n.onClose||Re;window.addEventListener("message",we({close:s,send:a,onReady:n.onReady||Re,onResponse:n.onResponse||Re,onMessage:n.onMessage||Re}));var t=ce(ne(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",we),i(),r()}catch(e){console.error("Frame Close Error",e)}}function a(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:L,body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=D(),a=r.redir,c=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Se,close:Se};var r=n.onClose||Se;window.addEventListener("message",we({close:a,send:c,onReady:n.onReady||Se,onResponse:n.onResponse||Se,onMessage:n.onMessage||Se}));var t=de(ne(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",we),clearInterval(s),i(),r()}catch(e){console.error("Popup Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=D(),a=r.redir,c=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:be,close:be};var r=n.onClose||be;window.addEventListener("message",we({close:a,send:c,onReady:n.onReady||be,onResponse:n.onResponse||be,onMessage:n.onMessage||be}));var t=he(ne(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",we),clearInterval(s),i(),r()}catch(e){console.error("Tab Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r,t){return new Promise(function(r,o){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",we),s()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:Ae,close:Ae});var i=e.endpoint,s=n.onClose||Ae;window.addEventListener("message",we({close:t,send:o,onReady:n.onReady||Ae,onResponse:n.onResponse||Ae,onMessage:n.onMessage||Ae})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var i=te(e.data);switch(i.status){case"APPROVED":r(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":r(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},De=function(e,n){try{Le(e,n);var r=n[0].addr,t=[],o=[];return n.map(function(e){t.push(e.signature),o.push(e.keyId)}),Promise.resolve(V({cadence:Ne,args:function(n,i){return[n(r,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(t,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},Le=function(e,n){return p(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),p(Array.isArray(n)&&n.every(function(e,n,r){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),p(n.map(function(e){return e.addr}).every(function(e,n,r){return e===r[0]}),"User signatures to be verified must be from a single account address"),!0},Ne='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function Oe(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},J,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ke(e,n,r){if(!e.s){if(r instanceof Fe){if(!r.s)return void(r.o=ke.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(ke.bind(null,e,n),ke.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var je=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(De(e,n))}catch(e){return Promise.reject(e)}},Fe=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{ke(t,1,i(this.v))}catch(e){ke(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ke(t,1,n?n(o):o):r?ke(t,1,r(o)):ke(t,2,o)}catch(e){ke(t,2,e)}},t},e}();function xe(e){return e instanceof Fe&&1&e.s}var Te=function(e){try{return Je(),Promise.resolve(Ue({redir:!0})).then(function(n){var r=ee(n.services,"user-signature");return p(r,"Current user must have authorized a signing service."),_e(function(){return Promise.resolve(Ce({service:r,msg:$e(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return Oe(e)}):[Oe(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function _e(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var Me=function(){return Promise.resolve(Ue()).then(function(e){return r(b(e.addr),h.Address)})},Ve=function(e){try{return Je(),Promise.resolve(U({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ue({redir:!0})).then(function(r){var t;function o(n){if(t)return n;if(i)return U({},e,{tempId:"CURRENT_USER",resolve:null,addr:A(i.identity.address),keyId:i.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(Ce({service:i,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(Oe)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var i=ee(r.services,"authz"),s=ee(r.services,"pre-authz"),a=function(){if(s)return Promise.resolve(Ce({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=z(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,s=z(n.authorization||[]);!(i=s()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return Ce({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return t=1,n})}();return a&&a.then?a.then(o):o(a)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ue=function(e){var r=void 0===e?{}:e,t=r.service,o=r.redir,i=void 0!==o&&o;try{return Promise.resolve(new Promise(function(e,r){try{return Je(),Promise.resolve(Xe()).then(function(r){return Promise.resolve(He()).then(function(o){var s={redir:i};return Promise.resolve(function(){try{return Promise.resolve(n.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.get("discovery.authn.include",[])).then(function(r){return Promise.resolve(n.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:r}})})})}catch(e){return Promise.reject(e)}}()).then(function(a){var c=ee(r.services,"authn-refresh");return Promise.resolve(n.get("fcl.warning.suppress.redir")).then(function(n){var u;function l(n){if(u)return n;var r=function(e,n){try{var r=_e(function(){return Promise.resolve(Ce({service:U({},t||a,{method:(null==a?void 0:a.method)||t.method||"IFRAME/RPC"}),msg:o,opts:s,config:{discoveryAuthnInclude:a.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return r&&r.then?r.then(n.bind(null,!1),n.bind(null,!0)):n(!1,r)}(0,function(n,r){return Promise.resolve(Xe()).then(function(t){if(e(t),n)throw r;return r})});return r&&r.then?r.then(function(){}):void 0}i&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),p(t||a.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var d=function(){if(r.loggedIn){if(c)return function(e,n){try{var r=_e(function(){return Promise.resolve(Ce({service:c,msg:o,opts:s})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return r&&r.then?r.then(n,n):n()}(0,function(){return Promise.resolve(Xe()).then(function(n){var r=e(n);return u=1,r})});var n=e(r);return u=1,n}}();return d&&d.then?d.then(l):l(d)})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},He=function(){try{var e=Date.now();return Promise.resolve(n.get("fcl.appDomainTag")).then(function(n){return{timestamp:e,appDomainTag:n,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},ze="CURRENT_USER",We="CURRENT_USER/UPDATED",Be="SET_CURRENT_USER",Ke='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ye=((ve={})[v]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Ke)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){var r=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(Ke);return Promise.resolve(e.get(ze)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(ze),n):r||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},ve[m]=function(e,n){e.subscribe(n.from),e.send(n.from,We,U({},e.all()))},ve[y]=function(e,n){e.unsubscribe(n.from)},ve.SNAPSHOT=function(e,n){try{return n.reply(U({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},ve[Be]=function(e,r,t){try{return e.merge(t),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},ve.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(Ke)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},ve),Je=function(){return g(Ye,ze)};function qe(){Je(),E(ze,"DEL_CURRENT_USER")}function Ge(e){Je();var n="@EXIT",r=g(function(r){try{var t;return r.send(ze,m),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(xe(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!xe(i)){t=1;break}i=i.s}}var s=new Fe,a=ke.bind(null,s,2);return(0===t?o.then(u):1===t?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(u).then(void 0,a):u(o):ke(s,1,i)})).then(void 0,a),s;function c(n){i=n;do{if(!(o=e())||xe(o)&&!o.v)return void ke(s,1,i);if(o.then)return void o.then(u).then(void 0,a);xe(i=r())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,a)}function u(e){e?(i=r())&&i.then?i.then(c).then(void 0,a):c(i):ke(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if(o.tag===n)return r.send(ze,y),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return E(r,n)}}function Xe(){return Je(),E(ze,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ze,$e=function(e){return p(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Qe=function(){return{authenticate:Ue,unauthenticate:qe,authorization:Ve,signUserMessage:Te,verifyUserSignatures:je,subscribe:Ge,snapshot:Xe,resolveArgument:Me}};Qe.authenticate=Ue,Qe.unauthenticate=qe,Qe.authorization=Ve,Qe.signUserMessage=Te,Qe.verifyUserSignatures=je,Qe.subscribe=Ge,Qe.snapshot=Xe,Qe.resolveArgument=Me;var en=function(e){try{return Promise.resolve(t([o(e)]).then(i))}catch(e){return Promise.reject(e)}},nn=function(e){return e.status>=4},rn=function(e){return e.status>=3},tn=function(e){return e.status>=2},on=((Ze={})[v]=function(e){try{return Promise.resolve(en(e.self())).then(function(n){nn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Ze[m]=function(e,n){e.subscribe(n.from),e.send(n.from,P,e.all())},Ze[y]=function(e,n){e.unsubscribe(n.from)},Ze[w]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ze.POLL=function(e){try{return Promise.resolve(en(e.self())).then(function(n){var r,t;nn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),t=n,JSON.stringify(r)!==JSON.stringify(t)&&e.broadcast(P,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Ze),sn=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},an=function(e){return g(on,sn(e))};function cn(e){function n(n){return R(sn(e),an,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return S(e,an)},subscribe:n,onceFinalized:r(tn),onceExecuted:r(rn),onceSealed:r(nn)}}cn.isUnknown=function(e){return e.status>=0},cn.isPending=function(e){return e.status>=1},cn.isFinalized=tn,cn.isExecuted=rn,cn.isSealed=nn,cn.isExpired=function(e){return 5===e.status};var un,ln=function(n){void 0===n&&(n={});try{return Promise.resolve(function(r,t){try{var o=Promise.resolve(function(n){try{return p(j(n),"mutate(opts) -- opts is required"),p(F(n),"mutate(opts) -- opts must be an object"),p(j(n.cadence),"mutate({ cadence }) -- cadence is required"),p(x(n.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return Promise.resolve(e.config().get("fcl.authz",Qe().authorization)).then(function(r){return e.send([e.transaction(n.cadence),e.args(M(n.args||[])),n.limit&&_(n.limit)&&e.limit(n.limit),e.proposer(n.proposer||n.authz||r),e.payer(n.payer||n.authz||r),e.authorizations(n.authorizations||[n.authz||r])]).then(e.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},dn=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{return Promise.resolve(n.first(["sdk.resolve"],r.resolve||s)).then(function(n){function r(){return Promise.resolve(n(e)).then(function(e){return JSON.stringify(a(e),null,2)})}var t=function(){if(Array.isArray(e))return Promise.resolve(c(u(),e)).then(function(n){e=n})}();return t&&t.then?t.then(r):r()})}catch(e){return Promise.reject(e)}},fn=function(e){try{var r=setTimeout;return Promise.resolve(n().get("fcl.eventPollRate",1e4)).then(function(n){return r(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},pn=((un={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var n=e.get("hwm"),r=function(){if(null==n){var r=e.put;return Promise.resolve(l()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(fn(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(l()).then(function(r){return e.put("hwm",r),Promise.resolve(t([d(e.self(),n.height,r.height-1)]).then(i)).then(function(n){for(var r,t=z(n);!(r=t()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve(fn(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},un[m]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(fn(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},un[y]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},un),hn=function(e){return g(pn,e)};function vn(e){return{subscribe:function(n){return R(e,hn,n)}}}var mn=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.get("discovery.authn.endpoint")).then(function(r){return p(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.get("discovery.authn.include",[])).then(function(n){var t=new URL(r);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:L,include:n})}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function yn(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var gn,En=((gn={})[v]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(mn,yn,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},gn[m]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",U({},e.all()))},gn[y]=function(e,n){return e.unsubscribe(n.from)},gn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(U({},e.all())))}catch(e){return Promise.reject(e)}},gn),Pn=function(){return g(En,"authn")},wn={authn:{subscribe:function(e){return R("authn",Pn,e)},snapshot:function(){return S("authn",Pn)}}},Rn=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},Sn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(U({},n,{type:e}),"*"):window.opener.postMessage(U({},n,{type:e}),"*")},bn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},An={__proto__:null,sendMsgToFCL:Sn,ready:function(e,n){Rn("FCL:VIEW:READY:RESPONSE",e),Sn("FCL:VIEW:READY")},close:function(){Sn("FCL:VIEW:CLOSE")},approve:function(e){Sn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){Sn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){Sn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:Rn,encodeMessageFromSignable:f,CompositeSignature:function(e,n,r){this.f_type=J.f_type,this.f_vsn=J.f_vsn,this.addr=b(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),p(e,"Encode Message From Provable Authn Error: address must be defined"),p(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t=bn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),o=bn(Buffer.from(r).toString("hex"),32).toString("hex");return t+(r?I([o,b(e),n]).toString("hex"):I([b(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),p(e,"Encode Message From Provable Authn Error: address must be defined"),p(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t,o=r?(t=Buffer.from(r).toString("hex"),Buffer.from(t.padEnd(64,0),"hex")).toString("hex"):null;return r?I([o,b(e),n]).toString("hex"):I([b(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},Cn=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},In=function(){return Qe().unauthenticate()},Dn=function(e){return void 0===e&&(e={}),Qe().unauthenticate(),Qe().authenticate(e)},Ln=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},Nn=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},On=Qe().authorization,kn=h;export{L as VERSION,An as WalletUtils,Cn as authenticate,On as authz,Qe as currentUser,wn as discovery,vn as events,Nn as logIn,ln as mutate,V as query,Dn as reauthenticate,dn as serialize,Ln as signUp,kn as t,cn as tx,In as unauthenticate,De as verifyUserSignatures};
import*as e from"@onflow/sdk";import{config as n,arg as r,send as t,getTransactionStatus as o,decode as i,resolve as s,createSignableVoucher as a,pipe as c,interaction as u,latestBlock as l,getEvents as d,encodeMessageFromSignable as f}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,why}from"@onflow/sdk";import{invariant as p}from"@onflow/util-invariant";import*as h from"@onflow/types";import{INIT as v,SUBSCRIBE as m,UNSUBSCRIBE as y,spawn as g,send as E,UPDATED as P,SNAPSHOT as w,subscriber as R,snapshoter as S}from"@onflow/util-actor";import{withPrefix as b,sansPrefix as A}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as C from"@onflow/rlp";import{encode as I}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";var L="0.0.79-alpha.2",N=function(e){try{return Promise.resolve(n().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var r=n[1];return[n[0].replace(e,""),r]}))})}catch(e){return Promise.reject(e)}},O={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":O});var k=function(e){return function(n){return typeof n===e}},j=function(e){return null!=e},F=k("object"),x=k("string"),T=k("function"),_=k("number");function M(n){return T(n)?n(e.arg,h):[]}var V=function(n){return void 0===n&&(n={}),Promise.resolve(function(n){try{return p(j(n.cadence),"query({ cadence }) -- cadence is required"),p(x(n.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return e.send([e.script(n.cadence),e.args(M(n.args||[])),n.limit&&"number"==typeof n.limit&&e.limit(n.limit)]).then(e.decode)})};function U(){return U=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},U.apply(this,arguments)}function H(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function z(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return H(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?H(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}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 W={f_type:"Service",f_vsn:"1.0.0"},B={f_type:"Identity",f_vsn:"1.0.0"},K={f_type:"USER",f_vsn:"1.0.0"},Y={f_type:"PollingResponse",f_vsn:"1.0.0"},J={f_type:"CompositeSignature",f_vsn:"1.0.0"};function q(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({old:e},W,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function G(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function X(e){return null==e?null:(null==e.method&&(e=U({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:U({},W,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var Z={"back-channel-rpc":G,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},B,{address:b(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},B,{address:b(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:b(e.addr),name:e.name,icon:e.icon}})},frame:q,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":X,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function $(e){return C.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var Q=function(e){try{var n=(e=function(e){return e.addr=e.addr?b(e.addr):null,e.paddr=e.paddr?b(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=z(e.authorizations);!(r=t()).done;)n.push(U({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(U({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,o,i=(t=n,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(n){return function(e,n){try{return Z[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,i);return U({},K,{addr:b(e.addr),cid:$(s),loggedIn:!0,services:i,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function ee(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function ne(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function re(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(ne(e),{method:r,headers:U({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function te(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:U({},Y,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||U({},e)||{},updates:G(e.authorizationUpdates),local:q((e.local||[])[0])})}var oe=function e(n,r){void 0===r&&(r=function(){return!0});try{if(p(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(re(n,{method:se(n)}).then(te)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},ie={"HTTP/GET":"GET","HTTP/POST":"POST"},se=function(e){return p(ie[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),ie[e.method]},ae="FCL_IFRAME";function ce(e){p(!document.getElementById(ae),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=ae,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(ae)&&document.getElementById(ae).remove()}]}var ue=null,le=null;function de(e){var n,r;return null==ue||null!=(n=ue)&&n.closed?(r=window,ue=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):le!==e?(ue.location.replace(e),ue.focus()):ue.focus(),le=e,[ue,function(){ue&&!ue.closed&&ue.close(),ue=null}]}var fe=null,pe=null;function he(e){var n;return null==fe||null!=(n=fe)&&n.closed?fe=window.open(e,"_blank"):pe!==e?(fe.location.replace(e),fe.focus()):fe.focus(),pe=e,[fe,function(){fe&&!fe.closed&&fe.close(),fe=null}]}var ve,me={"VIEW/IFRAME":ce,"VIEW/POP":de,"VIEW/TAB":he},ye=function(e,n,r,t){try{return Promise.resolve(re(e,{data:U({fclVersion:L,service:{params:e.params,data:e.data,type:e.type},config:t},n)}).then(te)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(me[e.method](ne(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(X(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return oe(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},ge=function(e){return"string"==typeof e&&e.toLowerCase()},Ee=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),Pe=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},we=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(Ee.has(e.data.type))return;ge(e.data.type)===ge("FCL:VIEW:CLOSE")&&n(),ge(e.data.type)===ge("FCL:VIEW:READY")&&t(e,{send:r,close:n}),ge(e.data.type)===ge("FCL:VIEW:RESPONSE")&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),ge(e.data.type)===ge("FCL:FRAME:READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ge(e.data.type)===ge("FCL:FRAME:RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ge(e.data.type)===ge("FCL:FRAME:CLOSE")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n()),ge(e.data.type)===ge("FCL::CHALLENGE::RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ge(e.data.type)===ge("FCL::AUTHZ_READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ge(e.data.type)===ge("FCL::CHALLENGE::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n()),ge(e.data.type)===ge("FCL::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},Re=function(){},Se=function(){},be=function(){},Ae=function(){},Ce=function e(n){var r=n.service,t=n.msg,o=void 0===t?{}:t,i=n.opts,s=void 0===i?{}:i,a=n.config,c=void 0===a?{}:a;try{return Promise.resolve(N(/^service\./)).then(function(n){return Promise.resolve(N(/^app\.detail\./)).then(function(t){var i=U({},c,{services:n,app:t});return function(n,t){try{var a=Promise.resolve(Ie[r.method](r,o,s,i)).then(function(n){return"REDIRECT"===n.status?(p(r.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:o,opts:s,config:i}))):n})}catch(e){return t(e)}return a&&a.then?a.then(void 0,t):a}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:r,msg:o,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},Ie={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,n,r,t){return new Promise(function(o,i){var s,a=D(),c=r.includeOlderJsonRpcCall;n.data=null!=(s=e.data)?s:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Re,close:Re};var r=n.onClose||Re;window.addEventListener("message",we({close:s,send:a,onReady:n.onReady||Re,onResponse:n.onResponse||Re,onMessage:n.onMessage||Re}));var t=ce(ne(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",we),i(),r()}catch(e){console.error("Frame Close Error",e)}}function a(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:L,body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=D(),a=r.redir,c=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Se,close:Se};var r=n.onClose||Se;window.addEventListener("message",we({close:a,send:c,onReady:n.onReady||Se,onResponse:n.onResponse||Se,onMessage:n.onMessage||Se}));var t=de(ne(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",we),clearInterval(s),i(),r()}catch(e){console.error("Popup Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=D(),a=r.redir,c=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:be,close:be};var r=n.onClose||be;window.addEventListener("message",we({close:a,send:c,onReady:n.onReady||be,onResponse:n.onResponse||be,onMessage:n.onMessage||be}));var t=he(ne(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",we),clearInterval(s),i(),r()}catch(e){console.error("Tab Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r,t){return new Promise(function(r,o){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",we),s()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:Ae,close:Ae});var i=e.endpoint,s=n.onClose||Ae;window.addEventListener("message",we({close:t,send:o,onReady:n.onReady||Ae,onResponse:n.onResponse||Ae,onMessage:n.onMessage||Ae})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var i=te(e.data);switch(i.status){case"APPROVED":r(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":r(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},De=function(e,n){try{Le(e,n);var r=n[0].addr,t=[],o=[];return n.map(function(e){t.push(e.signature),o.push(e.keyId)}),Promise.resolve(V({cadence:Ne,args:function(n,i){return[n(r,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(t,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},Le=function(e,n){return p(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),p(Array.isArray(n)&&n.every(function(e,n,r){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),p(n.map(function(e){return e.addr}).every(function(e,n,r){return e===r[0]}),"User signatures to be verified must be from a single account address"),!0},Ne='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function Oe(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},J,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ke(e,n,r){if(!e.s){if(r instanceof Fe){if(!r.s)return void(r.o=ke.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(ke.bind(null,e,n),ke.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var je=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(De(e,n))}catch(e){return Promise.reject(e)}},Fe=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{ke(t,1,i(this.v))}catch(e){ke(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ke(t,1,n?n(o):o):r?ke(t,1,r(o)):ke(t,2,o)}catch(e){ke(t,2,e)}},t},e}();function xe(e){return e instanceof Fe&&1&e.s}var Te=function(e){try{return Je(),Promise.resolve(Ue({redir:!0})).then(function(n){var r=ee(n.services,"user-signature");return p(r,"Current user must have authorized a signing service."),_e(function(){return Promise.resolve(Ce({service:r,msg:$e(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return Oe(e)}):[Oe(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function _e(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var Me=function(){return Promise.resolve(Ue()).then(function(e){return r(b(e.addr),h.Address)})},Ve=function(e){try{return Je(),Promise.resolve(U({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ue({redir:!0})).then(function(r){var t;function o(n){if(t)return n;if(i)return U({},e,{tempId:"CURRENT_USER",resolve:null,addr:A(i.identity.address),keyId:i.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(Ce({service:i,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(Oe)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var i=ee(r.services,"authz"),s=ee(r.services,"pre-authz"),a=function(){if(s)return Promise.resolve(Ce({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=z(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,s=z(n.authorization||[]);!(i=s()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return Ce({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return t=1,n})}();return a&&a.then?a.then(o):o(a)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ue=function(e){var r=void 0===e?{}:e,t=r.service,o=r.redir,i=void 0!==o&&o;try{return Promise.resolve(new Promise(function(e,r){try{return Je(),Promise.resolve(Xe()).then(function(r){return Promise.resolve(He()).then(function(o){var s={redir:i};return Promise.resolve(function(){try{return Promise.resolve(n.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.get("discovery.authn.include",[])).then(function(r){return Promise.resolve(n.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:r}})})})}catch(e){return Promise.reject(e)}}()).then(function(a){var c=ee(r.services,"authn-refresh");return Promise.resolve(n.get("fcl.warning.suppress.redir")).then(function(n){var u;function l(n){if(u)return n;var r=function(e,n){try{var r=_e(function(){return Promise.resolve(Ce({service:U({},t||a,{method:(null==a?void 0:a.method)||t.method||"IFRAME/RPC"}),msg:o,opts:s,config:{discoveryAuthnInclude:a.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return r&&r.then?r.then(n.bind(null,!1),n.bind(null,!0)):n(!1,r)}(0,function(n,r){return Promise.resolve(Xe()).then(function(t){if(e(t),n)throw r;return r})});return r&&r.then?r.then(function(){}):void 0}i&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),p(t||a.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var d=function(){if(r.loggedIn){if(c)return function(e,n){try{var r=_e(function(){return Promise.resolve(Ce({service:c,msg:o,opts:s})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return r&&r.then?r.then(n,n):n()}(0,function(){return Promise.resolve(Xe()).then(function(n){var r=e(n);return u=1,r})});var n=e(r);return u=1,n}}();return d&&d.then?d.then(l):l(d)})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},He=function(){try{var e=Date.now();return Promise.resolve(n.get("fcl.appDomainTag")).then(function(n){return{timestamp:e,appDomainTag:n,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},ze="CURRENT_USER",We="CURRENT_USER/UPDATED",Be="SET_CURRENT_USER",Ke='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ye=((ve={})[v]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Ke)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){var r=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(Ke);return Promise.resolve(e.get(ze)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(ze),n):r||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},ve[m]=function(e,n){e.subscribe(n.from),e.send(n.from,We,U({},e.all()))},ve[y]=function(e,n){e.unsubscribe(n.from)},ve.SNAPSHOT=function(e,n){try{return n.reply(U({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},ve[Be]=function(e,r,t){try{return e.merge(t),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},ve.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(Ke)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},ve),Je=function(){return g(Ye,ze)};function qe(){Je(),E(ze,"DEL_CURRENT_USER")}function Ge(e){Je();var n="@EXIT",r=g(function(r){try{var t;return r.send(ze,m),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(xe(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!xe(i)){t=1;break}i=i.s}}var s=new Fe,a=ke.bind(null,s,2);return(0===t?o.then(u):1===t?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(u).then(void 0,a):u(o):ke(s,1,i)})).then(void 0,a),s;function c(n){i=n;do{if(!(o=e())||xe(o)&&!o.v)return void ke(s,1,i);if(o.then)return void o.then(u).then(void 0,a);xe(i=r())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,a)}function u(e){e?(i=r())&&i.then?i.then(c).then(void 0,a):c(i):ke(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if(o.tag===n)return r.send(ze,y),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return E(r,n)}}function Xe(){return Je(),E(ze,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ze,$e=function(e){return p(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Qe=function(){return{authenticate:Ue,unauthenticate:qe,authorization:Ve,signUserMessage:Te,verifyUserSignatures:je,subscribe:Ge,snapshot:Xe,resolveArgument:Me}};Qe.authenticate=Ue,Qe.unauthenticate=qe,Qe.authorization=Ve,Qe.signUserMessage=Te,Qe.verifyUserSignatures=je,Qe.subscribe=Ge,Qe.snapshot=Xe,Qe.resolveArgument=Me;var en=function(e){try{return Promise.resolve(t([o(e)]).then(i))}catch(e){return Promise.reject(e)}},nn=function(e){return e.status>=4},rn=function(e){return e.status>=3},tn=function(e){return e.status>=2},on=((Ze={})[v]=function(e){try{return Promise.resolve(en(e.self())).then(function(n){nn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Ze[m]=function(e,n){e.subscribe(n.from),e.send(n.from,P,e.all())},Ze[y]=function(e,n){e.unsubscribe(n.from)},Ze[w]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ze.POLL=function(e){try{return Promise.resolve(en(e.self())).then(function(n){var r,t;nn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),t=n,JSON.stringify(r)!==JSON.stringify(t)&&e.broadcast(P,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Ze),sn=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},an=function(e){return g(on,sn(e))};function cn(e){function n(n){return R(sn(e),an,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return S(e,an)},subscribe:n,onceFinalized:r(tn),onceExecuted:r(rn),onceSealed:r(nn)}}cn.isUnknown=function(e){return e.status>=0},cn.isPending=function(e){return e.status>=1},cn.isFinalized=tn,cn.isExecuted=rn,cn.isSealed=nn,cn.isExpired=function(e){return 5===e.status};var un,ln=function(n){void 0===n&&(n={});try{return Promise.resolve(function(r,t){try{var o=Promise.resolve(function(n){try{return p(j(n),"mutate(opts) -- opts is required"),p(F(n),"mutate(opts) -- opts must be an object"),p(j(n.cadence),"mutate({ cadence }) -- cadence is required"),p(x(n.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return Promise.resolve(e.config().get("fcl.authz",Qe().authorization)).then(function(r){return e.send([e.transaction(n.cadence),e.args(M(n.args||[])),n.limit&&_(n.limit)&&e.limit(n.limit),e.proposer(n.proposer||n.authz||r),e.payer(n.payer||n.authz||r),e.authorizations(n.authorizations||[n.authz||r])]).then(e.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},dn=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{return Promise.resolve(n.first(["sdk.resolve"],r.resolve||s)).then(function(n){function r(){return Promise.resolve(n(e)).then(function(e){return JSON.stringify(a(e),null,2)})}var t=function(){if(Array.isArray(e))return Promise.resolve(c(u(),e)).then(function(n){e=n})}();return t&&t.then?t.then(r):r()})}catch(e){return Promise.reject(e)}},fn=function(e){try{var r=setTimeout;return Promise.resolve(n().get("fcl.eventPollRate",1e4)).then(function(n){return r(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},pn=((un={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var n=e.get("hwm"),r=function(){if(null==n){var r=e.put;return Promise.resolve(l()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(fn(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(l()).then(function(r){return e.put("hwm",r),Promise.resolve(t([d(e.self(),n.height,r.height-1)]).then(i)).then(function(n){for(var r,t=z(n);!(r=t()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve(fn(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},un[m]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(fn(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},un[y]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},un),hn=function(e){return g(pn,e)};function vn(e){return{subscribe:function(n){return R(e,hn,n)}}}var mn=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.get("discovery.authn.endpoint")).then(function(r){return p(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.get("discovery.authn.include",[])).then(function(n){var t=new URL(r);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:L,include:n})}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function yn(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var gn,En=((gn={})[v]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(mn,yn,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},gn[m]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",U({},e.all()))},gn[y]=function(e,n){return e.unsubscribe(n.from)},gn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(U({},e.all())))}catch(e){return Promise.reject(e)}},gn),Pn=function(){return g(En,"authn")},wn={authn:{subscribe:function(e){return R("authn",Pn,e)},snapshot:function(){return S("authn",Pn)}}},Rn=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},Sn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(U({},n,{type:e}),"*"):window.opener.postMessage(U({},n,{type:e}),"*")},bn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},An={__proto__:null,sendMsgToFCL:Sn,ready:function(e,n){Rn("FCL:VIEW:READY:RESPONSE",e),Sn("FCL:VIEW:READY")},close:function(){Sn("FCL:VIEW:CLOSE")},approve:function(e){Sn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){Sn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){Sn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:Rn,encodeMessageFromSignable:f,CompositeSignature:function(e,n,r){this.f_type=J.f_type,this.f_vsn=J.f_vsn,this.addr=b(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),p(e,"Encode Message From Provable Authn Error: address must be defined"),p(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t=bn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),o=bn(Buffer.from(r).toString("hex"),32).toString("hex");return t+(r?I([o,b(e),n]).toString("hex"):I([b(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),p(e,"Encode Message From Provable Authn Error: address must be defined"),p(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t,o=r?(t=Buffer.from(r).toString("hex"),Buffer.from(t.padEnd(64,0),"hex")).toString("hex"):null;return r?I([o,b(e),n]).toString("hex"):I([b(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},Cn=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},In=function(){return Qe().unauthenticate()},Dn=function(e){return void 0===e&&(e={}),Qe().unauthenticate(),Qe().authenticate(e)},Ln=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},Nn=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},On=Qe().authorization,kn=h;export{L as VERSION,An as WalletUtils,Cn as authenticate,On as authz,Qe as currentUser,wn as discovery,vn as events,Nn as logIn,ln as mutate,V as query,Dn as reauthenticate,dn as serialize,Ln as signUp,kn as t,cn as tx,In as unauthenticate,De as verifyUserSignatures};
//# sourceMappingURL=fcl.module.js.map

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/sdk"),require("@onflow/util-invariant"),require("@onflow/types"),require("@onflow/util-actor"),require("@onflow/util-address"),require("@onflow/rlp"),require("@onflow/util-uid"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/sdk","@onflow/util-invariant","@onflow/types","@onflow/util-actor","@onflow/util-address","@onflow/rlp","@onflow/util-uid","@onflow/util-template"],n):n((e||self).fcl={},e.sdk,e.utilInvariant,e.t$1,e.utilActor,e.utilAddress,e.rlp,e.utilUid,e.utilTemplate)}(this,function(e,n,t,r,o,i,a,s,u){function c(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}}),n.default=e,n}var l=c(n),d=c(r),f=c(a),p="0.0.79-alpha.1",h=function(e){try{return Promise.resolve(n.config().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var t=n[1];return[n[0].replace(e,""),t]}))})}catch(e){return Promise.reject(e)}},v={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":v});var m=function(e){return function(n){return typeof n===e}},y=function(e){return null!=e},g=m("object"),P=m("string"),b=m("function"),E=m("number");function w(e){return b(e)?e(l.arg,d):[]}var R=function(e){return void 0===e&&(e={}),Promise.resolve(function(e){try{return t.invariant(y(e.cadence),"query({ cadence }) -- cadence is required"),t.invariant(P(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){t.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return l.send([l.script(e.cadence),l.args(w(e.args||[])),e.limit&&"number"==typeof e.limit&&l.limit(e.limit)]).then(l.decode)})};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)}function A(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function I(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return A(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?A(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;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.")}var C={f_type:"Service",f_vsn:"1.0.0"},O={f_type:"Identity",f_vsn:"1.0.0"},j={f_type:"USER",f_vsn:"1.0.0"},D={f_type:"PollingResponse",f_vsn:"1.0.0"},N={f_type:"CompositeSignature",f_vsn:"1.0.0"};function k(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({old:e},C,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function x(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function L(e){return null==e?null:(null==e.method&&(e=S({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:S({},C,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var T={"back-channel-rpc":x,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},O,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},O,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:i.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:k,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":L,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return f.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var _=function(e){try{var n=(e=function(e){return e.addr=e.addr?i.withPrefix(e.addr):null,e.paddr=e.paddr?i.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",n),Promise.resolve(fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var t,r=I(e.authorizations);!(t=r()).done;)n.push(S({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&n.push(S({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(t){var r,o,a=(r=n,o=t,void 0===r&&(r=[]),void 0===o&&(o=[]),[].concat(r,o)).map(function(n){return function(e,n){try{return T[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return S({},j,{addr:i.withPrefix(e.addr),cid:F(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function U(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function B(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}return n}function M(e,n){void 0===n&&(n={});var t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(B(e),{method:t,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(function(e){return e.json()})}function V(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:S({},D,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||S({},e)||{},updates:x(e.authorizationUpdates),local:k((e.local||[])[0])})}var H=function e(n,r){void 0===r&&(r=function(){return!0});try{if(t.invariant(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(M(n,{method:W(n)}).then(V)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},z={"HTTP/GET":"GET","HTTP/POST":"POST"},W=function(e){return t.invariant(z[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),z[e.method]},K="FCL_IFRAME";function q(e){t.invariant(!document.getElementById(K),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=K,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(K)&&document.getElementById(K).remove()}]}var Y=null,J=null;function G(e){var n,t;return null==Y||null!=(n=Y)&&n.closed?(t=window,Y=t.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(t.top.outerHeight/2+t.top.screenY-385)+", left="+(t.top.outerWidth/2+t.top.screenX-320))):J!==e?(Y.location.replace(e),Y.focus()):Y.focus(),J=e,[Y,function(){Y&&!Y.closed&&Y.close(),Y=null}]}var $=null,X=null;function Z(e){var n;return null==$||null!=(n=$)&&n.closed?$=window.open(e,"_blank"):X!==e?($.location.replace(e),$.focus()):$.focus(),X=e,[$,function(){$&&!$.closed&&$.close(),$=null}]}var Q,ee={"VIEW/IFRAME":q,"VIEW/POP":G,"VIEW/TAB":Z},ne=function(e,n,t,r){try{return Promise.resolve(M(e,{data:S({fclVersion:p,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(V)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var t=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(ee[e.method](B(e),n))}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}catch(e){return Promise.reject(e)}}(L(n.local))).then(function(e){var r=e[1],o=function(){try{r(),t=!1}catch(e){console.error("Frame Close Error",e)}};return H(n.updates,function(){return t}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},te="FCL:VIEW:CLOSE",re="FCL:VIEW:READY",oe="FCL:VIEW:RESPONSE",ie=function(e){return"string"==typeof e&&e.toLowerCase()},ae=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),se=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},ue=function(e){var n=e.close,t=e.send,r=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(ae.has(e.data.type))return;ie(e.data.type)===ie(te)&&n(),ie(e.data.type)===ie(re)&&r(e,{send:t,close:n}),ie(e.data.type)===ie(oe)&&o(e,{send:t,close:n}),i(e,{send:t,close:n}),ie(e.data.type)===ie("FCL:FRAME:READY")&&(se(e.data.type,re),r(e,{send:t,close:n})),ie(e.data.type)===ie("FCL:FRAME:RESPONSE")&&(se(e.data.type,oe),o(e,{send:t,close:n})),ie(e.data.type)===ie("FCL:FRAME:CLOSE")&&(se(e.data.type,te),n()),ie(e.data.type)===ie("FCL::CHALLENGE::RESPONSE")&&(se(e.data.type,oe),o(e,{send:t,close:n})),ie(e.data.type)===ie("FCL::AUTHZ_READY")&&(se(e.data.type,re),r(e,{send:t,close:n})),ie(e.data.type)===ie("FCL::CHALLENGE::CANCEL")&&(se(e.data.type,te),n()),ie(e.data.type)===ie("FCL::CANCEL")&&(se(e.data.type,te),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ce=function(){},le=function(){},de=function(){},fe=function(){},pe=function e(n){var r=n.service,o=n.msg,i=void 0===o?{}:o,a=n.opts,s=void 0===a?{}:a,u=n.config,c=void 0===u?{}:u;try{return Promise.resolve(h(/^service\./)).then(function(n){return Promise.resolve(h(/^app\.detail\./)).then(function(o){var a=S({},c,{services:n,app:o});return function(n,o){try{var u=Promise.resolve(he[r.method](r,i,s,a)).then(function(n){return"REDIRECT"===n.status?(t.invariant(r.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:i,opts:s,config:a}))):n})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:r,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},he={"HTTP/RPC":ne,"HTTP/POST":ne,"IFRAME/RPC":function(e,n,t,r){return new Promise(function(o,i){var a,u=s.uid(),c=t.includeOlderJsonRpcCall;n.data=null!=(a=e.data)?a:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ce,close:ce};var t=n.onClose||ce;window.addEventListener("message",ue({close:a,send:s,onReady:n.onReady||ce,onResponse:n.onResponse||ce,onMessage:n.onMessage||ce}));var r=q(B(e)),o=r[0],i=r[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",ue),i(),t()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:p,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:u,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==u)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise(function(o,i){var a=s.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:le,close:le};var t=n.onClose||le;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||le,onResponse:n.onResponse||le,onMessage:n.onMessage||le}));var r=G(B(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),t()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise(function(o,i){var a=s.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:de,close:de};var t=n.onClose||de;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||de,onResponse:n.onResponse||de,onMessage:n.onMessage||de}));var r=Z(B(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),t()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise(function(t,o){!function(e,n){void 0===n&&(n={});try{var t,r=function(){try{window.removeEventListener("message",ue),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:fe,close:fe});var i=e.endpoint,a=n.onClose||fe;window.addEventListener("message",ue({close:r,send:o,onReady:n.onReady||fe,onResponse:n.onResponse||fe,onMessage:n.onMessage||fe})),Promise.resolve(null==(t=window[i])?void 0:t.flow.enable()).then(function(){return{send:o,close:r}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=V(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},ve=function(e,n){try{me(e,n);var t=n[0].addr,r=[],o=[];return n.map(function(e){r.push(e.signature),o.push(e.keyId)}),Promise.resolve(R({cadence:ye,args:function(n,i){return[n(t,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(r,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},me=function(e,n){return t.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),t.invariant(Array.isArray(n)&&n.every(function(e,n,t){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),t.invariant(n.map(function(e){return e.addr}).every(function(e,n,t){return e===t[0]}),"User signatures to be verified must be from a single account address"),!0},ye='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function ge(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},N,{addr:i.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function Pe(e,n,t){if(!e.s){if(t instanceof Ee){if(!t.s)return void(t.o=Pe.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(Pe.bind(null,e,n),Pe.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var be=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(ve(e,n))}catch(e){return Promise.reject(e)}},Ee=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{Pe(r,1,i(this.v))}catch(e){Pe(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Pe(r,1,n?n(o):o):t?Pe(r,1,t(o)):Pe(r,2,o)}catch(e){Pe(r,2,e)}},r},e}();function we(e){return e instanceof Ee&&1&e.s}var Re=function(e){try{return Le(),Promise.resolve(Ce({redir:!0})).then(function(n){var r=U(n.services,"user-signature");return t.invariant(r,"Current user must have authorized a signing service."),Se(function(){return Promise.resolve(pe({service:r,msg:Be(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return ge(e)}):[ge(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function Se(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var Ae=function(){return Promise.resolve(Ce()).then(function(e){return n.arg(i.withPrefix(e.addr),d.Address)})},Ie=function(e){try{return Le(),Promise.resolve(S({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ce({redir:!0})).then(function(t){var r;function o(n){if(r)return n;if(a)return S({},e,{tempId:"CURRENT_USER",resolve:null,addr:i.sansPrefix(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(pe({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(ge)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=U(t.services,"authz"),s=U(t.services,"pre-authz"),u=function(){if(s)return Promise.resolve(pe({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(var r,o=I(n.payer||[]);!(r=o()).done;)t.push(["PAYER",r.value]);for(var i,a=I(n.authorization||[]);!(i=a()).done;)t.push(["AUTHORIZER",i.value]);return t.map(function(e){var n=e[0],t=e[1];return{tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:function(e){return pe({service:t,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return r=1,n})}();return u&&u.then?u.then(o):o(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ce=function(e){var r=void 0===e?{}:e,i=r.service,a=r.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(e,r){try{return Le(),Promise.resolve(_e()).then(function(r){return Promise.resolve(Oe()).then(function(a){var u={redir:s};return Promise.resolve(function(){try{return Promise.resolve(n.config.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(t){return Promise.resolve(n.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:t}})})})}catch(e){return Promise.reject(e)}}()).then(function(c){var l=U(r.services,"authn-refresh");return Promise.resolve(n.config.get("fcl.warning.suppress.redir")).then(function(n){var d;function f(n){if(d)return n;var t=function(e,n){try{var t=Se(function(){return Promise.resolve(pe({service:S({},i||c,{method:(null==c?void 0:c.method)||i.method||"IFRAME/RPC"}),msg:a,opts:u,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return t&&t.then?t.then(n.bind(null,!1),n.bind(null,!0)):n(!1,t)}(0,function(n,t){return Promise.resolve(_e()).then(function(r){if(e(r),n)throw t;return t})});return t&&t.then?t.then(function(){}):void 0}s&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),t.invariant(i||c.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var p=function(){if(r.loggedIn){if(l)return function(e,n){try{var t=Se(function(){return Promise.resolve(pe({service:l,msg:a,opts:u})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(0,function(){return Promise.resolve(_e()).then(function(n){var t=e(n);return d=1,t})});var n=e(r);return d=1,n}}();return p&&p.then?p.then(f):f(p)})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Oe=function(){try{var e=Date.now();return Promise.resolve(n.config.get("fcl.appDomainTag")).then(function(n){return{timestamp:e,appDomainTag:n,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},je="CURRENT_USER",De="CURRENT_USER/UPDATED",Ne="SET_CURRENT_USER",ke='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',xe=((Q={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(ke)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){var t=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(ke);return Promise.resolve(e.get(je)).then(function(t){return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(je),n):t||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},Q[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,De,S({},e.all()))},Q[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Q.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Q[Ne]=function(e,t,r){try{return e.merge(r),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(De,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q.DEL_CURRENT_USER=function(e,t){try{return e.merge(JSON.parse(ke)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(De,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q),Le=function(){return o.spawn(xe,je)};function Te(){Le(),o.send(je,"DEL_CURRENT_USER")}function Fe(e){Le();var n="@EXIT",t=o.spawn(function(t){try{var r;return t.send(je,o.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(we(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!we(i)){r=1;break}i=i.s}}var a=new Ee,s=Pe.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):Pe(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||we(o)&&!o.v)return void Pe(a,1,i);if(o.then)return void o.then(c).then(void 0,s);we(i=t())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=t())&&i.then?i.then(u).then(void 0,s):u(i):Pe(a,1,i)}}(function(){return!r&&1},0,function(){return Promise.resolve(t.receive()).then(function(i){if(i.tag===n)return t.send(je,o.UNSUBSCRIBE),void(r=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return o.send(t,n)}}function _e(){return Le(),o.send(je,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ue,Be=function(e){return t.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Me=function(){return{authenticate:Ce,unauthenticate:Te,authorization:Ie,signUserMessage:Re,verifyUserSignatures:be,subscribe:Fe,snapshot:_e,resolveArgument:Ae}};Me.authenticate=Ce,Me.unauthenticate=Te,Me.authorization=Ie,Me.signUserMessage=Re,Me.verifyUserSignatures=be,Me.subscribe=Fe,Me.snapshot=_e,Me.resolveArgument=Ae;var Ve="POLL",He=function(e){try{return Promise.resolve(n.send([n.getTransactionStatus(e)]).then(n.decode))}catch(e){return Promise.reject(e)}},ze=function(e){return e.status>=4},We=function(e){return e.status>=3},Ke=function(e){return e.status>=2},qe=((Ue={})[o.INIT]=function(e){try{return Promise.resolve(He(e.self())).then(function(n){ze(n)||setTimeout(function(){return e.sendSelf(Ve)},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Ue[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,o.UPDATED,e.all())},Ue[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Ue[o.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ue.POLL=function(e){try{return Promise.resolve(He(e.self())).then(function(n){var t,r;ze(n)||setTimeout(function(){return e.sendSelf(Ve)},2500),t=e.all(),r=n,JSON.stringify(t)!==JSON.stringify(r)&&e.broadcast(o.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Ue),Ye=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},Je=function(e){return o.spawn(qe,Ye(e))};function Ge(e){function n(n){return o.subscriber(Ye(e),Je,n)}function t(e){return function(t){void 0===t&&(t={});var r=t.suppress||!1;return new Promise(function(t,o){var i=n(function(n){n.statusCode&&!r?(o(n.errorMessage),i()):e(n)&&(t(n),i())})})}}return{snapshot:function(){return o.snapshoter(e,Je)},subscribe:n,onceFinalized:t(Ke),onceExecuted:t(We),onceSealed:t(ze)}}Ge.isUnknown=function(e){return e.status>=0},Ge.isPending=function(e){return e.status>=1},Ge.isFinalized=Ke,Ge.isExecuted=We,Ge.isSealed=ze,Ge.isExpired=function(e){return 5===e.status};var $e,Xe=function(e){try{var t=setTimeout;return Promise.resolve(n.config().get("fcl.eventPollRate",1e4)).then(function(n){return t(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},Ze=(($e={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var t=e.get("hwm"),r=function(){if(null==t){var r=e.put;return Promise.resolve(n.latestBlock()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(Xe(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(n.latestBlock()).then(function(r){return e.put("hwm",r),Promise.resolve(n.send([n.getEvents(e.self(),t.height,r.height-1)]).then(n.decode)).then(function(n){for(var t,r=I(n);!(t=r()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(Xe(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},$e[o.SUBSCRIBE]=function(e,n){try{var t=function(){e.subscribe(n.from)},r=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Xe(e)).then(function(t){n.call(e,"tick",t)})}}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},$e[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},$e),Qe=function(e){return o.spawn(Ze,e)},en=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.config.get("discovery.authn.endpoint")).then(function(r){return t.invariant(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(n){var t=new URL(r);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:p,include:n})}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function nn(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var tn,rn="authn",on=((tn={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:rn},t=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(en,nn,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,t)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,t},tn[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",S({},e.all()))},tn[o.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},tn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(S({},e.all())))}catch(e){return Promise.reject(e)}},tn),an=function(){return o.spawn(on,rn)},sn={authn:{subscribe:function(e){return o.subscriber(rn,an,e)},snapshot:function(){return o.snapshoter(rn,an)}}},un=function(e,n){void 0===n&&(n=function(){});var t=function(t){var r=t.data;"object"==typeof r&&null!=typeof r&&r.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(r))};return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},cn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(S({},n,{type:e}),"*"):window.opener.postMessage(S({},n,{type:e}),"*")},ln=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},dn={__proto__:null,sendMsgToFCL:cn,ready:function(e,n){un("FCL:VIEW:READY:RESPONSE",e),cn("FCL:VIEW:READY")},close:function(){cn("FCL:VIEW:CLOSE")},approve:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:un,encodeMessageFromSignable:n.encodeMessageFromSignable,CompositeSignature:function(e,n,t){this.f_type=N.f_type,this.f_vsn=N.f_vsn,this.addr=i.withPrefix(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),t.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),t.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o=ln(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=ln(Buffer.from(r).toString("hex"),32).toString("hex");return o+(r?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),t.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),t.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o,s=r?(o=Buffer.from(r).toString("hex"),Buffer.from(o.padEnd(64,0),"hex")).toString("hex"):null;return r?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},fn=Me().authorization,pn=d;Object.defineProperty(e,"TestUtils",{enumerable:!0,get:function(){return n.TestUtils}}),Object.defineProperty(e,"account",{enumerable:!0,get:function(){return n.account}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return n.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return n.args}}),Object.defineProperty(e,"atBlockHeight",{enumerable:!0,get:function(){return n.atBlockHeight}}),Object.defineProperty(e,"atBlockId",{enumerable:!0,get:function(){return n.atBlockId}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return n.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return n.authorizations}}),Object.defineProperty(e,"block",{enumerable:!0,get:function(){return n.block}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"createSignableVoucher",{enumerable:!0,get:function(){return n.createSignableVoucher}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return n.decode}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return n.getAccount}}),Object.defineProperty(e,"getBlock",{enumerable:!0,get:function(){return n.getBlock}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return n.getBlockByHeight}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return n.getBlockById}}),Object.defineProperty(e,"getBlockHeader",{enumerable:!0,get:function(){return n.getBlockHeader}}),Object.defineProperty(e,"getCollection",{enumerable:!0,get:function(){return n.getCollection}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return n.getEvents}}),Object.defineProperty(e,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return n.getEventsAtBlockHeightRange}}),Object.defineProperty(e,"getEventsAtBlockIds",{enumerable:!0,get:function(){return n.getEventsAtBlockIds}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return n.getLatestBlock}}),Object.defineProperty(e,"getTransaction",{enumerable:!0,get:function(){return n.getTransaction}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return n.getTransactionStatus}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n.invariant}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(e,"latestBlock",{enumerable:!0,get:function(){return n.latestBlock}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return n.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return n.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return n.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return n.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return n.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return n.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return n.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return n.script}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return n.send}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return n.transaction}}),Object.defineProperty(e,"validator",{enumerable:!0,get:function(){return n.validator}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return n.why}}),Object.defineProperty(e,"display",{enumerable:!0,get:function(){return i.display}}),Object.defineProperty(e,"sansPrefix",{enumerable:!0,get:function(){return i.sansPrefix}}),Object.defineProperty(e,"withPrefix",{enumerable:!0,get:function(){return i.withPrefix}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.VERSION=p,e.WalletUtils=dn,e.authenticate=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.authz=fn,e.currentUser=Me,e.discovery=sn,e.events=function(e){return{subscribe:function(n){return o.subscriber(e,Qe,n)}}},e.logIn=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(n,r){try{var o=Promise.resolve(function(e){try{return t.invariant(y(e),"mutate(opts) -- opts is required"),t.invariant(g(e),"mutate(opts) -- opts must be an object"),t.invariant(y(e.cadence),"mutate({ cadence }) -- cadence is required"),t.invariant(P(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){t.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(l.config().get("fcl.authz",Me().authorization)).then(function(n){return l.send([l.transaction(e.cadence),l.args(w(e.args||[])),e.limit&&E(e.limit)&&l.limit(e.limit),l.proposer(e.proposer||e.authz||n),l.payer(e.payer||e.authz||n),l.authorizations(e.authorizations||[e.authz||n])]).then(l.decode)})})}catch(e){return r(e)}return o&&o.then?o.then(void 0,r):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},e.query=R,e.reauthenticate=function(e){return void 0===e&&(e={}),Me().unauthenticate(),Me().authenticate(e)},e.serialize=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(n.config.first(["sdk.resolve"],t.resolve||n.resolve)).then(function(t){function r(){return Promise.resolve(t(e)).then(function(e){return JSON.stringify(n.createSignableVoucher(e),null,2)})}var o=function(){if(Array.isArray(e))return Promise.resolve(n.pipe(n.interaction(),e)).then(function(n){e=n})}();return o&&o.then?o.then(r):r()})}catch(e){return Promise.reject(e)}},e.signUp=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.t=pn,e.tx=Ge,e.unauthenticate=function(){return Me().unauthenticate()},e.verifyUserSignatures=ve});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/sdk"),require("@onflow/util-invariant"),require("@onflow/types"),require("@onflow/util-actor"),require("@onflow/util-address"),require("@onflow/rlp"),require("@onflow/util-uid"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/sdk","@onflow/util-invariant","@onflow/types","@onflow/util-actor","@onflow/util-address","@onflow/rlp","@onflow/util-uid","@onflow/util-template"],n):n((e||self).fcl={},e.sdk,e.utilInvariant,e.t$1,e.utilActor,e.utilAddress,e.rlp,e.utilUid,e.utilTemplate)}(this,function(e,n,t,r,o,i,a,s,u){function c(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}}),n.default=e,n}var l=c(n),d=c(r),f=c(a),p="0.0.79-alpha.2",h=function(e){try{return Promise.resolve(n.config().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var t=n[1];return[n[0].replace(e,""),t]}))})}catch(e){return Promise.reject(e)}},v={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":v});var m=function(e){return function(n){return typeof n===e}},y=function(e){return null!=e},g=m("object"),P=m("string"),b=m("function"),E=m("number");function w(e){return b(e)?e(l.arg,d):[]}var R=function(e){return void 0===e&&(e={}),Promise.resolve(function(e){try{return t.invariant(y(e.cadence),"query({ cadence }) -- cadence is required"),t.invariant(P(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){t.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return l.send([l.script(e.cadence),l.args(w(e.args||[])),e.limit&&"number"==typeof e.limit&&l.limit(e.limit)]).then(l.decode)})};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)}function A(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function I(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return A(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?A(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;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.")}var C={f_type:"Service",f_vsn:"1.0.0"},O={f_type:"Identity",f_vsn:"1.0.0"},j={f_type:"USER",f_vsn:"1.0.0"},D={f_type:"PollingResponse",f_vsn:"1.0.0"},N={f_type:"CompositeSignature",f_vsn:"1.0.0"};function k(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({old:e},C,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function x(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function L(e){return null==e?null:(null==e.method&&(e=S({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:S({},C,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var T={"back-channel-rpc":x,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},O,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},O,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:i.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:k,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":L,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return f.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var _=function(e){try{var n=(e=function(e){return e.addr=e.addr?i.withPrefix(e.addr):null,e.paddr=e.paddr?i.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",n),Promise.resolve(fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var t,r=I(e.authorizations);!(t=r()).done;)n.push(S({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&n.push(S({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(t){var r,o,a=(r=n,o=t,void 0===r&&(r=[]),void 0===o&&(o=[]),[].concat(r,o)).map(function(n){return function(e,n){try{return T[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return S({},j,{addr:i.withPrefix(e.addr),cid:F(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function U(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function B(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}return n}function M(e,n){void 0===n&&(n={});var t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(B(e),{method:t,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(function(e){return e.json()})}function V(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:S({},D,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||S({},e)||{},updates:x(e.authorizationUpdates),local:k((e.local||[])[0])})}var H=function e(n,r){void 0===r&&(r=function(){return!0});try{if(t.invariant(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(M(n,{method:W(n)}).then(V)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},z={"HTTP/GET":"GET","HTTP/POST":"POST"},W=function(e){return t.invariant(z[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),z[e.method]},K="FCL_IFRAME";function q(e){t.invariant(!document.getElementById(K),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=K,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(K)&&document.getElementById(K).remove()}]}var Y=null,J=null;function G(e){var n,t;return null==Y||null!=(n=Y)&&n.closed?(t=window,Y=t.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(t.top.outerHeight/2+t.top.screenY-385)+", left="+(t.top.outerWidth/2+t.top.screenX-320))):J!==e?(Y.location.replace(e),Y.focus()):Y.focus(),J=e,[Y,function(){Y&&!Y.closed&&Y.close(),Y=null}]}var $=null,X=null;function Z(e){var n;return null==$||null!=(n=$)&&n.closed?$=window.open(e,"_blank"):X!==e?($.location.replace(e),$.focus()):$.focus(),X=e,[$,function(){$&&!$.closed&&$.close(),$=null}]}var Q,ee={"VIEW/IFRAME":q,"VIEW/POP":G,"VIEW/TAB":Z},ne=function(e,n,t,r){try{return Promise.resolve(M(e,{data:S({fclVersion:p,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(V)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var t=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(ee[e.method](B(e),n))}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}catch(e){return Promise.reject(e)}}(L(n.local))).then(function(e){var r=e[1],o=function(){try{r(),t=!1}catch(e){console.error("Frame Close Error",e)}};return H(n.updates,function(){return t}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},te="FCL:VIEW:CLOSE",re="FCL:VIEW:READY",oe="FCL:VIEW:RESPONSE",ie=function(e){return"string"==typeof e&&e.toLowerCase()},ae=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),se=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},ue=function(e){var n=e.close,t=e.send,r=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(ae.has(e.data.type))return;ie(e.data.type)===ie(te)&&n(),ie(e.data.type)===ie(re)&&r(e,{send:t,close:n}),ie(e.data.type)===ie(oe)&&o(e,{send:t,close:n}),i(e,{send:t,close:n}),ie(e.data.type)===ie("FCL:FRAME:READY")&&(se(e.data.type,re),r(e,{send:t,close:n})),ie(e.data.type)===ie("FCL:FRAME:RESPONSE")&&(se(e.data.type,oe),o(e,{send:t,close:n})),ie(e.data.type)===ie("FCL:FRAME:CLOSE")&&(se(e.data.type,te),n()),ie(e.data.type)===ie("FCL::CHALLENGE::RESPONSE")&&(se(e.data.type,oe),o(e,{send:t,close:n})),ie(e.data.type)===ie("FCL::AUTHZ_READY")&&(se(e.data.type,re),r(e,{send:t,close:n})),ie(e.data.type)===ie("FCL::CHALLENGE::CANCEL")&&(se(e.data.type,te),n()),ie(e.data.type)===ie("FCL::CANCEL")&&(se(e.data.type,te),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ce=function(){},le=function(){},de=function(){},fe=function(){},pe=function e(n){var r=n.service,o=n.msg,i=void 0===o?{}:o,a=n.opts,s=void 0===a?{}:a,u=n.config,c=void 0===u?{}:u;try{return Promise.resolve(h(/^service\./)).then(function(n){return Promise.resolve(h(/^app\.detail\./)).then(function(o){var a=S({},c,{services:n,app:o});return function(n,o){try{var u=Promise.resolve(he[r.method](r,i,s,a)).then(function(n){return"REDIRECT"===n.status?(t.invariant(r.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:i,opts:s,config:a}))):n})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:r,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},he={"HTTP/RPC":ne,"HTTP/POST":ne,"IFRAME/RPC":function(e,n,t,r){return new Promise(function(o,i){var a,u=s.uid(),c=t.includeOlderJsonRpcCall;n.data=null!=(a=e.data)?a:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ce,close:ce};var t=n.onClose||ce;window.addEventListener("message",ue({close:a,send:s,onReady:n.onReady||ce,onResponse:n.onResponse||ce,onMessage:n.onMessage||ce}));var r=q(B(e)),o=r[0],i=r[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",ue),i(),t()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:p,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:u,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==u)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise(function(o,i){var a=s.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:le,close:le};var t=n.onClose||le;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||le,onResponse:n.onResponse||le,onMessage:n.onMessage||le}));var r=G(B(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),t()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise(function(o,i){var a=s.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:de,close:de};var t=n.onClose||de;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||de,onResponse:n.onResponse||de,onMessage:n.onMessage||de}));var r=Z(B(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),t()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise(function(t,o){!function(e,n){void 0===n&&(n={});try{var t,r=function(){try{window.removeEventListener("message",ue),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:fe,close:fe});var i=e.endpoint,a=n.onClose||fe;window.addEventListener("message",ue({close:r,send:o,onReady:n.onReady||fe,onResponse:n.onResponse||fe,onMessage:n.onMessage||fe})),Promise.resolve(null==(t=window[i])?void 0:t.flow.enable()).then(function(){return{send:o,close:r}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=V(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},ve=function(e,n){try{me(e,n);var t=n[0].addr,r=[],o=[];return n.map(function(e){r.push(e.signature),o.push(e.keyId)}),Promise.resolve(R({cadence:ye,args:function(n,i){return[n(t,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(r,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},me=function(e,n){return t.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),t.invariant(Array.isArray(n)&&n.every(function(e,n,t){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),t.invariant(n.map(function(e){return e.addr}).every(function(e,n,t){return e===t[0]}),"User signatures to be verified must be from a single account address"),!0},ye='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function ge(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},N,{addr:i.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function Pe(e,n,t){if(!e.s){if(t instanceof Ee){if(!t.s)return void(t.o=Pe.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(Pe.bind(null,e,n),Pe.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var be=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(ve(e,n))}catch(e){return Promise.reject(e)}},Ee=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{Pe(r,1,i(this.v))}catch(e){Pe(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Pe(r,1,n?n(o):o):t?Pe(r,1,t(o)):Pe(r,2,o)}catch(e){Pe(r,2,e)}},r},e}();function we(e){return e instanceof Ee&&1&e.s}var Re=function(e){try{return Le(),Promise.resolve(Ce({redir:!0})).then(function(n){var r=U(n.services,"user-signature");return t.invariant(r,"Current user must have authorized a signing service."),Se(function(){return Promise.resolve(pe({service:r,msg:Be(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return ge(e)}):[ge(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function Se(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var Ae=function(){return Promise.resolve(Ce()).then(function(e){return n.arg(i.withPrefix(e.addr),d.Address)})},Ie=function(e){try{return Le(),Promise.resolve(S({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ce({redir:!0})).then(function(t){var r;function o(n){if(r)return n;if(a)return S({},e,{tempId:"CURRENT_USER",resolve:null,addr:i.sansPrefix(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(pe({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(ge)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=U(t.services,"authz"),s=U(t.services,"pre-authz"),u=function(){if(s)return Promise.resolve(pe({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(var r,o=I(n.payer||[]);!(r=o()).done;)t.push(["PAYER",r.value]);for(var i,a=I(n.authorization||[]);!(i=a()).done;)t.push(["AUTHORIZER",i.value]);return t.map(function(e){var n=e[0],t=e[1];return{tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:function(e){return pe({service:t,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return r=1,n})}();return u&&u.then?u.then(o):o(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ce=function(e){var r=void 0===e?{}:e,i=r.service,a=r.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(e,r){try{return Le(),Promise.resolve(_e()).then(function(r){return Promise.resolve(Oe()).then(function(a){var u={redir:s};return Promise.resolve(function(){try{return Promise.resolve(n.config.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(t){return Promise.resolve(n.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:t}})})})}catch(e){return Promise.reject(e)}}()).then(function(c){var l=U(r.services,"authn-refresh");return Promise.resolve(n.config.get("fcl.warning.suppress.redir")).then(function(n){var d;function f(n){if(d)return n;var t=function(e,n){try{var t=Se(function(){return Promise.resolve(pe({service:S({},i||c,{method:(null==c?void 0:c.method)||i.method||"IFRAME/RPC"}),msg:a,opts:u,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return t&&t.then?t.then(n.bind(null,!1),n.bind(null,!0)):n(!1,t)}(0,function(n,t){return Promise.resolve(_e()).then(function(r){if(e(r),n)throw t;return t})});return t&&t.then?t.then(function(){}):void 0}s&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),t.invariant(i||c.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var p=function(){if(r.loggedIn){if(l)return function(e,n){try{var t=Se(function(){return Promise.resolve(pe({service:l,msg:a,opts:u})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(0,function(){return Promise.resolve(_e()).then(function(n){var t=e(n);return d=1,t})});var n=e(r);return d=1,n}}();return p&&p.then?p.then(f):f(p)})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Oe=function(){try{var e=Date.now();return Promise.resolve(n.config.get("fcl.appDomainTag")).then(function(n){return{timestamp:e,appDomainTag:n,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},je="CURRENT_USER",De="CURRENT_USER/UPDATED",Ne="SET_CURRENT_USER",ke='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',xe=((Q={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(ke)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){var t=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(ke);return Promise.resolve(e.get(je)).then(function(t){return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(je),n):t||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},Q[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,De,S({},e.all()))},Q[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Q.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Q[Ne]=function(e,t,r){try{return e.merge(r),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(De,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q.DEL_CURRENT_USER=function(e,t){try{return e.merge(JSON.parse(ke)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(De,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q),Le=function(){return o.spawn(xe,je)};function Te(){Le(),o.send(je,"DEL_CURRENT_USER")}function Fe(e){Le();var n="@EXIT",t=o.spawn(function(t){try{var r;return t.send(je,o.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(we(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!we(i)){r=1;break}i=i.s}}var a=new Ee,s=Pe.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):Pe(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||we(o)&&!o.v)return void Pe(a,1,i);if(o.then)return void o.then(c).then(void 0,s);we(i=t())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=t())&&i.then?i.then(u).then(void 0,s):u(i):Pe(a,1,i)}}(function(){return!r&&1},0,function(){return Promise.resolve(t.receive()).then(function(i){if(i.tag===n)return t.send(je,o.UNSUBSCRIBE),void(r=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return o.send(t,n)}}function _e(){return Le(),o.send(je,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ue,Be=function(e){return t.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Me=function(){return{authenticate:Ce,unauthenticate:Te,authorization:Ie,signUserMessage:Re,verifyUserSignatures:be,subscribe:Fe,snapshot:_e,resolveArgument:Ae}};Me.authenticate=Ce,Me.unauthenticate=Te,Me.authorization=Ie,Me.signUserMessage=Re,Me.verifyUserSignatures=be,Me.subscribe=Fe,Me.snapshot=_e,Me.resolveArgument=Ae;var Ve="POLL",He=function(e){try{return Promise.resolve(n.send([n.getTransactionStatus(e)]).then(n.decode))}catch(e){return Promise.reject(e)}},ze=function(e){return e.status>=4},We=function(e){return e.status>=3},Ke=function(e){return e.status>=2},qe=((Ue={})[o.INIT]=function(e){try{return Promise.resolve(He(e.self())).then(function(n){ze(n)||setTimeout(function(){return e.sendSelf(Ve)},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Ue[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,o.UPDATED,e.all())},Ue[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Ue[o.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ue.POLL=function(e){try{return Promise.resolve(He(e.self())).then(function(n){var t,r;ze(n)||setTimeout(function(){return e.sendSelf(Ve)},2500),t=e.all(),r=n,JSON.stringify(t)!==JSON.stringify(r)&&e.broadcast(o.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Ue),Ye=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},Je=function(e){return o.spawn(qe,Ye(e))};function Ge(e){function n(n){return o.subscriber(Ye(e),Je,n)}function t(e){return function(t){void 0===t&&(t={});var r=t.suppress||!1;return new Promise(function(t,o){var i=n(function(n){n.statusCode&&!r?(o(n.errorMessage),i()):e(n)&&(t(n),i())})})}}return{snapshot:function(){return o.snapshoter(e,Je)},subscribe:n,onceFinalized:t(Ke),onceExecuted:t(We),onceSealed:t(ze)}}Ge.isUnknown=function(e){return e.status>=0},Ge.isPending=function(e){return e.status>=1},Ge.isFinalized=Ke,Ge.isExecuted=We,Ge.isSealed=ze,Ge.isExpired=function(e){return 5===e.status};var $e,Xe=function(e){try{var t=setTimeout;return Promise.resolve(n.config().get("fcl.eventPollRate",1e4)).then(function(n){return t(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},Ze=(($e={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var t=e.get("hwm"),r=function(){if(null==t){var r=e.put;return Promise.resolve(n.latestBlock()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(Xe(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(n.latestBlock()).then(function(r){return e.put("hwm",r),Promise.resolve(n.send([n.getEvents(e.self(),t.height,r.height-1)]).then(n.decode)).then(function(n){for(var t,r=I(n);!(t=r()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(Xe(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},$e[o.SUBSCRIBE]=function(e,n){try{var t=function(){e.subscribe(n.from)},r=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Xe(e)).then(function(t){n.call(e,"tick",t)})}}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},$e[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},$e),Qe=function(e){return o.spawn(Ze,e)},en=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.config.get("discovery.authn.endpoint")).then(function(r){return t.invariant(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(n){var t=new URL(r);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:p,include:n})}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function nn(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var tn,rn="authn",on=((tn={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:rn},t=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(en,nn,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,t)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,t},tn[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",S({},e.all()))},tn[o.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},tn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(S({},e.all())))}catch(e){return Promise.reject(e)}},tn),an=function(){return o.spawn(on,rn)},sn={authn:{subscribe:function(e){return o.subscriber(rn,an,e)},snapshot:function(){return o.snapshoter(rn,an)}}},un=function(e,n){void 0===n&&(n=function(){});var t=function(t){var r=t.data;"object"==typeof r&&null!=typeof r&&r.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(r))};return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},cn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(S({},n,{type:e}),"*"):window.opener.postMessage(S({},n,{type:e}),"*")},ln=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},dn={__proto__:null,sendMsgToFCL:cn,ready:function(e,n){un("FCL:VIEW:READY:RESPONSE",e),cn("FCL:VIEW:READY")},close:function(){cn("FCL:VIEW:CLOSE")},approve:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:un,encodeMessageFromSignable:n.encodeMessageFromSignable,CompositeSignature:function(e,n,t){this.f_type=N.f_type,this.f_vsn=N.f_vsn,this.addr=i.withPrefix(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),t.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),t.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o=ln(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=ln(Buffer.from(r).toString("hex"),32).toString("hex");return o+(r?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),t.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),t.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o,s=r?(o=Buffer.from(r).toString("hex"),Buffer.from(o.padEnd(64,0),"hex")).toString("hex"):null;return r?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},fn=Me().authorization,pn=d;Object.defineProperty(e,"TestUtils",{enumerable:!0,get:function(){return n.TestUtils}}),Object.defineProperty(e,"account",{enumerable:!0,get:function(){return n.account}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return n.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return n.args}}),Object.defineProperty(e,"atBlockHeight",{enumerable:!0,get:function(){return n.atBlockHeight}}),Object.defineProperty(e,"atBlockId",{enumerable:!0,get:function(){return n.atBlockId}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return n.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return n.authorizations}}),Object.defineProperty(e,"block",{enumerable:!0,get:function(){return n.block}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"createSignableVoucher",{enumerable:!0,get:function(){return n.createSignableVoucher}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return n.decode}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return n.getAccount}}),Object.defineProperty(e,"getBlock",{enumerable:!0,get:function(){return n.getBlock}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return n.getBlockByHeight}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return n.getBlockById}}),Object.defineProperty(e,"getBlockHeader",{enumerable:!0,get:function(){return n.getBlockHeader}}),Object.defineProperty(e,"getCollection",{enumerable:!0,get:function(){return n.getCollection}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return n.getEvents}}),Object.defineProperty(e,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return n.getEventsAtBlockHeightRange}}),Object.defineProperty(e,"getEventsAtBlockIds",{enumerable:!0,get:function(){return n.getEventsAtBlockIds}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return n.getLatestBlock}}),Object.defineProperty(e,"getTransaction",{enumerable:!0,get:function(){return n.getTransaction}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return n.getTransactionStatus}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n.invariant}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(e,"latestBlock",{enumerable:!0,get:function(){return n.latestBlock}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return n.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return n.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return n.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return n.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return n.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return n.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return n.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return n.script}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return n.send}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return n.transaction}}),Object.defineProperty(e,"validator",{enumerable:!0,get:function(){return n.validator}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return n.why}}),Object.defineProperty(e,"display",{enumerable:!0,get:function(){return i.display}}),Object.defineProperty(e,"sansPrefix",{enumerable:!0,get:function(){return i.sansPrefix}}),Object.defineProperty(e,"withPrefix",{enumerable:!0,get:function(){return i.withPrefix}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.VERSION=p,e.WalletUtils=dn,e.authenticate=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.authz=fn,e.currentUser=Me,e.discovery=sn,e.events=function(e){return{subscribe:function(n){return o.subscriber(e,Qe,n)}}},e.logIn=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(n,r){try{var o=Promise.resolve(function(e){try{return t.invariant(y(e),"mutate(opts) -- opts is required"),t.invariant(g(e),"mutate(opts) -- opts must be an object"),t.invariant(y(e.cadence),"mutate({ cadence }) -- cadence is required"),t.invariant(P(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){t.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(l.config().get("fcl.authz",Me().authorization)).then(function(n){return l.send([l.transaction(e.cadence),l.args(w(e.args||[])),e.limit&&E(e.limit)&&l.limit(e.limit),l.proposer(e.proposer||e.authz||n),l.payer(e.payer||e.authz||n),l.authorizations(e.authorizations||[e.authz||n])]).then(l.decode)})})}catch(e){return r(e)}return o&&o.then?o.then(void 0,r):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},e.query=R,e.reauthenticate=function(e){return void 0===e&&(e={}),Me().unauthenticate(),Me().authenticate(e)},e.serialize=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(n.config.first(["sdk.resolve"],t.resolve||n.resolve)).then(function(t){function r(){return Promise.resolve(t(e)).then(function(e){return JSON.stringify(n.createSignableVoucher(e),null,2)})}var o=function(){if(Array.isArray(e))return Promise.resolve(n.pipe(n.interaction(),e)).then(function(n){e=n})}();return o&&o.then?o.then(r):r()})}catch(e){return Promise.reject(e)}},e.signUp=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.t=pn,e.tx=Ge,e.unauthenticate=function(){return Me().unauthenticate()},e.verifyUserSignatures=ve});
//# sourceMappingURL=fcl.umd.js.map
{
"name": "@onflow/fcl",
"version": "0.0.79-alpha.1",
"version": "0.0.79-alpha.2",
"description": "Flow Client Library",

@@ -45,3 +45,3 @@ "license": "Apache-2.0",

"@onflow/rlp": "0.0.3",
"@onflow/sdk": "0.0.57-alpha.1",
"@onflow/sdk": "0.0.57-alpha.2",
"@onflow/types": "0.0.6",

@@ -48,0 +48,0 @@ "@onflow/util-actor": "0.0.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc