gun-eth 1.3.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/README.md +18 -207
  2. package/dist/gun-eth-protocol.cjs.js +11528 -0
  3. package/dist/gun-eth-protocol.esm.js +11503 -0
  4. package/dist/gun-eth-protocol.js +18 -0
  5. package/dist/gun-eth-protocol.react.js +11503 -0
  6. package/dist/gun-eth-protocol.umd.js +18 -0
  7. package/jsdoc.json +7 -0
  8. package/package.json +28 -25
  9. package/rollup.config.js +80 -0
  10. package/src/index.js +160 -512
  11. package/src/lib/authentication/index.js +13 -0
  12. package/src/lib/authentication/isAuthenticated.js +20 -0
  13. package/src/lib/authentication/login.js +25 -0
  14. package/src/lib/authentication/register.js +58 -0
  15. package/src/lib/blockchain/ethereum.js +74 -0
  16. package/src/lib/blockchain/shine.js +204 -0
  17. package/src/lib/certificates/friendsCertificates.js +92 -0
  18. package/src/lib/certificates/index.js +44 -0
  19. package/src/lib/certificates/messagingCertificates.js +94 -0
  20. package/src/lib/friends/acceptFriendRequest.js +69 -0
  21. package/src/lib/friends/addFriendRequest.js +49 -0
  22. package/src/lib/friends/friendRequests.js +51 -0
  23. package/src/lib/friends/friendsList.js +57 -0
  24. package/src/lib/friends/index.js +36 -0
  25. package/src/lib/friends/rejectFriendRequest.js +31 -0
  26. package/src/lib/messaging/chatsList.js +42 -0
  27. package/src/lib/messaging/createChat.js +132 -0
  28. package/src/lib/messaging/index.js +36 -0
  29. package/src/lib/messaging/messageList.js +106 -0
  30. package/src/lib/messaging/sendMessage.js +132 -0
  31. package/src/lib/messaging/sendVoiceMessage.js +119 -0
  32. package/src/lib/notes/createNote.js +41 -0
  33. package/src/lib/notes/deleteNote.js +12 -0
  34. package/src/lib/notes/getNote.js +25 -0
  35. package/src/lib/notes/getUserNote.js +59 -0
  36. package/src/lib/notes/index.js +8 -0
  37. package/src/lib/notes/updateNotes.js +35 -0
  38. package/src/lib/post/createPost.js +17 -0
  39. package/src/lib/post/decryptPost.js +14 -0
  40. package/src/lib/post/deletePost.js +13 -0
  41. package/src/lib/post/encryptPost,js +16 -0
  42. package/src/lib/post/getPost.js +36 -0
  43. package/src/lib/post/index.js +9 -0
  44. package/src/lib/post/updatePost.js +16 -0
  45. package/src/state/gun.js +33 -0
  46. package/types/types.d.ts +244 -0
  47. package/TUTORIAL.md +0 -103
  48. package/src/examples/eth2gun.html +0 -163
  49. package/src/examples/gun2eth.html +0 -164
  50. package/src/examples/shine.html +0 -256
  51. /package/src/{abis → lib/blockchain/abis}/SHINE.json +0 -0
  52. /package/src/{contracts → lib/blockchain/contracts}/SHINE.sol +0 -0
@@ -0,0 +1,18 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fs"),require("path"),require("url"),require("events"),require("https"),require("http"),require("net"),require("tls"),require("crypto"),require("stream"),require("zlib"),require("os"),require("child_process"),require("ethers")):"function"==typeof define&&define.amd?define(["exports","fs","path","url","events","https","http","net","tls","crypto","stream","zlib","os","child_process","ethers"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["gun-ethProtocol"]={},e.require$$0,e.require$$1,e.require$$7,e.require$$0$3,e.require$$1$1,e.require$$2,e.require$$3,e.require$$4,e.require$$5,e.require$$0$2,e.require$$0$1,e.require$$1$2,e.require$$4$1,e.ethers)}(this,(function(e,t,r,n,o,i,s,a,c,u,f,l,d,p,h){"use strict";function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=g(t),v=g(r),m=g(n),w=g(o),b=g(i),_=g(s),S=g(a),k=g(c),x=g(u),T=g(f),E=g(l),A=g(d),O=g(p),D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function C(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var N={exports:{}};!function(e){!function(){function t(e,r){return r?C(e):e.slice?t[n(e)]:function(r,o){e(r={exports:{}}),t[n(o)]=r.exports};function n(e){return e.split("/").slice(-1).toString().replace(".js","")}}var r=e;t((function(e){String.random=function(e,t){var r="";for(e=e||24,t=t||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";e-- >0;)r+=t.charAt(Math.floor(Math.random()*t.length));return r},String.match=function(e,t){var r,n;return"string"==typeof e&&("string"==typeof t&&(t={"=":t}),e===(r=(t=t||{})["="]||t["*"]||t[">"]||t["<"])||n===t["="]&&(r=t["*"]||t[">"],e.slice(0,(r||"").length)===r||n===t["*"]&&(n!==t[">"]&&n!==t["<"]?e>=t[">"]&&e<=t["<"]:n!==t[">"]&&e>=t[">"]||n!==t["<"]&&e<=t["<"])))},String.hash=function(e,t){if("string"==typeof e){if(t=t||0,!e.length)return t;for(var r=0,n=e.length;r<n;++r)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t}};var t,r,n,o,i=Object.prototype.hasOwnProperty;Object.plain=function(e){return!!e&&(e instanceof Object&&e.constructor===Object||"Object"===Object.prototype.toString.call(e).match(/^\[object (\w+)\]$/)[1])},Object.empty=function(e,t){for(var r in e)if(i.call(e,r)&&(!t||-1==t.indexOf(r)))return!1;return!0},Object.keys=Object.keys||function(e){var t=[];for(var r in e)i.call(e,r)&&t.push(r);return t},t=setTimeout,r=0,n=0,o=typeof setImmediate!=""+void 0&&setImmediate||t,t.poll=t.poll||function(e){1>=+new Date-r&&n++<3333?e():o((function(){r=+new Date,e()}),n=0)},function(){var e,t=setTimeout,r=t.turn=t.turn||function(e){1==n.push(e)&&o(s)},n=r.s=[],o=t.poll,i=0,s=function(){(e=n[i++])&&e(),i!=n.length&&99!=i||(n=r.s=n.slice(i),i=0),n.length&&o(s)}}(),function(){var e,t=setTimeout,r=t.turn;(t.each=t.each||function(t,n,o,i){i=i||9,function s(a,c,u){if(c=(a=(t||[]).splice(0,i)).length){for(var f=0;f<c&&e===(u=n(a[f]));f++);if(e===u)return void r(s)}o&&o(u)}()})()}()}))(t,"./shim"),t((function(e){e.exports=function e(t,r,n){if(!t)return{to:e};var o="function"==typeof r;t=(this.tag||(this.tag={}))[t]||o&&(this.tag[t]={tag:t,to:e._={next:function(e){var t;(t=this.to)&&t.next(e)}}});if(o){var i={off:e.off||(e.off=function(){if(this.next===e._.next)return!0;this===this.the.last&&(this.the.last=this.back),this.to.back=this.back,this.next=e._.next,this.back.to=this.to,this.the.last===this.the&&delete this.on.tag[this.the.tag]}),to:e._,next:r,the:t,on:this,as:n};return(i.back=t.last||t).to=i,t.last=i}return(t=t.to)&&undefined!==r&&t.next(r),t}}))(t,"./onto"),t((function(e){t("./shim"),e.exports=function(e){return void 0!==e&&(null===e||e!==1/0&&(e==e&&("string"==typeof e||"boolean"==typeof e||"number"==typeof e||!(!e||"string"!=typeof(e["#"]||0)||!Object.empty(e,["#"]))&&e["#"])))}}))(t,"./valid"),t((function(e){function r(){var e=+new Date;return a<e?(i=0,a=e+r.drift):a=e+(i+=1)/s+r.drift}t("./shim"),r.drift=0;var n,o=-1/0,i=0,s=999,a=o;r.is=function(e,t,r){var n=t&&e&&e._&&e._[">"]||r;if(n)return"number"==typeof(n=n[t])?n:o},r.ify=function(e,t,r,o,i){(e=e||{})._=e._||{},i&&(e._["#"]=i);var s=e._[">"]||(e._[">"]={});return n!==t&&"_"!==t&&("number"==typeof r&&(s[t]=r),n!==o&&(e[t]=o)),e},e.exports=r}))(t,"./state"),t((function(e){t("./shim"),e.exports=function(e){var t={s:{}},r=t.s;e=e||{max:999,age:9e3},t.check=function(e){return!!r[e]&&n(e)};var n=t.track=function(n){var o=r[n]||(r[n]={});return o.was=t.now=+new Date,t.to||(t.to=setTimeout(t.drop,e.age+9)),o};return t.drop=function(n){t.to=null,t.now=+new Date;var o=Object.keys(r);console.STAT&&console.STAT(t.now,+new Date-t.now,"dup drop keys"),setTimeout.each(o,(function(o){var i=r[o];i&&(n||e.age)>t.now-i.was||delete r[o]}),0,99)},t}}))(t,"./dup"),t((function(e){t("./onto"),e.exports=function(e,t){if(this.on){var n=(this.opt||{}).lack||9e3;if("function"!=typeof e){if(!e)return;var o=e["#"]||e,i=(this.tag||"")[o];if(!i)return;return t&&(i=this.on(o,t),clearTimeout(i.err),i.err=setTimeout((function(){i.off()}),n)),!0}o=t&&t["#"]||r(9);if(!e)return o;var s=this.on(o,e,t);return s.err=s.err||setTimeout((function(){s.off(),s.next({err:"Error: No ACK yet.",lack:!0})}),n),o}};var r=String.random||function(){return Math.random().toString(36).slice(2)}}))(t,"./ask"),t((function(e){function n(e){return e instanceof n?(this._={$:this}).$:this instanceof n?n.create(this._={$:this,opt:e}):new n(e)}n.is=function(e){return e instanceof n||e&&e._&&e===e._.$||!1},n.version=.202,n.chain=n.prototype,n.chain.toJSON=function(){},t("./shim"),n.valid=t("./valid"),n.state=t("./state"),n.on=t("./onto"),n.dup=t("./dup"),n.ask=t("./ask"),function(){function e(r){if(r)if(r.out!==e){var o,i=this.as,c=i.at||i,u=c.$,f=c.dup,l=r.DBG;if((o=r["#"])||(o=r["#"]=a(9)),!f.check(o)){if(f.track(o),o=r._,r._="function"==typeof o?o:function(){},r.$&&r.$===(r.$._||"").$||(r.$=u),r["@"]&&!r.put&&function(e){var t,r=e["@"]||"";if(!(t=r._))return;t.acks=(t.acks||0)+1,(t.err=e.err)&&(e["@"]=t["#"],s(t));t.stop||t.crack||(t.crack=t.match&&t.match.push((function(){p(t)})));p(t)}(r),!c.ask(r["@"],r)){if(l&&(l.u=+new Date),r.put)return void t(r);r.get&&n.on.get(r,u)}l&&(l.uc=+new Date),this.to.next(r),l&&(l.ua=+new Date),r.nts||r.NTS||(r.out=e,c.on("out",r),l&&(l.ue=+new Date))}}else this.to.next(r)}function t(t){if(t){var n=t._||"",i=n.root=((n.$=t.$||"")._||"").root;if(t["@"]&&n.faith&&!n.miss)return t.out=e,void i.on("out",t);n.latch=i.hatch,n.match=i.hatch=[];var a=t.put,f=n.DBG=t.DBG,l=+new Date;if(!a["#"]||!a["."]){f&&(f.p=l),n["#"]=t["#"],n.msg=t,n.all=0,n.stun=1;var d=Object.keys(a);console.STAT&&console.STAT(l,((f||n).pk=+new Date)-l,"put sort");var p,y,v,m,w,b,_,S=0;!function e(i){if(p!=S){if(p=S,!(v=d[S]))return console.STAT&&console.STAT(l,((f||n).pd=+new Date)-l,"put"),void s(n);(m=a[v])?(_=m._)?v!==_["#"]?b=h+g(v)+"soul not same.":(w=_[">"])||(b=h+g(v)+"no state."):b=h+g(v)+"no meta.":b=h+g(v)+"no node.",y=Object.keys(m||{})}if(b)return t.err=n.err=b,void s(n);var k,x=0;for(i=i||0;i++<9&&(k=y[x++]);)if("_"!==k){var T=m[k],E=w[k];if(o===E){b=h+g(k)+"on"+g(v)+"no state.";break}if(!u(T)){b=h+g(k)+"on"+g(v)+"bad "+typeof T+g(T);break}r(T,k,v,E,t)}(y=y.slice(x)).length?c(e):(++S,y=null,e(i))}()}}}function r(e,t,n,o,i){var s,a=i._||"",c=a.root,u=c.graph,l=u[n]||d,p=f(l,t,1),h=l[t],g=a.DBG;(s=console.STAT)&&(u[n]&&h||(s.has=(s.has||0)+1));var w=m();if(o>w)return setTimeout((function(){r(e,t,n,o,i)}),(s=o-w)>v?v:s),void(console.STAT&&console.STAT((g||a).Hf=+new Date,s,"future"));if((!(o<p)||a.miss)&&(a.faith||o!==p||!(e===h||y(e)<=y(h))||a.miss)){a.stun++;var b=i["#"]+a.all++,_={toString:function(){return b},_:a};_.toJSON=_.toString,g&&(g.ph=g.ph||+new Date),c.on("put",{"#":_,"@":i["@"],put:{"#":n,".":t,":":e,">":o},_:a})}}function i(e){var t;(t=(e._||"").DBG)&&(t.pa=+new Date,t.pm=t.pm||+new Date);var r,n=this.as,o=n.graph,i=e._,a=e.put,c=a["#"],u=a["."],f=a[":"],d=a[">"];e["#"],(r=i.msg)&&(r=r.put)&&(r=r[c])&&l(r,u,d,f,c),o[c]=l(o[c],u,d,f,c),(r=(n.next||"")[c])&&r.on("in",e),s(i),this.to.next(e)}function s(t,r){var n;if(!t.stop&&(t.err||!(0<--t.stun))&&(t.stop=1,n=t.root)){var o=t.match;o.end=1,o===n.hatch&&(!(o=t.latch)||o.end?delete n.hatch:n.hatch=o),t.hatch&&t.hatch(),setTimeout.each(t.match,(function(e){e&&e()})),!(r=t.msg)||t.err||r.err||(r.out=e,t.root.on("out",r))}}function p(e){e&&e.root&&(e.stun||e.acks!==e.all||e.root.on("in",{"@":e["#"],err:e.err,ok:e.err?o:{"":1}}))}n.create=function(t){t.root=t.root||t,t.graph=t.graph||{},t.on=t.on||n.on,t.ask=t.ask||n.ask,t.dup=t.dup||n.dup();var r=t.$.opt(t.opt);return t.once||(t.on("in",e,t),t.on("out",e,t),t.on("put",i,t),n.on("create",t),t.on("create",t)),t.once=1,r},n.on.put=t;var h="Error: Invalid graph!",g=function(e){return" '"+(""+e).slice(0,9)+"...' "},y=JSON.stringify,v=2147483647,m=n.state}(),function(){function e(e,t){var r=+new Date,n=e._||{},i=n.DBG=e.DBG,s=e["#"],c=a(9),u=Object.keys(t||"").sort(),d=((t||"")._||"")["#"];u.length;var p=e.$._.root,h=t===p.graph[d];console.STAT&&console.STAT(r,((i||n).gk=+new Date)-r,"got keys"),t&&function e(){r=+new Date;for(var n,g,y,v=0,m={};v<9&&(n=u[v++]);)l(m,n,f(t,n),t[n],d);u=u.slice(v),(g={})[d]=m,m=g,h&&((y=function(){}).ram=y.faith=!0),g=u.length,console.STAT&&console.STAT(r,-(r-(r=+new Date)),"got copied some"),i&&(i.ga=+new Date),p.on("in",{"@":s,"#":c,put:m,"%":g?c=a(9):o,$:p.$,_:y,DBG:i}),console.STAT&&console.STAT(r,+new Date-r,"got in"),g&&setTimeout.turn(e)}(),t||p.on("in",{"@":e["#"]})}n.on.get=function(t,r){var n=r._,i=t.get,s=i["#"],a=n.graph[s],c=i["."];(n.next||(n.next={}))[s];var u=(t._||{}).DBG=t.DBG;if(u&&(u.g=+new Date),!a)return n.on("get",t);if(c){if("string"!=typeof c||o===a[c])return n.on("get",t);a=l({},c,f(a,c),a[c],s)}a&&e(t,a),n.on("get",t)},n.on.get.ack=e}(),n.chain.opt=function(e){e=e||{};var t=this._,r=e.peers||e;return Object.plain(e)||(e={}),Object.plain(t.opt)||(t.opt=e),"string"==typeof r&&(r=[r]),r instanceof Array&&(Object.plain(t.opt.peers)||(t.opt.peers={}),r.forEach((function(e){var r={};r.id=r.url=e,t.opt.peers[e]=t.opt.peers[e]||r}))),t.opt.peers=t.opt.peers||{},s(e,(function e(t){var r=this[t];this&&this.hasOwnProperty(t)||"string"==typeof r||Object.empty(r)?this[t]=r:(!r||r.constructor===Object||r instanceof Array)&&s(r,e)})),n.on("opt",t),t.opt.uuid=t.opt.uuid||function(e){return n.state().toString(36).replace(".","")+String.random(e||12)},this};var o,i,s=function(e,t){Object.keys(e).forEach(t,e)},a=String.random,c=setTimeout.turn,u=n.valid,f=n.state.is,l=n.state.ify,d={};n.log=function(){return!n.log.off&&i.log.apply(i,arguments),[].slice.call(arguments).join(" ")},n.log.once=function(e,t,r){return(r=n.log.once)[e]=r[e]||0,r[e]++||n.log(t)},"undefined"!=typeof window&&((window.GUN=window.Gun=n).window=window);try{void 0!==r&&(r.exports=n)}catch(e){}e.exports=n,(n.window||{}).console=(n.window||{}).console||{log:function(){}},(i=console).only=function(e,t){return i.only.i&&e===i.only.i&&i.only.i++&&(i.log.apply(i,arguments)||t)},n.log.once("welcome","Hello wonderful person! :) Thanks for using GUN, please ask for help on http://chat.gun.eco if anything takes you longer than 5min to figure out!")}))(t,"./root"),t((function(e){t("./root").chain.back=function(e,t){if(-1===(e=e||1)||1/0===e)return this._.root.$;if(1===e)return(this._.back||this._).$;var o=this._;if("string"==typeof e&&(e=e.split(".")),e instanceof Array){for(var i=0,s=e.length,a=o;i<s;i++)a=(a||n)[e[i]];return r!==a?t?this:a:(a=o.back)?a.$.back(e,t):void 0}if("function"==typeof e){var c;for(a={back:o};(a=a.back)&&r===(c=e(a,t)););return c}return"number"==typeof e?(o.back||o).$.back(e-1):this};var r,n={}}))(t,"./back"),t((function(e){var r=t("./root");function n(e,t){if(t=t||this.as||e.$._,(!e.$$||this===r.on)&&e.put&&!t.soul){var n=e.put||"",o=n["="]||n[":"],i=t.root,s=i.$.get(n["#"]).get(n["."])._;if("string"==typeof(o=u(o))){if(!(s.echo||(s.echo={}))[t.id]||(i.pass||"")[t.id]){if(a=i.pass){if(a[o+t.id])return;a[o+t.id]=1}(s.echo||(s.echo={}))[t.id]=t,t.has&&(t.link=o);var a,c=i.$.get(s.link=o)._;(c.echo||(c.echo={}))[s.id]=s,((a=t.ask||"")[""]||t.lex)&&c.on("out",{get:{"#":o}}),setTimeout.each(Object.keys(a),(function(e,t){e&&(t=a[e])&&t.on("out",{get:{"#":o,".":e}})}),0,99)}}else this===r.on&&((s.echo||(s.echo={}))[t.id]=t)}}function o(e,t){var r,n,i=e.put||"",a=s!==i["="]?i["="]:i[":"],c=t.root;if(s===a){if(t.soul&&s!==t.put)return;if(n=(e.$$||e.$||"")._||"",e["@"]&&(s!==n.put||s!==t.put))return;return(r=t.link||e.linked)&&delete(c.$.get(r)._.echo||"")[t.id],t.has&&(t.link=null),t.put=s,void setTimeout.each(Object.keys(t.next||""),(function(e,n){(n=t.next[e])&&(r&&delete(c.$.get(r).get(e)._.echo||"")[n.id],n.on("in",{get:e,put:s,$:n.$}))}),0,99)}t.soul||e.$$||(r=u(a),n=e.$._||"",(r!==n.link&&(!t.has||n.link)||(c.pass||"")[t.id]&&"string"!=typeof r)&&(delete(n.echo||"")[t.id],o({get:t.get,put:s,$:e.$,linked:e.linked=e.linked||n.link},t)))}function i(e,t){var n=this.as,o=n.$._;o.root;var i=n.get||"",a=(e.put||"")[i["#"]]||"";if(!e.put||"string"==typeof i["."]&&s===a[i["."]]){if(s!==o.put)return;if(!o.soul&&!o.has)return;return o.ack=(o.ack||0)+1,void o.on("in",{get:o.get,put:o.put=s,$:o.$,"@":e["@"]})}(e._||{}).miss=1,r.on.put(e)}r.chain.chain=function(e){var t,n=this,o=n._,i=new(e||n).constructor(n),s=i._;return s.root=t=o.root,s.id=++t.once,s.back=n._,s.on=r.on,s.on("in",r.on.in,s),s.on("out",r.on.out,s),i},r.on.out=function(e){var t,r,n=this.as,o=n.back,a=n.root;if(e.$||(e.$=n.$),this.to.next(e),!n.err){if(t=e.get){if(a.pass&&(a.pass[n.id]=n),n.lex&&Object.keys(n.lex).forEach((function(e){r[e]=n.lex[e]}),r=e.get=e.get||{}),t["#"]||n.soul){if(t["#"]=t["#"]||n.soul,e["#"]||(e["#"]=c(9)),o=a.$.get(t["#"])._,t=t["."]){if(f(o.put,t)&&(r=o.ask&&o.ask[t],(o.ask||(o.ask={}))[t]=o.$.get(t)._,o.on("in",{get:t,put:{"#":o.soul,".":t,":":o.put[t],">":d(a.graph[o.soul],t)}}),r))return}else{if(r=o.ask&&o.ask[""],(o.ask||(o.ask={}))[""]=o,s!==o.put&&(o.on("in",o),r))return;e.$=o.$}return a.ask(i,e),a.on("in",e)}if(t["."])return n.get?(e={get:{".":n.get},$:n.$},(o.ask||(o.ask={}))[n.get]=e.$._,o.on("out",e)):(e={get:n.lex?e.get:{},$:n.$},o.on("out",e));if((n.ask||(n.ask={}))[""]=n,n.get)return t["."]=n.get,(o.ask||(o.ask={}))[n.get]=e.$._,o.on("out",e)}return o.on("out",e)}n.on("in",{put:n.put=s,$:n.$})},r.on.in=function(e,t){var r,i=(t=t||this.as).root,c=e.$||(e.$=t.$),f=(c||"")._||a,l=e.put||"",h=l["#"],g=l["."],y=s!==l["="]?l["="]:l[":"],v=l[">"]||-1/0;if(s!==e.put&&(s===l["#"]||s===l["."]||s===l[":"]&&s===l["="]||s===l[">"]))return u(l)?void t.on("in",{$:f.back.$,put:{"#":h=f.back.soul,".":g=f.has||f.get,"=":l,">":d(f.back.put,g)},via:e}):(h=((l||"")._||"")["#"])?(c=t.root.$.get(h),setTimeout.each(Object.keys(l).sort(),(function(r){"_"!=r&&s!==(v=d(l,r))&&t.on("in",{$:c,put:{"#":h,".":r,"=":l[r],">":v},VIA:e})}))):void console.log("chain not yet supported for",l,"...",e,t);(e.seen||"")[t.id]||((e.seen||(e.seen=function(){}))[t.id]=t,t!==f&&(Object.keys(e).forEach((function(t){l[t]=e[t]}),l={}),l.get=t.get||l.get,t.soul||t.has?f.soul&&(l.$=t.$,l.$$=l.$$||f.$):l.$$$=l.$$$||t.$,e=l),o(e,t),(t.soul||e.$$)&&v>=d(i.graph[h],g)&&((l=i.$.get(h)._).put=p(l.put,g,v,y,h)),!f.soul&&v>=d(i.graph[h],g)&&(r=(i.$.get(h)._.next||"")[g])&&(r.put=y,"string"==typeof(l=u(y))&&(r.put=i.$.get(l)._.put||y)),this.to&&this.to.next(e),t.any&&setTimeout.each(Object.keys(t.any),(function(r){(r=t.any[r])&&r(e)}),0,99),t.echo&&setTimeout.each(Object.keys(t.echo),(function(r){(r=t.echo[r])&&r.on("in",e)}),0,99),((e.$$||"")._||f).soul&&(r=t.next)&&(r=r[g])&&(l={},Object.keys(e).forEach((function(t){l[t]=e[t]})),l.$=(e.$$||e.$).get(l.get=g),delete l.$$,delete l.$$$,r.on("in",l)),n(e,t))},r.on.link=n,r.on.unlink=o;var s,a={},c=String.random,u=r.valid,f=function(e,t){return e&&Object.prototype.hasOwnProperty.call(e,t)},l=r.state,d=l.is,p=l.ify}))(t,"./chain"),t((function(e){var r=t("./root");function n(e){var t=this.at||this.on;if(!e||t.soul||t.has)return this.off();if(e=(e=(e=e.$||e)._||e).id){var r;if(t.map,(r=this.seen||(this.seen={}))[e])return!0;r[e]=!0}}r.chain.get=function(e,t,a){var c,u;if("string"==typeof e){if(0==e.length)return(c=this.chain())._.err={err:r.log("0 length key!",e)},t&&t.call(c,c._.err),c;(c=((l=this._).next||i)[e])||(c=e&&function(e,t){var r=t._,n=r.next,o=t.chain(),i=o._;n||(n=r.next={});n[i.get=e]=i,t===r.root.$?i.soul=e:(r.soul||r.has)&&(i.has=e);return i}(e,this)),c=c&&c.$}else{if("function"==typeof e){if(!0===t)return function(e,t,n,i){var s,a=e._,c=0;if(s=a.soul||a.link)return t(s,i,a);if(a.jam)return a.jam.push([t,i]);a.jam=[[t,i]],e.get((function(e,t){if(!(o===e.put&&!a.root.opt.super&&(s=Object.keys(a.root.opt.peers).length)&&++c<=s)){t.rid(e);var n,i=(i=e.$)&&i._||{},u=0;for(s=a.jam,delete a.jam;n=s[u++];){var f=n[0];n=n[1],f&&f(i.link||i.soul||r.valid(e.put)||((e.put||{})._||{})["#"],n,e,t)}}}),{out:{get:{".":!0}}})}(this,e,0,a),this;var f,l=(c=this)._,d=t||{},p=l.root;d.at=l,d.ok=e;var h={};function g(e,t,n){if(!g.stun&&(!(i=p.pass)||i[f])){var i,s=e.$._,a=(e.$$||"")._,c=(a||s).put,u=!s.has&&!s.soul,y={};if((u||o===c)&&(c=o===((i=e.put)||"")["="]?o===(i||"")[":"]?i:i[":"]:i["="]),"string"==typeof(i=r.valid(c))&&(c=o===(i=p.$.get(i)._.put)?d.not?o:c:i),!d.not||o!==c){if(o===d.stun){if((i=p.stun)&&i.on&&(l.$.back((function(e){if(i.on(""+e.id,y={}),(y.run||0)<g.id)return y})),!y.run&&i.on(""+s.id,y={}),!y.run&&a&&i.on(""+a.id,y={}),g.id>y.run&&(y.stun&&!y.stun.end||(y.stun=i.on("stun"),y.stun=y.stun&&y.stun.last),y.stun&&!y.stun.end)))return void((y.stun.add||(y.stun.add={}))[f]=function(){g(e,t,1)});if(o===c&&(n=0),(i=p.hatch)&&!i.end&&o===d.hatch&&!n){if(h[s.$._.id])return;return h[s.$._.id]=1,void i.push((function(){g(e,t,1)}))}h={}}if(p.pass){if(p.pass[f+s.id])return;p.pass[f+s.id]=1}d.on?d.ok.call(s.$,c,s.get,e,t||g):d.v2020?d.ok(e,t||g):(Object.keys(e).forEach((function(t){i[t]=e[t]}),i={}),(e=i).put=c,d.ok.call(d.as,e,t||g))}}}return g.at=l,(l.any||(l.any={}))[f=String.random(7)]=g,g.off=function(){g.stun=1,l.any&&delete l.any[f]},g.rid=n,g.id=d.run||++p.once,u=p.pass,(p.pass={})[f]=1,d.out=d.out||{get:{}},l.on("out",d.out),p.pass=u,c}if("number"==typeof e)return this.get(""+e,t,a);if("string"==typeof(u=s(e)))return this.get(u,t,a);(u=this.get.next)&&(c=u(this,e))}return c?(t&&"function"==typeof t&&c.get(t,a),c):((c=this.chain())._.err={err:r.log("Invalid get request!",e)},t&&t.call(c,c._.err),c)};var o,i={},s=r.valid}))(t,"./get"),t((function(e){var r=t("./root");function n(e,t){if(t){t=(t._||"").id||t;var n,o=e.root.stun||(e.root.stun={on:r.on}),i={};e.stun||(e.stun=o.on("stun",(function(){}))),(n=o.on(""+t))&&n.the.last.next(i),i.run>=e.run||o.on(""+t,(function(t){if(e.stun.end)return this.off(),void this.to.next(t);t.run=t.run||e.run,t.stun=t.stun||e.stun}))}}function o(e){if(e.err)o.end(e.stun,e.root);else if(!e.todo.length&&!e.end&&Object.empty(e.wait)){e.end=1;var t,n=e.$.back(-1)._,i=n.root,s=n.ask((function(t){i.on("ack",t),t.err&&r.log(t),++a>(e.acks||0)&&this.off(),e.ack&&e.ack(t,this)}),e.opt),a=0,c=e.stun;(t=function(){c&&(o.end(c,i),setTimeout.each(Object.keys(c=c.add||""),(function(e){(e=c[e])&&e()})))}).hatch=t,e.via._.on("out",{put:e.out=e.graph,opt:e.opt,"#":s,_:t})}}r.chain.put=function(e,t,f){var l=this,d=l._,p=d.root;(f=f||{}).root=d.root,f.run||(f.run=p.once),n(f,d.id),f.ack=f.ack||t,f.via=f.via||l,f.data=f.data||e,f.soul||(f.soul=d.soul||"string"==typeof t&&t);var h=f.state=f.state||r.state();return"function"==typeof e?(e((function(e){f.data=e,l.put(i,i,f)})),l):f.soul?(f.$=p.$.get(f.soul),f.todo=[{it:f.data,ref:f.$}],f.turn=f.turn||a,f.ran=f.ran||o,function e(){var t,o,i,a,l,d=f.todo,p=d.pop(),g=p.it;if(p.ref&&p.ref._.id,n(f,p.ref),(a=p.todo)&&(g=g[o=a.pop()],a.length&&d.push(p)),o&&(d.path||(d.path=[])).push(o),!(t=c(g))&&!(l=r.is(g))){if(!Object.plain(g))return(f.ack||s).call(f,f.out={err:f.err=r.log("Invalid data: "+(g&&(a=g.constructor)&&a.name||typeof g)+" at "+(f.via.back((function(e){e.get&&a.push(e.get)}),a=[])||a.join("."))+"."+(d.path||[]).join("."))}),void f.ran(f);for(var y=f.seen||(f.seen=[]),v=y.length;v--;)if(g===(a=y[v]).it){t=g=a.link;break}}if(o&&t)p.node=u(p.node,o,h,g);else{f.seen.push(i={it:g,link:{},todo:l?[]:Object.keys(g).sort().reverse(),path:(d.path||[]).slice(),up:p}),p.node=u(p.node,o,h,i.link),!l&&i.todo.length&&d.push(i);var m=f.seen.length;function w(e,t){var r=i.link["#"];t&&(t.off(),t.rid(e));var o=r||e.soul||(a=(e.$$||e.$)._||"").soul||a.link||((a=a.put||"")._||"")["#"]||a["#"]||((a=e.put||"")&&e.$$?a["#"]:(a["="]||a[":"]||"")["#"]);!r&&n(f,e.$),o||p.link["#"]?(o||(o=[],(e.$$||e.$).back((function(e){if(a=e.soul||e.link)return o.push(a);o.push(e.get)})),o=o.reverse().join("/")),i.link["#"]=o,!l&&(((f.graph||(f.graph={}))[o]=i.node||(i.node={_:{}}))._["#"]=o),delete f.wait[m],i.wait&&setTimeout.each(i.wait,(function(e){e&&e()})),f.ran(f)):(p.wait||(p.wait=[])).push((function(){w(e,t)}))}(f.wait||(f.wait={}))[m]="",a=(i.ref=l?g:o?p.ref.get(o):p.ref)._,(a=g&&(g._||"")["#"]||a.soul||a.link)?w({soul:a}):i.ref.get(w,{run:f.run,v2020:1,out:{get:{".":" "}}})}if(!d.length)return f.ran(f);f.turn(e)}(),l):(function(e){var t,r=e.via._;e.via=e.via.back((function(r){if(r.soul||!r.get)return r.$;t=e.data,(e.data={})[r.get]=t})),e.via&&e.via._.soul||(e.via=r.root.$.get(((e.data||"")._||"")["#"]||r.$.back("opt.uuid")()));e.via.put(e.data,e.ack,e)}(f),l)},o.end=function(e,t){e.end=s,e.the.to===e&&e===e.the.last&&delete t.stun,e.off()};var i,s=function(){},a=setTimeout.turn,c=r.valid,u=r.state.ify}))(t,"./put"),t((function(e){var r=t("./root");t("./chain"),t("./back"),t("./put"),t("./get"),e.exports=r}))(t,"./index"),t((function(e){var r,n=t("./index");n.chain.on=function(e,t,r,n){var o,i=this,s=i._;if(s.root,"string"==typeof e)return t?(o=s.on(e,t,r||s,n),r&&r.$&&(r.subs||(r.subs=[])).push(o),i):s.on(e);var a=t;return(a=!0===a?{change:!0}:a||{}).not=1,a.on=1,i.get(e,a),i},n.chain.once=function(e,t){if(t=t||{},!e)return function(e,t,r){return n.log.once("valonce","Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."),(r=e.chain())._.nix=e.once((function(e,t){r._.on("in",this._)})),r._.lex=e._.lex,r}(this);var o=this,i=o._,s=i.root;i.put;var a,c=String.random(7);return o.get((function(o,u,f,l){var d=this,p=d._,h=p.one||(p.one={});function g(){p.has||p.soul||(p={put:o,get:u}),r===(a=p.put)&&(a=((f.$$||"")._||"").put),"string"==typeof n.valid(a)&&(a=s.$.get(a)._.put)===r||l.stun||""!==h[c]&&(h[c]="",(i.soul||i.has)&&l.off(),e.call(d,a,p.get))}l.stun||""!==h[c]&&(!0!==(a=n.valid(o))?"string"!=typeof a&&(clearTimeout((i.one||"")[c]),clearTimeout(h[c]),h[c]=setTimeout(g,t.wait||99)):g())}),{on:1}),o},n.chain.off=function(){var e,t=this._,r=t.back;if(r)return t.ack=0,(e=r.next)&&e[t.get]&&delete e[t.get],(e=r.ask)&&delete e[t.get],(e=r.put)&&delete e[t.get],(e=t.soul)&&delete r.root.graph[e],(e=t.map)&&Object.keys(e).forEach((function(t,n){(n=e[t]).link&&r.root.$.get(n.link).off()})),(e=t.next)&&Object.keys(e).forEach((function(t,r){e[t].$.off()})),t.on("off",{}),this}}))(t,"./on"),t((function(e){var r=t("./index"),n=r.chain.get.next;function o(e){this.to.next(e);var t,n=this.as,o=e.$._,i=e.put;(o.soul||e.$$)&&((t=n.lex)&&!String.match(e.get||(i||"")["."],t["."]||t["#"]||t)||r.on.link(e,n))}r.chain.get.next=function(e,t){var r;return Object.plain(t)?(r=((r=t["#"])||"")["="]||r)?e.get(r):((r=e.chain()._).lex=t,e.on("in",(function(e){String.match(e.get||(e.put||"")["."],t["."]||t["#"]||t)&&r.on("in",e),this.to.next(e)})),r.$):(n||s)(e,t)},r.chain.map=function(e,t,n){var a,c,u=this,f=u._;return Object.plain(e)&&(a=e["."]?e:{".":e},e=i),e?(r.log.once("mapfn","Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."),c=u.chain(),u.map().on((function(t,n,o,a){var u=(e||s).call(this,t,n,o,a);if(i!==u){if(t===u)return c._.on("in",o);if(r.is(u))return c._.on("in",u._);var f={};Object.keys(o.put).forEach((function(e){f[e]=o.put[e]}),f),f["="]=u,c._.on("in",{get:n,put:f})}})),c):((c=f.each)||((f.each=c=u.chain())._.lex=a||c._.lex||f.lex,c._.nix=u.back("nix"),u.on("in",o,c._)),c)};var i,s=function(){}}))(t,"./map"),t((function(e){var r=t("./index");r.chain.set=function(e,t,n){var o,i,s=this,a=s.back(-1);return t=t||function(){},(n=n||{}).item=n.item||e,(o=((e||"")._||"")["#"])&&((e={})["#"]=o),"string"==typeof(i=r.valid(e))?s.get(o=i).put(e,t,n):r.is(e)?(s.put((function(n){e.get((function(e,o,a){if(!e)return t.call(s,{err:r.log('Only a node can be linked! Not "'+a.put+'"!')});(i={})[e]={"#":e},n(i)}),!0)})),e):(Object.plain(e)&&(e=a.get(o=s.back("opt.uuid")()).put(e)),s.get(o||a.back("opt.uuid")(7)).put(e,t,n))}}))(t,"./set"),t((function(e){var r;t("./shim");try{e.exports=function(e){var t=function(){},n=e.opt||{};n.log=n.log||console.log,n.gap=n.gap||n.wait||0,n.max=n.max||.3*(n.memory?999*n.memory*999:3e8),n.pack=n.pack||.01*n.max*.01,n.puff=n.puff||9;var o=setTimeout.turn||setTimeout,i=JSON.parseAsync||function(e,t,r){try{t(void 0,JSON.parse(e,r))}catch(e){t(e)}},s=JSON.stringifyAsync||function(e,t,r,n){try{t(void 0,JSON.stringify(e,r,n))}catch(e){t(e)}},a=e.dup,c=a.check,u=a.track,f=t.hear=function(e,r){if(e){if(n.max<=e.length)return t.say({dam:"!",err:"Message too big!"},r);t===this&&(f.d+=e.length||0,++f.c);var s,a=r.SH=+new Date,c=e[0];return"["===c?(i(e,(function(e,i){if(e||!i)return t.say({dam:"!",err:"DAM JSON parse error."},r);console.STAT&&console.STAT(+new Date,i.length,"# on hear batch");var s=n.puff;!function e(){for(var t,n=+new Date,a=0;a<s&&(t=i[a++]);)f(t,r);i=i.slice(a),console.STAT&&console.STAT(n,+new Date-n,"hear loop"),l(r),i.length&&o(e,0)}()})),void(e="")):"{"===c||(e["#"]||Object.plain(e))&&(s=e)?s?f.one(s,r,a):void i(e,(function(e,n){if(e||!n)return t.say({dam:"!",err:"DAM JSON parse error."},r);f.one(n,r,a)})):void 0}};function l(e){var t=e.batch,r="string"==typeof t;if(r&&(t+="]"),e.batch=e.tail=null,t&&!(r?3>t.length:!t.length)){if(!r)try{t=1===t.length?t[0]:JSON.stringify(t)}catch(e){return n.log("DAM JSON stringify error",e)}t&&d(t,e)}}function d(e,r){try{var n=r.wire;r.say?r.say(e):n.send&&n.send(e),t.say.d+=e.length||0,++t.say.c}catch(t){(r.queue=r.queue||[]).push(e)}}f.one=function(r,n,o){var i,s,f,l,d;if(r.DBG&&(r.DBG=d={DBG:r.DBG}),d&&(d.h=o),d&&(d.hp=+new Date),(i=r["#"])||(i=r["#"]=String.random(9)),!((f=c(i))||(s=r["##"])&&(f=r["@"]||r.get&&i)&&a.check(l=f+s))){if((r._=function(){}).via=t.leap=n,(f=r["><"])&&"string"==typeof f&&f.slice(0,99).split(",").forEach((function(e){this[e]=1}),r._.yo={}),f=r.dam)return(f=t.hear[f])&&f(r,n,e),void u(i);o=+new Date,d&&(d.is=o),n.SI=i,e.on("in",t.last=r),d&&(d.hd=+new Date),console.STAT&&console.STAT(o,+new Date-o,r.get?"msg get":r.put?"msg put":"msg"),(f=u(i)).via=n,r.get&&(f.it=r),l&&u(l),t.leap=t.last=null}},f.c=f.d=0,function(){var e,i=0;function f(e,t){var r;return t instanceof Object?(Object.keys(t).sort().forEach(p,{to:r={},on:t}),r):t}function p(e){this.to[e]=this.on[e]}t.hash=function(e,t){var r,n,i,a=+new Date;s(e.put,(function s(c,u){var f=(n||(n=i=u||"")).slice(0,32768);r=String.hash(f,r),(n=n.slice(32768))?o(s,0):(console.STAT&&console.STAT(a,+new Date-a,"say json+hash"),e._.$put=i,e["##"]=r,h(e,t),delete e._.$put)}),f)};var h=t.say=function(s,c){var f;if((f=this)&&(f=f.to)&&f.next&&f.next(s),!s)return!1;var p,g,y=s["@"],v=s._||(s._=function(){}),m=s.DBG,w=+new Date;if(v.y=v.y||w,c||m&&(m.y=w),(p=s["#"])||(p=s["#"]=String.random(9)),!e&&u(p),s.put&&(s.err||(a.s[p]||"").err))return!1;if(s["##"]||r===s.put||v.via||!y){if(!c&&y&&(c=(f=a.s[y])&&(f.via||(f=f.it)&&(f=f._)&&f.via)||(f=t.last)&&y===f["#"]&&t.leap),!c&&y){if(a.s[y])return;return console.STAT&&console.STAT(+new Date,++i,"total no peer to ack to"),!1}if(!c&&t.way)return t.way(s);if(m&&(m.yh=+new Date),g=v.raw){if(m&&(m.yr=+new Date),!c||!c.id){if(!Object.plain(c||n.peers))return!1;w=+new Date,n.puff;var b=n.peers,_=Object.keys(c||n.peers||{});return console.STAT&&console.STAT(w,+new Date-w,"peer keys"),void function t(){var r=+new Date;e=1;var n=v.raw;v.raw=g;for(var i,a=0;a<9&&(i=(_||"")[a++]);)(i=b[i])&&h(s,i);v.raw=n,e=0,_=_.slice(a),console.STAT&&console.STAT(r,+new Date-r,"say loop"),_.length&&(o(t,0),y&&u(y))}()}if(!c.wire&&t.wire&&t.wire(c),p!==c.last){if(c.last=p,c===v.via)return!1;if((f=v.yo)&&(f[c.url]||f[c.pid]||f[c.id]))return!1;if(console.STAT&&console.STAT(w,((m||v).yp=+new Date)-(v.y||w),"say prep"),!e&&y&&u(y),c.batch){if(c.tail=(f=c.tail||0)+g.length,c.tail<=n.pack)return void(c.batch+=(f?",":"")+g);l(c)}c.batch="[";var S=+new Date;setTimeout((function(){console.STAT&&console.STAT(S,+new Date-S,"0ms TO"),l(c)}),n.gap),d(g,c),console.STAT&&y===c.SI&&console.STAT(w,+new Date-c.SH,"say ack")}}else t.raw(s,c)}else t.hash(s,c)};t.say.c=t.say.d=0,t.raw=function(e,o){if(!e)return"";var i,u,f=e._||{};if(u=f.raw)return u;if("string"==typeof e)return e;var l=e["##"],d=e["@"];if(l&&d){if(!f.via&&c(d+l))return!1;if((u=(a.s[d]||"").it)||(u=t.last)&&d===u["#"]){if(l===u["##"])return!1;u["##"]||(u["##"]=l)}}if(!e.dam){var p=0,g=[];for(var y in u=n.peers){var v=u[y];if(g.push(v.url||v.pid||v.id),++p>6)break}p>1&&(e["><"]=g.join())}if(i=f.$put)return u={},Object.keys(e).forEach((function(t){u[t]=e[t]})),u.put=":])([:",void s(u,(function(e,t){if(!e){var n=+new Date;u=t.indexOf('"put":":])([:"'),m(r,t=t.slice(0,u+6)+i+t.slice(u+14)),console.STAT&&console.STAT(n,+new Date-n,"say slice")}}));function m(t,r){t||(f.raw=r,h(e,o))}s(e,m)}}(),t.hi=function(r){var o=r.wire||{};r.id?n.peers[r.url||r.id]=r:(o=r.id=r.id||String.random(9),t.say({dam:"?",pid:e.opt.pid},n.peers[o]=r),delete a.s[r.last]),r.met=r.met||+new Date,o.hied||e.on(o.hied="hi",r),o=r.queue,r.queue=[],setTimeout.each(o||[],(function(e){d(e,r)}),0,9)},t.bye=function(r){e.on("bye",r);var n=+new Date;n-=r.met||n,t.bye.time=((t.bye.time||n)+n)/2},t.hear["!"]=function(e,t){n.log("Error:",e.err)},t.hear["?"]=function(e,r){e.pid&&(r.pid||(r.pid=e.pid),e["@"])||(t.say({dam:"?",pid:n.pid,"@":e["#"]},r),delete a.s[r.last])},e.on("create",(function(e){e.opt.pid=e.opt.pid||String.random(9),this.to.next(e),e.on("out",t.say)})),e.on("bye",(function(e,t){e=n.peers[e.id||e]||e,this.to.next(e),e.bye?e.bye():(t=e.wire)&&t.close&&t.close(),delete n.peers[e.id],e.wire=null}));var p={};return e.on("bye",(function(e,t){this.to.next(e),(t=console.STAT)&&(t.peers=(t.peers||0)-1),(t=e.url)&&(p[t]=!0,setTimeout((function(){delete p[t]}),n.lack||9e3))})),e.on("hi",(function(r,o){this.to.next(r),(o=console.STAT)&&(o.peers=(o.peers||0)+1),(o=r.url)&&p[o]&&(delete p[o],n.super||setTimeout.each(Object.keys(e.next),(function(n){e.next[n],(o={})[n]=e.graph[n],o=String.hash(o),t.say({"##":o,get:{"#":n}},r)})))})),t}}catch(e){}}))(t,"./mesh"),t((function(e){var r=t("../index");r.Mesh=t("./mesh"),r.on("opt",(function(e){if(this.to.next(e),!e.once){var t=e.opt;if(!1!==t.WebSocket){var n=r.window||{},o=t.WebSocket||n.WebSocket||n.webkitWebSocket||n.mozWebSocket;if(o){t.WebSocket=o;var i=t.mesh=t.mesh||r.Mesh(e);i.wire||t.wire,i.wire=t.wire=c,setTimeout((function(){!t.super&&e.on("out",{dam:"hi"})}),1);var s=1998,a=""+undefined!=typeof document&&document}}}function c(e){try{if(!e||!e.url)return n&&n(e);var r=e.url.replace(/^http/,"ws"),n=e.wire=new t.WebSocket(r);return n.onclose=function(){t.mesh.bye(e),u(e)},n.onerror=function(t){u(e)},n.onopen=function(){t.mesh.hi(e)},n.onmessage=function(r){r&&t.mesh.hear(r.data||r,e)},n}catch(e){}}function u(e){clearTimeout(e.defer),a&&e.retry<=0||(e.retry=(e.retry||t.retry+1||60)-(-e.tried+(e.tried=+new Date)<4*s?1:0),e.defer=setTimeout((function t(){if(a&&a.hidden)return setTimeout(t,s);c(e)}),s))}}))}))(t,"./websocket"),t((function(e){if("undefined"!=typeof Gun){var t;try{t=(Gun.window||function(){}).localStorage}catch(e){}t||(Gun.log("Warning: No localStorage exists to persist data to!"),t={setItem:function(e,t){this[e]=t},removeItem:function(e){delete this[e]},getItem:function(e){return this[e]}}),Gun.on("create",(function e(r){this.to.next(r);var n=r.opt;r.graph;var o,i,s=[];if(!1!==n.localStorage){n.prefix=n.file||"gun/";try{o=e[n.prefix]=e[n.prefix]||JSON.parse(t.getItem(n.prefix))||{}}catch(t){o=e[n.prefix]={}}r.on("get",(function(e){this.to.next(e);var t,r,n,i=e.get;i&&(t=i["#"])&&((r=o[t]||undefined)&&(n=i["."])&&!Object.plain(n)&&(r=Gun.state.ify({},n,Gun.state.is(r,n),r[n],t)),Gun.on.get.ack(e,r))})),r.on("put",(function(e){this.to.next(e);var t=e.put,r=t["#"],c=t["."];o[r]=Gun.state.ify(o[r],c,t[">"],t[":"],r),e["@"]||s.push(e["#"]),i||(i=setTimeout(a,n.wait||1))}))}function a(){var e,a=s;clearTimeout(i),i=!1,s=[];try{t.setItem(n.prefix,JSON.stringify(o))}catch(t){Gun.log((e=t||"localStorage failure")+" Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install"),r.on("localStorage:error",{err:e,get:n.prefix,put:o})}(e||Object.empty(n.peers))&&setTimeout.each(a,(function(t){r.on("in",{"@":t,err:e,ok:0})}))}}))}}))(t,"./localStorage")}(),function(){if(""+S!=typeof Gun){var e=function(e){console.log("Warning! Deprecated internal utility will break in next version:",e)},t=Gun;t.fn=t.fn||{is:function(t){return e("fn"),!!t&&"function"==typeof t}},t.bi=t.bi||{is:function(t){return e("bi"),t instanceof Boolean||"boolean"==typeof t}},t.num=t.num||{is:function(t){return e("num"),!n(t)&&(t-parseFloat(t)+1>=0||1/0===t||-1/0===t)}},t.text=t.text||{is:function(t){return e("text"),"string"==typeof t}},t.text.ify=t.text.ify||function(r){return e("text.ify"),t.text.is(r)?r:"undefined"!=typeof JSON?JSON.stringify(r):r&&r.toString?r.toString():r},t.text.random=t.text.random||function(t,r){e("text.random");var n="";for(t=t||24,r=r||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";t>0;)n+=r.charAt(Math.floor(Math.random()*r.length)),t--;return n},t.text.match=t.text.match||function(t,r){var n,o;return e("text.match"),"string"==typeof t&&("string"==typeof r&&(r={"=":r}),t===(n=(r=r||{})["="]||r["*"]||r[">"]||r["<"])||o===r["="]&&(n=r["*"]||r[">"]||r["<"],t.slice(0,(n||"").length)===n||o===r["*"]&&(o!==r[">"]&&o!==r["<"]?t>=r[">"]&&t<=r["<"]:o!==r[">"]&&t>=r[">"]||o!==r["<"]&&t<=r["<"])))},t.text.hash=t.text.hash||function(t,r){if(e("text.hash"),"string"==typeof t){if(r=r||0,!t.length)return r;for(var n=0,o=t.length;n<o;++n)r=(r<<5)-r+t.charCodeAt(n),r|=0;return r}},t.list=t.list||{is:function(t){return e("list"),t instanceof Array}},t.list.slit=t.list.slit||Array.prototype.slice,t.list.sort=t.list.sort||function(t){return e("list.sort"),function(e,r){return e&&r?(e=e[t])<(r=r[t])?-1:e>r?1:0:0}},t.list.map=t.list.map||function(t,r,n){return e("list.map"),s(t,r,n)},t.list.index=1,t.obj=t.boj||{is:function(t){return e("obj"),!!t&&(t instanceof Object&&t.constructor===Object||"Object"===Object.prototype.toString.call(t).match(/^\[object (\w+)\]$/)[1])}},t.obj.put=t.obj.put||function(t,r,n){return e("obj.put"),(t||{})[r]=n,t},t.obj.has=t.obj.has||function(t,r){return e("obj.has"),t&&Object.prototype.hasOwnProperty.call(t,r)},t.obj.del=t.obj.del||function(t,r){if(e("obj.del"),t)return t[r]=null,delete t[r],t},t.obj.as=t.obj.as||function(t,r,n,o){return e("obj.as"),t[r]=t[r]||(o===n?{}:n)},t.obj.ify=t.obj.ify||function(t){if(e("obj.ify"),o(t))return t;try{t=JSON.parse(t)}catch(e){t={}}return t},function(){function r(e,t){i(this,t)&&undefined!==this[t]||(this[t]=e)}t.obj.to=t.obj.to||function(t,n){return e("obj.to"),s(t,r,n=n||{}),n}}(),t.obj.copy=t.obj.copy||function(t){return e("obj.copy"),t?JSON.parse(JSON.stringify(t)):t},function(){function r(e,t){var r=this.n;if(!r||!(t===r||o(r)&&i(r,t)))return undefined!==t||void 0}t.obj.empty=t.obj.empty||function(t,n){return e("obj.empty"),!t||!s(t,r,{n:n})}}(),function(){function r(e,t){if(2===arguments.length)return r.r=r.r||{},void(r.r[e]=t);r.r=r.r||[],r.r.push(e)}var s,a=Object.keys;Object.keys=Object.keys||function(e){return s(e,(function(e,t,r){r(t)}))},t.obj.map=s=t.obj.map||function(s,c,u){e("obj.map");var f,l,d,p,h,g=0,y="function"==typeof c;if(r.r=f,a&&o(s)&&(p=a(s),h=!0),u=u||{},n(s)||p)for(l=(p||s).length;g<l;g++){var v=g+t.list.index;if(y){if((d=h?c.call(u,s[p[g]],p[g],r):c.call(u,s[g],v,r))!==f)return d}else if(c===s[h?p[g]:g])return p?p[g]:v}else for(g in s)if(y){if(i(s,g)&&(d=u?c.call(u,s[g],g,r):c(s[g],g,r))!==f)return d}else if(c===s[g])return g;return y?r.r:t.list.index?0:-1}}(),t.time=t.time||{},t.time.is=t.time.is||function(t){return e("time"),t?t instanceof Date:+(new Date).getTime()};var r=t.fn.is,n=t.list.is,o=(_=t.obj).is,i=_.has,s=_.map,a={is:function(t){return e("val.is"),t!==S&&(null===t||t!==1/0&&(!!(l(t)||u(t)||f(t))||(a.link.is(t)||!1)))}};a.link=a.rel={_:"#"},function(){function t(e,t){var r=this;return r.id?r.id=!1:t==c&&l(e)?void(r.id=e):r.id=!1}a.link.is=function(r){if(e("val.link.is"),r&&r[c]&&!r._&&o(r)){var n={};if(s(r,t,n),n.id)return n.id}return!1}}(),a.link.ify=function(t){return e("val.link.ify"),d({},c,t)},t.obj.has._=".";var c=a.link._,u=t.bi.is,f=t.num.is,l=t.text.is,d=(o=(_=t.obj).is,_.put);s=_.map;t.val=t.val||a;var p={_:"_",soul:function(t,r){return e("node.soul"),t&&t._&&t._[r||y]}};p.soul.ify=function(t,r){return e("node.soul.ify"),r="string"==typeof r?{soul:r}:r||{},(t=t||{})._=t._||{},t._[y]=r.soul||t._[y]||g(),t},p.soul._=a.link._,function(){function t(e,t){if(t!==p._)return!a.is(e)||void(this.cb&&this.cb.call(this.as,e,t,this.n,this.s))}p.is=function(r,n,i){var a;return e("node.is"),!!o(r)&&(!!(a=p.soul(r))&&!s(r,t,{as:i,cb:n,s:a,n:r}))}}(),function(){function t(e,t){var r,n=this.o;n.map?undefined===(r=n.map.call(this.as,e,""+t,n.node))?h(n.node,t):n.node&&(n.node[t]=r):a.is(e)&&(n.node[t]=e)}p.ify=function(r,n,o){return e("node.ify"),n?"string"==typeof n?n={soul:n}:"function"==typeof n&&(n={map:n}):n={},n.map&&(n.node=n.map.call(o,r,S,n.node||{})),(n.node=p.soul.ify(n.node||{},n))&&s(r,t,{o:n,as:o}),n.node}}();o=(_=t.obj).is;var h=_.del,g=(s=_.map,t.text.random),y=p.soul._;t.node=t.node||p;var v=t.state;v.lex=function(){return e("state.lex"),v().toString(36).replace(".","")},v.to=function(t,r,n){e("state.to");var i=(t||{})[r];return o(i)&&(i=m(i)),v.ify(n,r,v.is(t,r),i,p.soul(t))},function(){function t(e,t){w!==t&&v.ify(this.o,t,this.s)}v.map=function(n,a,c){var u;e("state.map");var l=o(l=n||a)?l:null;return n=r(n=n||a)?n:null,l&&!n?(a=f(a)?a:v(),l[w]=l[w]||{},s(l,t,{o:l,s:a}),l):(c=c||o(a)?a:u,a=f(a)?a:v(),function(e,r,o,s){if(!n)return t.call({o:o,s:a},e,r),e;n.call(c||this||{},e,r,o,s),i(o,r)&&u===o[r]||t.call({o:o,s:a},e,r)})}}(),(_=t.obj).as;i=_.has,o=_.is,s=_.map;var m=_.copy,w=(f=t.num.is,r=t.fn.is,p._),b={};!function(){function t(e,t){if(!e||t!==p.soul(e)||!p.is(e,this.fn,this.as))return!0;this.cb&&(r.n=e,r.as=this.as,this.cb.call(r.as,e,t,r))}function r(e){e&&p.is(r.n,e,r.as)}b.is=function(r,n,i,a){return e("graph.is"),!(!r||!o(r)||k(r))&&!s(r,t,{cb:n,fn:i,as:a})}}(),function(){function r(e,t){var r;return(r=function(e,t){var r,n=e.seen,o=n.length;for(;o--;)if(r=n[o],t.obj===r.obj)return r;n.push(t)}(e,t))?r:(t.env=e,t.soul=s,p.ify(t.obj,n,t)&&(t.link=t.link||a.link.ify(p.soul(t.node)),t.obj!==e.shell&&(e.graph[a.link.is(t.link)]=t.node)),t)}function n(e,t,n){var o,s,u=this,f=u.env;if(p._===t&&i(e,a.link._))return n._;if(o=c(e,t,n,u,f)){if(t||(u.node=u.node||n||{},i(e,p._)&&p.soul(e)&&(u.node._=m(e._)),u.node=p.soul.ify(u.node,a.link.is(u.link)),u.link=u.link||a.link.ify(p.soul(u.node))),(s=f.map)&&(s.call(f.as||{},e,t,n,u),i(n,t))){if(e=n[t],S===e)return void h(n,t);if(!(o=c(e,t,n,u,f)))return}if(!t)return u.node;if(!0===o)return e;if((s=r(f,{obj:e,path:u.path.concat(t)})).node)return s.link}}function s(e){var t=this,r=a.link.is(t.link),n=t.env.graph;t.link=t.link||a.link.ify(e),t.link[a.link._]=e,t.node&&t.node[p._]&&(t.node[p._][a.link._]=e),i(n,r)&&(n[e]=n[r],h(n,r))}function c(e,r,n,i,s){var u;return!!a.is(e)||(o(e)?1:(u=s.invalid)?c(e=u.call(s.as||{},e,r,n),r,n,i,s):(s.err="Invalid value at '"+i.path.concat(r).join(".")+"'!",void(t.list.is(e)&&(s.err+=" Use `.set(item)` instead of an Array."))))}b.ify=function(t,n,o){e("graph.ify");var i={path:[],obj:t};return n?"string"==typeof n?n={soul:n}:"function"==typeof n&&(n.map=n):n={},"string"==typeof o&&(n.soul=n.soul||o,o=S),n.soul&&(i.link=a.link.ify(n.soul)),n.shell=(o||{}).shell,n.graph=n.graph||{},n.seen=n.seen||[],n.as=n.as||o,r(n,i),n.root=i.node,n.graph}}(),b.node=function(t){e("graph.node");var r=p.soul(t);if(r)return d({},r,t)},function(){function t(e,t){var r,n;if(p._!==t)(r=a.link.is(e))?(n=this.opt.seen[r])?this.obj[t]=n:this.obj[t]=this.opt.seen[r]=b.to(this.graph,r,this.opt):this.obj[t]=e;else{if(k(e,a.link._))return;this.obj[t]=m(e)}}b.to=function(r,n,o){if(e("graph.to"),r){var i={};return o=o||{seen:{}},s(r[n],t,{obj:i,graph:r,opt:o}),i}}}();r=t.fn.is,o=(_=t.obj).is,h=_.del,i=_.has;var _,S,k=_.empty;d=_.put,s=_.map,m=_.copy;t.graph=t.graph||b}}()}(N);var j=N.exports;!function(e){!function(){function t(e,r){return r?C(e):e.slice?t[n(e)]:function(r,o){e(r={exports:{}}),t[n(o)]=r.exports};function n(e){return e.split("/").slice(-1).toString().replace(".js","")}}var r=e;t((function(e){"undefined"!=typeof window&&(e.window=window);var t=(e.window||e).SEA||{};(t.window=e.window)&&(t.window.SEA=t);try{undefined+""!=typeof r&&(r.exports=t)}catch(e){}e.exports=t}))(t,"./root"),t((function(e){var r=t("./root");try{r.window&&location.protocol.indexOf("s")<0&&location.host.indexOf("localhost")<0&&!/^127\.\d+\.\d+\.\d+$/.test(location.hostname)&&location.protocol.indexOf("file:")<0&&(console.warn("HTTPS needed for WebCrypto in SEA, redirecting..."),location.protocol="https:")}catch(e){}}))(t,"./https"),t((function(e){var r;if(r+""==typeof btoa){if(r+""==typeof Buffer)try{D.Buffer=t("buffer",1).Buffer}catch(e){console.log("Please `npm install buffer` or add it to your package.json !")}D.btoa=function(e){return Buffer.from(e,"binary").toString("base64")},D.atob=function(e){return Buffer.from(e,"base64").toString("binary")}}}))(t,"./base64"),t((function(e){function r(){}t("./base64"),Object.assign(r,{from:Array.from}),r.prototype=Object.create(Array.prototype),r.prototype.toString=function(e,t,r){e=e||"utf8",t=t||0;const n=this.length;if("hex"===e){const e=new Uint8Array(this);return[...Array((r&&r+1||n)-t).keys()].map((r=>e[r+t].toString(16).padStart(2,"0"))).join("")}return"utf8"===e?Array.from({length:(r||n)-t},((e,r)=>String.fromCharCode(this[r+t]))).join(""):"base64"===e?btoa(this):void 0},e.exports=r}))(t,"./array"),t((function(e){t("./base64");var r=t("./array");function n(...e){return console.warn("new SafeBuffer() is depreciated, please use SafeBuffer.from()"),n.from(...e)}n.prototype=Object.create(Array.prototype),Object.assign(n,{from(){if(!Object.keys(arguments).length||null==arguments[0])throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");const e=arguments[0];let t;if("string"==typeof e){const n=arguments[1]||"utf8";if("hex"===n){const n=e.match(/([\da-fA-F]{2})/g).map((e=>parseInt(e,16)));if(!n||!n.length)throw new TypeError("Invalid first argument for type 'hex'.");t=r.from(n)}else if("utf8"===n||"binary"===n){const n=e.length,o=new Uint16Array(n);Array.from({length:n},((t,r)=>o[r]=e.charCodeAt(r))),t=r.from(o)}else if("base64"===n){const n=atob(e),o=n.length,i=new Uint8Array(o);Array.from({length:o},((e,t)=>i[t]=n.charCodeAt(t))),t=r.from(i)}else"binary"===n?t=r.from(e):console.info("SafeBuffer.from unknown encoding: "+n);return t}e.byteLength;if(e.byteLength?e.byteLength:e.length){let t;return e instanceof ArrayBuffer&&(t=new Uint8Array(e)),r.from(t||e)}},alloc:(e,t=0)=>r.from(new Uint8Array(Array.from({length:e},(()=>t)))),allocUnsafe:e=>r.from(new Uint8Array(Array.from({length:e}))),concat(e){if(!Array.isArray(e))throw new TypeError("First argument must be Array containing ArrayBuffer or Uint8Array instances.");return r.from(e.reduce(((e,t)=>e.concat(Array.from(t))),[]))}}),n.prototype.from=n.from,n.prototype.toString=r.prototype.toString,e.exports=n}))(t,"./buffer"),t((function(e){const n=t("./root"),o={Buffer:t("./buffer")};var i={};if(JSON.parseAsync=JSON.parseAsync||function(e,t,r){try{t(undefined,JSON.parse(e,r))}catch(e){t(e)}},JSON.stringifyAsync=JSON.stringifyAsync||function(e,t,r,n){try{t(undefined,JSON.stringify(e,r,n))}catch(e){t(e)}},o.parse=function(e,t){return new Promise((function(r,n){JSON.parseAsync(e,(function(e,t){e?n(e):r(t)}),t)}))},o.stringify=function(e,t,r){return new Promise((function(n,o){JSON.stringifyAsync(e,(function(e,t){e?o(e):n(t)}),t,r)}))},n.window&&(o.crypto=window.crypto||window.msCrypto,o.subtle=(o.crypto||i).subtle||(o.crypto||i).webkitSubtle,o.TextEncoder=window.TextEncoder,o.TextDecoder=window.TextDecoder,o.random=e=>o.Buffer.from(o.crypto.getRandomValues(new Uint8Array(o.Buffer.alloc(e))))),!o.TextDecoder){const{TextEncoder:e,TextDecoder:n}=t((undefined+""==typeof r?".":"")+"./lib/text-encoding",1);o.TextDecoder=n,o.TextEncoder=e}if(!o.crypto)try{var s=t("crypto",1);Object.assign(o,{crypto:s,random:e=>o.Buffer.from(s.randomBytes(e))});const{Crypto:e}=t("@peculiar/webcrypto",1);o.ossl=o.subtle=new e({directory:"ossl"}).subtle}catch(e){console.log("Please `npm install @peculiar/webcrypto` or add it to your package.json !")}e.exports=o}))(t,"./shim"),t((function(e){var r=t("./root"),n=t("./shim"),o={pbkdf2:{hash:{name:"SHA-256"},iter:1e5,ks:64},ecdsa:{pair:{name:"ECDSA",namedCurve:"P-256"},sign:{name:"ECDSA",hash:{name:"SHA-256"}}},ecdh:{name:"ECDH",namedCurve:"P-256"},jwk:function(e,t){var r={kty:"EC",crv:"P-256",x:(e=e.split("."))[0],y:e[1],ext:!0};return r.key_ops=t?["sign"]:["verify"],t&&(r.d=t),r},keyToJwk:function(e){return{kty:"oct",k:e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,""),ext:!1,alg:"A256GCM"}},recall:{validity:43200,hook:function(e){return e}},check:function(e){return"string"==typeof e&&"SEA{"===e.slice(0,4)},parse:async function(e){try{var t="string"==typeof e;return t&&"SEA{"===e.slice(0,4)&&(e=e.slice(3)),t?await n.parse(e):e}catch(e){}return e}};r.opt=o,e.exports=o}))(t,"./settings"),t((function(e){var r=t("./shim");e.exports=async function(e,t){var n="string"==typeof e?e:await r.stringify(e),o=await r.subtle.digest({name:t||"SHA-256"},(new r.TextEncoder).encode(n));return r.Buffer.from(o)}}))(t,"./sha256"),t((function(e){const r=t("./shim"),n=r.subtle,o=r.ossl?r.ossl:n;e.exports=e=>o.digest({name:"SHA-1"},new ArrayBuffer(e))}))(t,"./sha1"),t((function(e){var r=t("./root"),n=t("./shim"),o=t("./settings"),i=t("./sha256");r.work=r.work||(async(e,t,s,a)=>{try{var c=(t||{}).epub||t;if(a=a||{},c instanceof Function&&(s=c,c=undefined),e="string"==typeof e?e:await n.stringify(e),"sha"===(a.name||"").toLowerCase().slice(0,3)){var u=n.Buffer.from(await i(e,a.name),"binary").toString(a.encode||"base64");if(s)try{s(u)}catch(e){console.log(e)}return u}c=c||n.random(9);var f=await(n.ossl||n.subtle).importKey("raw",(new n.TextEncoder).encode(e),{name:a.name||"PBKDF2"},!1,["deriveBits"]),l=await(n.ossl||n.subtle).deriveBits({name:a.name||"PBKDF2",iterations:a.iterations||o.pbkdf2.iter,salt:(new n.TextEncoder).encode(a.salt||c),hash:a.hash||o.pbkdf2.hash},f,a.length||8*o.pbkdf2.ks);e=n.random(e.length);var d=n.Buffer.from(l,"binary").toString(a.encode||"base64");if(s)try{s(d)}catch(e){console.log(e)}return d}catch(e){if(console.log(e),r.err=e,r.throw)throw e;return void(s&&s())}}),e.exports=r.work}))(t,"./work"),t((function(e){var r=t("./root"),n=t("./shim");t("./settings"),r.name=r.name||(async(e,t)=>{try{if(e)try{e()}catch(e){console.log(e)}return}catch(t){if(console.log(t),r.err=t,r.throw)throw t;return void(e&&e())}}),r.pair=r.pair||(async(e,t)=>{try{var o=n.ossl||n.subtle,i=await n.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]).then((async e=>{var t={};t.priv=(await n.subtle.exportKey("jwk",e.privateKey)).d;var r=await n.subtle.exportKey("jwk",e.publicKey);return t.pub=r.x+"."+r.y,t}));try{var s=await o.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"]).then((async e=>{var t={};t.epriv=(await o.exportKey("jwk",e.privateKey)).d;var r=await o.exportKey("jwk",e.publicKey);return t.epub=r.x+"."+r.y,t}))}catch(e){if(r.window)throw e;if("Error: ECDH is not a supported algorithm"!=e)throw e;console.log("Ignoring ECDH...")}s=s||{};var a={pub:i.pub,priv:i.priv,epub:s.epub,epriv:s.epriv};if(e)try{e(a)}catch(e){console.log(e)}return a}catch(t){if(console.log(t),r.err=t,r.throw)throw t;return void(e&&e())}}),e.exports=r.pair}))(t,"./pair"),t((function(e){var r,n=t("./root"),o=t("./shim"),i=t("./settings"),s=t("./sha256");n.sign=n.sign||(async(e,t,a,c)=>{try{if(c=c||{},!(t||c).priv){if(!n.I)throw"No signing key.";t=await n.I(null,{what:e,how:"sign",why:c.why})}if(r===e)throw"`undefined` not allowed.";var u=await i.parse(e),f=c.check=c.check||u;if(n.verify&&(n.opt.check(f)||f&&f.s&&f.m)&&r!==await n.verify(f,t)){var l=await i.parse(f);if(c.raw||(l="SEA"+await o.stringify(l)),a)try{a(l)}catch(e){console.log(e)}return l}var d=t.pub,p=t.priv,h=i.jwk(d,p),g=await s(u),y=await(o.ossl||o.subtle).importKey("jwk",h,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]).then((e=>(o.ossl||o.subtle).sign({name:"ECDSA",hash:{name:"SHA-256"}},e,new Uint8Array(g))));l={m:u,s:o.Buffer.from(y,"binary").toString(c.encode||"base64")};if(c.raw||(l="SEA"+await o.stringify(l)),a)try{a(l)}catch(e){console.log(e)}return l}catch(e){if(console.log(e),n.err=e,n.throw)throw e;return void(a&&a())}}),e.exports=n.sign}))(t,"./sign"),t((function(e){var r,n=t("./root"),o=t("./shim"),i=t("./settings"),s=t("./sha256");n.verify=n.verify||(async(e,t,a,c)=>{try{var u=await i.parse(e);if(!1===t){var f=await i.parse(u.m);if(a)try{a(f)}catch(e){console.log(e)}return f}c=c||{};var l,d,p,h=t.pub||t,g=n.opt.slow_leak?await n.opt.slow_leak(h):await(o.ossl||o.subtle).importKey("jwk",i.jwk(h),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]),y=await s(u.m);try{if(l=o.Buffer.from(u.s,c.encode||"base64"),d=new Uint8Array(l),!(p=await(o.ossl||o.subtle).verify({name:"ECDSA",hash:{name:"SHA-256"}},g,d,new Uint8Array(y))))throw"Signature did not match."}catch(r){if(n.opt.fallback)return await n.opt.fall_verify(e,t,a,c)}var v=p?await i.parse(u.m):r;if(a)try{a(v)}catch(e){console.log(e)}return v}catch(e){if(console.log(e),n.err=e,n.throw)throw e;return void(a&&a())}}),e.exports=n.verify;var a={};n.opt.slow_leak=e=>{if(a[e])return a[e];var t=i.jwk(e);return a[e]=(o.ossl||o.subtle).importKey("jwk",t,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]),a[e]};var c=n.opt;n.opt.fall_verify=async function(e,t,a,u,f){if(f===n.opt.fallback)throw"Signature did not match";f=f||1;var l=e||"";e=n.opt.unpack(e)||e;var d,p,h,g=await i.parse(e),y=t.pub||t,v=await n.opt.slow_leak(y),m=f<=n.opt.fallback?o.Buffer.from(await o.subtle.digest({name:"SHA-256"},(new o.TextEncoder).encode(await i.parse(g.m)))):await s(g.m);try{if(d=o.Buffer.from(g.s,u.encode||"base64"),p=new Uint8Array(d),!(h=await(o.ossl||o.subtle).verify({name:"ECDSA",hash:{name:"SHA-256"}},v,p,new Uint8Array(m))))throw"Signature did not match."}catch(e){try{d=o.Buffer.from(g.s,"utf8"),p=new Uint8Array(d),h=await(o.ossl||o.subtle).verify({name:"ECDSA",hash:{name:"SHA-256"}},v,p,new Uint8Array(m))}catch(e){if(!h)throw"Signature did not match."}}var w=h?await i.parse(g.m):r;if(c.fall_soul=l["#"],c.fall_key=l["."],c.fall_val=e,c.fall_state=l[">"],a)try{a(w)}catch(e){console.log(e)}return w},n.opt.fallback=2}))(t,"./verify"),t((function(e){var r=t("./shim"),n=t("./settings"),o=t("./sha256");e.exports=async(e,t,i)=>{const s=e+(t||r.random(8)).toString("utf8"),a=r.Buffer.from(await o(s),"binary"),c=n.keyToJwk(a);return await r.subtle.importKey("jwk",c,{name:"AES-GCM"},!1,["encrypt","decrypt"])}}))(t,"./aeskey"),t((function(e){var r=t("./root"),n=t("./shim");t("./settings");var o=t("./aeskey");r.encrypt=r.encrypt||(async(e,t,i,s)=>{try{s=s||{};var a=(t||s).epriv||t;if(undefined===e)throw"`undefined` not allowed.";if(!a){if(!r.I)throw"No encryption key.";a=(t=await r.I(null,{what:e,how:"encrypt",why:s.why})).epriv||t}var c="string"==typeof e?e:await n.stringify(e),u={s:n.random(9),iv:n.random(15)},f=await o(a,u.s,s).then((e=>n.subtle.encrypt({name:s.name||"AES-GCM",iv:new Uint8Array(u.iv)},e,(new n.TextEncoder).encode(c)))),l={ct:n.Buffer.from(f,"binary").toString(s.encode||"base64"),iv:u.iv.toString(s.encode||"base64"),s:u.s.toString(s.encode||"base64")};if(s.raw||(l="SEA"+await n.stringify(l)),i)try{i(l)}catch(e){console.log(e)}return l}catch(e){if(console.log(e),r.err=e,r.throw)throw e;return void(i&&i())}}),e.exports=r.encrypt}))(t,"./encrypt"),t((function(e){var r=t("./root"),n=t("./shim"),o=t("./settings"),i=t("./aeskey");r.decrypt=r.decrypt||(async(e,t,s,a)=>{try{a=a||{};var c=(t||a).epriv||t;if(!c){if(!r.I)throw"No decryption key.";c=(t=await r.I(null,{what:e,how:"decrypt",why:a.why})).epriv||t}var u,f,l,d=await o.parse(e);try{u=n.Buffer.from(d.s,a.encode||"base64"),f=n.Buffer.from(d.iv,a.encode||"base64"),l=n.Buffer.from(d.ct,a.encode||"base64");var p=await i(c,u,a).then((e=>n.subtle.decrypt({name:a.name||"AES-GCM",iv:new Uint8Array(f),tagLength:128},e,new Uint8Array(l))))}catch(n){if("utf8"===a.encode)throw"Could not decrypt";if(r.opt.fallback)return a.encode="utf8",await r.decrypt(e,t,s,a)}var h=await o.parse(new n.TextDecoder("utf8").decode(p));if(s)try{s(h)}catch(e){console.log(e)}return h}catch(e){if(console.log(e),r.err=e,r.throw)throw e;return void(s&&s())}}),e.exports=r.decrypt}))(t,"./decrypt"),t((function(e){var r=t("./root"),n=t("./shim");t("./settings"),r.secret=r.secret||(async(e,t,i,s)=>{try{if(s=s||{},!t||!t.epriv||!t.epub){if(!r.I)throw"No secret mix.";t=await r.I(null,{what:e,how:"secret",why:s.why})}var a=e.epub||e,c=t.epub,u=t.epriv,f=n.ossl||n.subtle,l=o(a),d=Object.assign({public:await f.importKey(...l,!0,[])},{name:"ECDH",namedCurve:"P-256"}),p=o(c,u),h=await f.importKey(...p,!1,["deriveBits"]).then((async e=>{var t=await f.deriveBits(d,e,256),r=new Uint8Array(t),n=await f.importKey("raw",r,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return f.exportKey("jwk",n).then((({k:e})=>e))}));if(i)try{i(h)}catch(e){console.log(e)}return h}catch(e){if(console.log(e),r.err=e,r.throw)throw e;return void(i&&i())}});var o=(e,t)=>{var[r,n]=e.split("."),o=t?{d:t}:{};return["jwk",Object.assign(o,{x:r,y:n,kty:"EC",crv:"P-256",ext:!0}),{name:"ECDH",namedCurve:"P-256"}]};e.exports=r.secret}))(t,"./secret"),t((function(e){var r=t("./root");r.certify=r.certify||(async(e,t={},n,o,i={})=>{try{if(console.log("SEA.certify() is an early experimental community supported method that may change API behavior without warning in any future version."),e=(()=>{var t=[];if(e){if(("string"==typeof e||Array.isArray(e))&&e.indexOf("*")>-1)return"*";if("string"==typeof e)return e;if(Array.isArray(e)){if(1===e.length&&e[0])return"object"==typeof e[0]&&e[0].pub?e[0].pub:"string"==typeof e[0]?e[0]:null;e.map((e=>{"string"==typeof e?t.push(e):"object"==typeof e&&e.pub&&t.push(e.pub)}))}return"object"==typeof e&&e.pub?e.pub:t.length>0?t:null}})(),!e)return console.log("No certificant found.");const a=!i.expiry||"number"!=typeof i.expiry&&"string"!=typeof i.expiry?null:parseFloat(i.expiry),c=(t||{}).read?t.read:null,u=(t||{}).write?t.write:"string"==typeof t||Array.isArray(t)||t["+"]||t["#"]||t["."]||t["="]||t["*"]||t[">"]||t["<"]?t:null,f=(i||{}).block||(i||{}).blacklist||(i||{}).ban||{},l=f.read&&("string"==typeof f.read||(f.read||{})["#"])?f.read:null,d="string"==typeof f?f:f.write&&("string"==typeof f.write||f.write["#"])?f.write:null;if(!c&&!u)return console.log("No policy found.");const p=JSON.stringify({c:e,...a?{e:a}:{},...c?{r:c}:{},...u?{w:u}:{},...l?{rb:l}:{},...d?{wb:d}:{}});var s=await r.sign(p,n,null,{raw:1});if(i.raw||(s="SEA"+JSON.stringify(s)),o)try{o(s)}catch(e){console.log(e)}return s}catch(e){if(r.err=e,r.throw)throw e;return void(o&&o())}}),e.exports=r.certify}))(t,"./certify"),t((function(e){var r=t("./shim"),n=t("./root");n.work=t("./work"),n.sign=t("./sign"),n.verify=t("./verify"),n.encrypt=t("./encrypt"),n.decrypt=t("./decrypt"),n.certify=t("./certify"),n.random=n.random||r.random,n.Buffer=n.Buffer||t("./buffer"),n.keyid=n.keyid||(async e=>{try{const t=r.Buffer.concat(e.replace(/-/g,"+").replace(/_/g,"/").split(".").map((e=>r.Buffer.from(e,"base64")))),n=r.Buffer.concat([r.Buffer.from([153,t.length/256,t.length%256]),t]),o=await sha1hash(n),i=r.Buffer.from(o,"binary");return i.toString("hex",i.length-8)}catch(e){throw console.log(e),e}}),((n.window||{}).GUN||{}).SEA=n,e.exports=n}))(t,"./sea"),t((function(e){var n,o=t("./sea");function i(e){this._={$:this}}function s(){return n.state().toString(36).replace(".","")}n=o.window?o.window.GUN||{chain:{}}:t((undefined+""==typeof r?".":"")+"./gun",1),o.GUN=n,i.prototype=function(){function e(){}return e.prototype=n.chain,new e}(),i.prototype.constructor=i,n.chain.user=function(e){var t,r=this.back(-1);if(e)return e=o.opt.pub((e._||"")["#"])||e,r.get("~"+e);if(t=r.back("user"))return t;var n=r=r._,a=n.opt.uuid||s;return(n=(t=n.user=this.chain(new i))._).opt={},n.opt.uuid=function(e){var t=a(),n=r.user;return n&&(n=n.is)&&(n=n.pub)?(t="~"+n+"/"+t,e&&e.call&&e(null,t),t):t},t},n.User=i,i.GUN=n,i.SEA=n.SEA=o,e.exports=i}))(t,"./user"),t((function(e){var n;(""+n!=typeof window?window.Gun||{chain:{}}:t((""+n==typeof r?".":"")+"./gun",1)).chain.then=function(e,t){var r=this,n=new Promise((function(e,n){r.once(e,t)}));return e?n.then(e):n}}))(t,"./then"),t((function(e){var r=t("./user"),n=r.SEA,o=r.GUN,i=function(){};r.prototype.create=function(...e){var t,r="object"==typeof e[0]&&(e[0].pub||e[0].epub)?e[0]:"object"==typeof e[1]&&(e[1].pub||e[1].epub)?e[1]:null,s=r&&(r.pub||r.epub)?r.pub:"string"==typeof e[0]?e[0]:null,a=r&&(r.pub||r.epub)?r:s&&"string"==typeof e[1]?e[1]:null,c=e.filter((e=>"function"==typeof e))[0]||null,u=e&&e.length>1&&"object"==typeof e[e.length-1]?e[e.length-1]:{},f=this,l=f._,d=f.back(-1);if((c=c||i,!1!==(u=u||{}).check)&&(s||(t="No user."),(a||"").length<8&&(t="Password too short!"),t))return c({err:o.log(t)}),f;if(l.ing)return(c||i)({err:o.log("User is already being created or authenticated!"),wait:!0}),f;l.ing=!0;var p={a:function(e){if(p.pubs=e,e&&!u.already){var t={err:o.log("User already created!")};return l.ing=!1,(c||i)(t),void f.leave()}p.salt=String.random(64),n.work(a,p.salt,p.b)},b:function(e){p.proof=e,r?p.c(r):n.pair(p.c)},c:function(e){var t;p.pair=e||{},(t=l.root.user)&&(t._.sea=e,t.is={pub:e.pub,epub:e.epub,alias:s}),p.data={pub:e.pub},p.d()},d:function(){p.data.alias=s,p.e()},e:function(){p.data.epub=p.pair.epub,n.encrypt({priv:p.pair.priv,epriv:p.pair.epriv},p.proof,p.f,{raw:1})},f:function(e){p.data.auth=JSON.stringify({ek:e,s:p.salt}),p.g(p.data.auth)},g:function(e){var t;p.data.auth=p.data.auth||e,d.get(t="~"+p.pair.pub).put(p.data).on(p.h);var r={};r[t]={"#":t},d.get("~@"+s).put(r).get(t).on(p.i)},h:function(e,t,r,n){n.off(),p.h.ok=1,p.i()},i:function(e,t,n,o){o&&(p.i.ok=1,o.off()),p.h.ok&&p.i.ok&&(l.ing=!1,c({ok:0,pub:p.pair.pub}),i===c&&(r?f.auth(r):f.auth(s,a)))}};return d.get("~@"+s).once(p.a),f},r.prototype.leave=function(e,t){var r=this.back(-1)._.user;if(r&&(delete r.is,delete r._.is,delete r._.sea),n.window)try{var o={};delete(o=window.sessionStorage).recall,delete o.pair}catch(e){}return this}}))(t,"./create"),t((function(e){var r=t("./user"),n=r.SEA,o=r.GUN,i=function(){};function s(e){if("string"!=typeof e)return e;try{e=JSON.parse(e)}catch(t){e={}}return e}r.prototype.auth=function(...e){var t="object"==typeof e[0]&&(e[0].pub||e[0].epub)?e[0]:"object"==typeof e[1]&&(e[1].pub||e[1].epub)?e[1]:null,r=t||"string"!=typeof e[0]?null:e[0],a=r&&"string"==typeof e[1]?e[1]:null,c=e.filter((e=>"function"==typeof e))[0]||null,u=e&&e.length>1&&"object"==typeof e[e.length-1]?e[e.length-1]:{},f=this,l=f._,d=f.back(-1);if(l.ing)return(c||i)({err:o.log("User is already being created or authenticated!"),wait:!0}),f;l.ing=!0;var p,h={};return h.a=function(e){if(!e)return h.b();if(!e.pub){var t=[];return Object.keys(e).forEach((function(r){"_"!=r&&t.push(e[r])})),h.b(t)}if(h.name)return h.f(e);h.c((h.data=e).auth)},h.b=function(e){var t=(h.list=(h.list||[]).concat(e||[])).shift();if(p===t)return h.name?h.err("Your user account is not published for dApps to access, please consider syncing it online, or allowing local access by adding your device as a peer."):h.err("Wrong user or password.");d.get(t).once(h.a)},h.c=function(e){return p===e?h.b():"string"==typeof e?h.c(s(e)):void n.work(a,(h.auth=e).s,h.d,h.enc)},h.d=function(e){n.decrypt(h.auth.ek,e,h.e,h.enc)},h.e=function(e){if(p===e)return h.enc?(h.enc=null,h.b()):(h.enc={encode:"utf8"},h.c(h.auth));h.half=e,h.f(h.data)},h.f=function(e){var t=h.half||{},r=h.data||{};h.g(h.lol={pub:e.pub||r.pub,epub:e.epub||r.epub,priv:e.priv||t.priv,epriv:e.epriv||t.epriv})},h.g=function(e){if(!e||!e.pub||!e.epub)return h.b();h.pair=e;var t=d._.user,g=t._;g.tag;var y=g.opt;(g=t._=d.get("~"+e.pub)._).opt=y,t.is={pub:e.pub,epub:e.epub,alias:r||e.pub},g.sea=h.pair,l.ing=!1;try{a&&p==(s(l.root.graph["~"+e.pub].auth)||"")[":"]&&(u.shuffle=u.change=a)}catch(e){}if(u.change?h.z():(c||i)(g),n.window&&(f.back("user")._.opt||u).remember)try{var v={};(v=window.sessionStorage).recall=!0,v.pair=JSON.stringify(e)}catch(e){}try{d._.tag.auth?d._.on("auth",g):setTimeout((function(){d._.on("auth",g)}),1)}catch(e){o.log("Your 'auth' callback crashed with:",e)}},h.z=function(){h.salt=String.random(64),n.work(u.change,h.salt,h.y)},h.y=function(e){n.encrypt({priv:h.pair.priv,epriv:h.pair.epriv},e,h.x,{raw:1})},h.x=function(e){h.w(JSON.stringify({ek:e,s:h.salt}))},h.w=function(e){if(u.shuffle){console.log("migrate core account from UTF8 & shuffle");var t={};Object.keys(h.data).forEach((function(e){t[e]=h.data[e]})),delete t._,t.auth=e,d.get("~"+h.pair.pub).put(t)}d.get("~"+h.pair.pub).get("auth").put(e,c||i)},h.err=function(e){var t={err:o.log(e||"User cannot be found!")};l.ing=!1,(c||i)(t)},h.plugin=function(e){if(!(h.name=e))return h.err();var t=[e];"~"!==e[0]&&(t[1]="~"+e,t[2]="~@"+e),h.b(t)},t?h.g(t):r?d.get("~@"+r).once(h.a):r||a||n.name(h.plugin),f}}))(t,"./auth"),t((function(e){var r=t("./user"),n=r.SEA;r.GUN,r.prototype.recall=function(e,t){var r=this,o=r.back(-1);if((e=e||{})&&e.sessionStorage){if(n.window)try{var i;(i=window.sessionStorage)&&(o._.opt.remember=!0,(r.back("user")._.opt||e).remember=!0,(i.recall||i.pair)&&o.user().auth(JSON.parse(i.pair),t))}catch(e){}return r}return r}}))(t,"./recall"),t((function(e){var r=t("./user"),n=r.SEA,o=r.GUN,i=function(){};r.prototype.pair=function(){var e,t=this;try{e=new Proxy({DANGER:"☠"},{get:function(e,r,n){if(t.is&&(t._||"").sea)return t._.sea[r]}})}catch(e){}return e},r.prototype.delete=async function(e,t,r){console.log("user.delete() IS DEPRECATED AND WILL BE MOVED TO A MODULE!!!");var n=this;n.back(-1);var s=n.back("user");try{s.auth(e,t,(function(e){(s.is||{}).pub;s.map().once((function(){this.put(null)})),s.leave(),(r||i)({ok:0})}))}catch(e){o.log("User.delete failed! Error:",e)}return n},r.prototype.alive=async function(){console.log("user.alive() IS DEPRECATED!!!");const e=this.back(-1);try{return await authRecall(e),e._.user._}catch(e){const t="No session!";throw o.log(t),{err:t}}},r.prototype.trust=async function(e){console.log("`.trust` API MAY BE DELETED OR CHANGED OR RENAMED, DO NOT USE!"),o.is(e)&&e.get("pub").get(((e,t)=>{console.log(e,t)})),e.get("trust").get(path).put(theirPubkey)},r.prototype.grant=function(e,t){console.log("`.grant` API MAY BE DELETED OR CHANGED OR RENAMED, DO NOT USE!");var r=this,o=r.back(-1).user(),i=o._.sea,s="";return r.back((function(e){e.is||(s+=e.get||"")})),async function(){var r,a=await o.get("grant").get(i.pub).get(s).then();(a=await n.decrypt(a,i))||(a=n.random(16).toString(),r=await n.encrypt(a,i),o.get("grant").get(i.pub).get(s).put(r));var c=e.get("pub").then(),u=e.get("epub").then();c=await c,u=await u;var f=await n.secret(u,i);r=await n.encrypt(a,f),o.get("grant").get(c).get(s).put(r,t)}(),r},r.prototype.secret=function(e,t){console.log("`.secret` API MAY BE DELETED OR CHANGED OR RENAMED, DO NOT USE!");var r=this,o=r.back(-1).user(),i=o.pair(),s="";return r.back((function(e){e.is||(s+=e.get||"")})),async function(){var a,c=await o.get("trust").get(i.pub).get(s).then();(c=await n.decrypt(c,i))||(c=n.random(16).toString(),a=await n.encrypt(c,i),o.get("trust").get(i.pub).get(s).put(a)),a=await n.encrypt(e,c),r.put(a,t)}(),r},e.exports=r}))(t,"./share"),t((function(e){var n,o=t("./sea"),i=t("./settings"),s=""+n!=typeof window?window.Gun||{on:function(){}}:t((""+n==typeof r?".":"")+"./gun",1);function a(e){var t,r=this,n=r.as,i=e.put,c=i["#"],u=i["."],f=i[":"],l=i[">"],d=e["#"];if(c&&u)if((e._||"").faith&&(n.opt||"").faith&&"function"==typeof e._)o.opt.pack(i,(function(t){o.verify(t,!1,(function(t){i["="]=o.opt.unpack(t),r.to.next(e)}))}));else{var p=function(t){n.on("in",{"@":d,err:e.err=t})};(e._||"").DBG&&((e._||"").DBG.c=+new Date),0<=c.indexOf("<?")&&(t=parseFloat(c.split("<?")[1]||""))&&l<s.state()-1e3*t?(t=e._)&&t.stun&&t.stun--:"~@"!==c?"~@"!==c.slice(0,2)?(t=o.opt.pub(c))?a.pub(r,e,f,u,c,n,p,n.user||"",t):0<=c.indexOf("#")?a.hash(r,e,f,u,c,n,p):a.any(r,e,f,u,c,n,p,n.user||""):a.pubs(r,e,f,u,c,n,p):a.alias(r,e,f,u,c,n,p)}}s.on("opt",(function(e){e.sea||(e.sea={own:{}},e.on("put",a,e)),this.to.next(e)})),a.hash=function(e,t,r,n,i,s,a){o.work(r,null,(function(r){if(r&&r===n.split("#").slice(-1)[0])return e.to.next(t);a("Data hash not same as hash!")}),{name:"SHA-256"})},a.alias=function(e,t,r,n,o,i,s){return r?"~@"+n===u(r)?e.to.next(t):void s("Alias not same!"):s("Data must exist!")},a.pubs=function(e,t,r,n,o,i,s){return r?n===u(r)?e.to.next(t):void s("Alias not same!"):s("Alias must exist!")},a.pub=async function(e,t,r,a,c,f,l,d,p){var h;const g=await i.parse(r)||{},y=(r,i,u)=>{if(r.m&&r.s&&i&&p)return o.verify(r,p,(r=>{if(n!==r&&n!==r.e&&t.put[">"]&&t.put[">"]>parseFloat(r.e))return l("Certificate expired.");if(n!==r&&r.c&&r.w&&(r.c===i||r.c.indexOf("*")>-1)){let t=c.indexOf("/")>-1?c.replace(c.substring(0,c.indexOf("/")+1),""):"";String.match=String.match||s.text.match;const n=Array.isArray(r.w)?r.w:"object"==typeof r.w||"string"==typeof r.w?[r.w]:[];for(const s of n)if(String.match(t,s["#"])&&String.match(a,s["."])||!s["."]&&String.match(t,s["#"])||!s["#"]&&String.match(a,s["."])||String.match(t?t+"/"+a:a,s["#"]||s)){if(s["+"]&&s["+"].indexOf("*")>-1&&t&&-1==t.indexOf(i)&&-1==a.indexOf(i))return l(`Path "${t}" or key "${a}" must contain string "${i}".`);if(r.wb&&("string"==typeof r.wb||(r.wb||{})["#"])){var o=e.as.root.$.back(-1);return"string"==typeof r.wb&&"~"!==r.wb.slice(0,1)&&(o=o.get("~"+p)),o.get(r.wb).get(i).once((e=>!e||1!==e&&!0!==e?u(r):l(`Certificant ${i} blocked.`)))}return u(r)}return l("Certificate verification fail.")}}))};if("pub"===a&&"~"+p===c)return r===p?e.to.next(t):l("Account not same!");(h=d.is)&&h.pub&&!g["*"]&&!g["+"]&&(p===h.pub||p!==h.pub&&((t._.msg||{}).opt||{}).cert)?o.opt.pack(t.put,(s=>{o.sign(s,d._.sea,(async function(s){if(n===s)return l(o.err||"Signature fail.");if(t.put[":"]={":":h=o.opt.unpack(s.m),"~":s.s},t.put["="]=h,p===d.is.pub)return(h=u(r))&&((f.sea.own[h]=f.sea.own[h]||{})[p]=1),void JSON.stringifyAsync(t.put[":"],(function(r,n){return r?l(r||"Stringify error."):(t.put[":"]=n,e.to.next(t))}));if(p!==d.is.pub&&((t._.msg||{}).opt||{}).cert){const r=await i.parse(t._.msg.opt.cert);r&&r.m&&r.s&&y(r,d.is.pub,(n=>{t.put[":"]["+"]=r,t.put[":"]["*"]=d.is.pub,JSON.stringifyAsync(t.put[":"],(function(r,n){return r?l(r||"Stringify error."):(t.put[":"]=n,e.to.next(t))}))}))}}),{raw:1})})):o.opt.pack(t.put,(r=>{o.verify(r,g["*"]||p,(function(r){var i;return r=o.opt.unpack(r),n===r?l("Unverified data."):((i=u(r))&&p===o.opt.pub(i)&&((f.sea.own[i]=f.sea.own[i]||{})[p]=1),g["+"]&&g["+"].m&&g["+"].s&&g["*"]?void y(g["+"],g["*"],(n=>(t.put["="]=r,e.to.next(t)))):(t.put["="]=r,e.to.next(t)))}))}))},a.any=function(e,t,r,n,o,i,s,a){if(i.opt.secure)return s("Soul missing public key at '"+n+"'.");i.on("secure",(function(t){if(this.off(),!i.opt.secure)return e.to.next(t);s("Data cannot be changed.")})).on.on("secure",t)};var c=s.valid,u=function(e,t){return"string"==typeof(t=c(e))&&t};(s.state||"").ify;var f=/[^\w_-]/;o.opt.pub=function(e){if(e&&(e=e.split("~"))&&(e=e[1])&&(e=e.split(f).slice(0,2))&&2==e.length&&"@"!==(e[0]||"")[0])return e=e.slice(0,2).join(".")},o.opt.stringy=function(e){},o.opt.pack=function(e,t,r,i,a){var c,u;if(o.opt.check(e))return t(e);e&&e["#"]&&e["."]&&e[">"]&&(c=e[":"],u=1),JSON.parseAsync(u?c:e,(function(o,c){var u=n!==(c||"")[":"]&&(c||"")["~"];t(u?{m:{"#":a||e["#"],".":r||e["."],":":(c||"")[":"],">":e[">"]||s.state.is(i,r)},s:u}:e)}))};var l=o.opt;o.opt.unpack=function(e,t,r){var i;if(n!==e){if(e&&n!==(i=e[":"]))return i;if(t=t||l.fall_key,!r&&l.fall_val&&((r={})[t]=l.fall_val),t&&r){if(e===r[t])return e;if(!o.opt.check(r[t]))return e;var a=r&&r._&&r._["#"]||l.fall_soul,c=s.state.is(r,t)||l.fall_state;return e&&4===e.length&&a===e[0]&&t===e[1]&&d(c)===d(e[3])?e[2]:c<o.opt.shuffle_attack?e:void 0}}},o.opt.shuffle_attack=15463296e5;var d=Math.floor}))(t,"./index")}()}({exports:{}});var $={exports:{}};!function(){function e(){var n=function(i,s,a){if(n.unit=0,a||t===s||(n.last=""+i<n.last?n.last:""+i,delete(n.$||{})[o]),a=a||n.$||(n.$={}),!i&&Object.keys(a).length)return a;for(var c,u,f=0,l=(i=""+i).length-1,d=i[f];!(c=a[d])&&f<l;)d+=i[++f];if(c){if(f!=l)return t!==s&&delete c[o],n(i.slice(++f),s,c||(c={}));if(t===s)return t===(u=c[""])?c:(n.unit=1)&&u;c[""]=s}else{if(!r(a,(function(r,n){var o=0,c="";if((n||"").length)for(;n[o]==i[o];)c+=n[o++];if(c){if(t===s){if(o<=l)return;return(u||(u={}))[n.slice(o)]=r,r}var f={};return f[n.slice(o)]=r,""===(o=i.slice(o))?f[""]=s:(f[o]={})[""]=s,a[c]=f,e.debug&&"undefined"==""+c&&console.log(0,c),delete a[n],!0}}))){if(t===s)return;(a[d]||(a[d]={}))[""]=s,e.debug&&"undefined"==""+d&&console.log(1,d)}if(t===s)return u}};return n}if(e.map=function r(i,s,a,c){c=c||[];var u="function"==typeof i?i.$||{}:i;
2
+ //!opt && console.log("WHAT IS T?", JSON.stringify(t).length);
3
+ if(u)if("string"!=typeof u){var f,l=(u[o]||n).sort||(u[o]=function e(){return e.sort=Object.keys(u).sort(),e}()).sort;(f=(a=!0===a?{branch:!0}:a||{}).reverse)&&(l=l.slice(0).reverse());for(var d=a.start,p=a.end,h=0,g=l.length;h<g;h++){var y,v,m,w=l[h],b=u[w];if(b&&""!==w&&o!==w&&((v=c.slice(0)).push(w),m=v.join(""),!(t!==d&&m<(d||"").slice(0,m.length)||t!==p&&(p||"￿")<m))){if(f&&(y=r(b,s,a,v),t!==y))return y;if(t!==(y=b[""])){var _=1;if(t!==d&&m<(d||"")&&(_=0),t!==p&&m>(p||"￿")&&(_=0),_&&(y=s(y,m,w,c),t!==y))return y}else if(a.branch&&(y=s(t,m,w,c),t!==y))return y;if(c=v,!f&&(y=r(b,s,a,c),t!==y))return y;c.pop()}}}else if(e.debug)throw["BUG:",i,s,a,c]},"undefined"!=typeof window)window.Radix=e;else try{$.exports=e}catch(e){}var t,r=e.object=function(e,r,n){for(var o in e)if(e.hasOwnProperty(o)&&(n=r(e[o],o))!==t)return n},n={},o=String.fromCharCode(24)}();var B={exports:{}};!function(e){!function(){var t,r={},n=setTimeout.turn||typeof setImmediate!=""+t&&setImmediate||setTimeout;function o(e){var t=parseFloat(e);return isNaN(t)?"true"==(e=e.trim())||"false"!=e&&("null"==e?null:void 0):t}r.parseAsync=function(e,r,i,s){if("string"==typeof e){var a={i:0,text:e,done:r,l:e.length,up:[]};s=s||32768,function r(){var i,c,u=a.text,f=a.i,l=a.l,d=0,p=a.w;for(;d++<s;){var h=u[f++];if(f>l){a.end=!0;break}if(p)f=u.indexOf('"',f-1),h=u[f],c="\\"==u[f-1],i=i||c,'"'!=h||c||(p=t,c=a.s,a.a?(c=u.slice(a.sl,f),(i||1+c.indexOf("\\u"))&&(c=JSON.parse('"'+c+'"')),a.at instanceof Array?a.at.push(a.s=c):(a.at||(a.end=d=s,c=t),(a.at||{})[a.s]=a.s=c)):(a.s=u.slice(a.sl,f),(i||1+a.s.indexOf("\\u"))&&(a.s=JSON.parse('"'+a.s+'"'))),a.a=i=t),++f;else switch(h){case'"':a.sl=f,p=!0;break;case":":a.ai=f,a.a=!0;break;case",":(a.a||a.at instanceof Array)&&(c=u.slice(a.ai,f-1))&&t!==(c=o(c))&&(a.at instanceof Array?a.at.push(c):a.at[a.s]=c),a.a=t,a.at instanceof Array&&(a.a=!0,a.ai=f);break;case"{":a.up.push(a.at||(a.at={})),a.at instanceof Array?a.at.push(a.at={}):t!==(c=a.s)&&(a.at[c]=a.at={}),a.a=t;break;case"}":a.a&&(c=u.slice(a.ai,f-1))&&t!==(c=o(c))&&(a.at instanceof Array?a.at.push(c):(a.at||(a.end=d=s,c=t),(a.at||{})[a.s]=c)),a.a=t,a.at=a.up.pop();break;case"[":t!==(c=a.s)?(a.up.push(a.at),a.at[c]=a.at=[]):a.at||a.up.push(a.at=[]),a.a=!0,a.ai=f;break;case"]":a.a&&(c=u.slice(a.ai,f-1))&&t!==(c=o(c))&&(a.at instanceof Array?a.at.push(c):a.at[a.s]=c),a.a=t,a.at=a.up.pop()}}if(a.s=t,a.i=f,a.w=p,a.end){if(c=a.at,t===c)try{c=JSON.parse(e)}catch(e){return a.done(e)}a.done(t,c)}else n(r)}()}else try{r(t,JSON.parse(e))}catch(e){r(e)}},r.stringifyAsync=function(e,r,o,i,s){(s=s||{}).text=s.text||"",s.up=[s.at={d:e}],s.done=r,s.i=0;var a=0;!function e(){var r,o=s.at,i=o.d,c="";o.i&&o.i-o.j>0&&(c+=",");t!==(r=o.k)&&(c+=JSON.stringify(r)+":");switch(typeof i){case"boolean":c+=""+i;break;case"string":c+=JSON.stringify(i);break;case"number":c+=i;break;case"object":if(!i){c+="null";break}if(i instanceof Array){c+="[",(o={i:-1,as:i,up:o,j:0}).l=i.length,s.up.push(s.at=o);break}if("function"!=typeof(i||"").toJSON){c+="{",(o={i:-1,ok:Object.keys(i).sort(),as:i,up:o,j:0}).l=o.ok.length,s.up.push(s.at=o);break}if(r=i.toJSON()){c+=r;break}case"function":if(o.as instanceof Array){c+="null";break}default:c="",o.j++}s.text+=c;for(;1+o.i>=o.l;)s.text+=o.ok?"}":"]",o=s.at=o.up;if(++o.i<o.l)return(r=o.ok)?o.d=o.as[o.k=r[o.i]]:o.d=o.as[o.i],++a<9?e():(a=0,void n(e));s.done(t,s.text)}()},typeof window!=""+t&&(window.YSON=r);try{e.exports=r}catch(e){}typeof JSON!=""+t&&(JSON.parseAsync=r.parseAsync,JSON.stringifyAsync=r.stringifyAsync)}()}({exports:{}}),function(){function e(t){(t=t||{}).log=t.log||console.log,t.file=String(t.file||"radata");var o=(e.has||(e.has={}))[t.file];if(o)return o;function i(e){return encodeURIComponent(e).replace(/\*/g,"%2A")}t.max=t.max||.3*(t.memory?999*t.memory*999:3e8),t.until=t.until||t.wait||250,t.batch=t.batch||1e4,t.chunk=t.chunk||1048576,t.code=t.code||{},t.code.from=t.code.from||"!",t.jsonify=!0;var s=""+y==typeof setImmediate?setTimeout:setImmediate,a=setTimeout.turn||s,c=n.object,u=0;if(!t.store)return t.log("ERROR: Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");if(!t.store.put)return t.log("ERROR: Radisk needs `store.put` interface with `(file, data, cb)`!");if(!t.store.get)return t.log("ERROR: Radisk needs `store.get` interface with `(file, cb)`!");t.store.list;var f=JSON.parseAsync||function(e,t,r){try{t(undefined,JSON.parse(e,r))}catch(e){t(e)}},l=function(e,t,r,n,o){if("function"==typeof t){var i=r||{};return r=t,void l.read(e,r,i,o||n)}l.save(e,t,r,n,o)};l.save=function(e,r,o,s,a){var c,u,f={key:e};f.find=function(e){var r;f.file=e||(e=t.code.from),a&&(a=a[e]=a[e]||{}),a&&(a.sf=a.sf||+new Date),(r=l.disk[e])?f.mix(y,r):l.parse(e,f.mix,y,a)},f.mix=function(i,c){if(a&&(a.sml=+new Date),a&&(a.sm=a.sm||+new Date),f.err=i||f.err)o(i);else{var u,d=f.file=(c||"").file||f.file;if(!c&&d!==t.code.from)return l.find.bad(d),void l.save(e,r,o,s);(c=l.disk[d]||(l.disk[d]=c||n())).file||(c.file=d),t.compare&&(r=t.compare(c(e),r,e,d),y===r)?o(i,-1):((f.disk=c)(e,r),s&&((u=(u=c.tags||(c.tags={}))[s]||(u[s]=l.tags[s]||(l.tags[s]={})))[d]||(u[d]=l.one[s]||(l.one[s]=o)),o=null),a&&(a.st=a.st||+new Date),c.Q?o&&c.Q.push(o):(c.Q=o?[o]:[],c.to=setTimeout(f.write,t.until)))}},f.write=function(){a&&(a.sto=a.sto||+new Date);var e=c=f.file,t=f.disk;u=f.q=t.Q,f.tags=t.tags,delete t.Q,delete l.disk[e],delete t.tags,l.write(e,t,f.ack,y,a)},f.ack=function(e,t){var r,n;for(var o in a&&(a.sa=a.sa||+new Date),a&&(a.sal=u.length),l.tags)if(l.tags.hasOwnProperty(o)){var s=l.tags[o];if(!((n=l.disk[c])&&(n=n.tags)&&n[s])){var d;for(var p in r=s[c],delete s[c],s)if(s.hasOwnProperty(p)){d=!0;break}d||(delete l.tags[s],r&&r(e,t))}}!u&&(u="");for(var h=u.length,g=0,y=+new Date;g<h;g++)(r=u[g])&&r(e,t);console.STAT&&console.STAT(y,+new Date-y,"rad acks",i(f.file)),console.STAT&&console.STAT(y,u.length,"rad acks #",i(f.file))},o||(o=function(e,t){}),l.find(e,f.find)},l.disk={},l.one={},l.tags={};var d,p,h,g=0;l.write=function(r,o,s,a,c){if(o){a="object"==typeof a?a:{force:a};var f,d,p=function(){};p.text="",p.file=r=o.file||(o.file=r),r?(p.write=function(){var e=o.raw=p.text;l.disk[r=o.file||p.file||r]=o;var n=+new Date;c&&(c.wd=n),l.find.add(r,(function(a){c&&(c.wa=+new Date),a?s(a):t.store.put(i(r),e,(function(e,t){c&&(c.wp=+new Date),console.STAT&&console.STAT(n,u=+new Date-n,"wrote disk",JSON.stringify(r),++g,"total all writes."),s(e,t||1),o.Q||delete l.disk[r]}))}))},p.split=function(){var e=+new Date;c&&(c.wf=e),p.text="",p.count||(p.count=0,n.map(o,(function(){p.count++}))),c&&(c.wfc=p.count),p.limit=Math.ceil(p.count/2);var t=p.count;return p.count=0,c&&(c.wf1=+new Date),p.sub=n(),n.map(o,p.slice,{reverse:1}),c&&(c.wf2=+new Date),l.write(p.end,p.sub,p.both,a),c&&(c.wf3=+new Date),p.hub=n(),n.map(o,p.stop),c&&(c.wf4=+new Date),l.write(o.file,p.hub,p.both,a),c&&(c.wf5=+new Date),console.STAT&&console.STAT(e,+new Date-e,"rad split",i(o.file),t),!0},p.slice=function(e,t){if(p.sub(p.end=t,e),p.limit<=++p.count)return!0},p.stop=function(e,t){if(t>=p.end)return!0;p.hub(t,e)},p.both=function(e,t){c&&(c.wfd=+new Date),d?s(e||d):f?s(e,t):(f=!0,d=e)},p.each=function(r,n,o,i){if(y!==r&&p.count++,t.max<=(r||"").length)return s("Data too big!"),!0;var c=e.encode(i.length)+"#"+e.encode(o)+(y===r?"":":"+e.encode(r))+"\n";if(t.chunk<p.text.length+c.length&&1<p.count&&!a.force)return p.split();p.text+=c},t.jsonify?l.write.jsonify(p,o,s,a,c):n.map(o,p.each,!0)||p.write()):s("What file?")}else s("No radix!")},l.write.jsonify=function(e,r,o,i,s){var a,c=+new Date;s&&(s.w=c);try{a=JSON.stringify(r.$)}catch(e){return void o("Cannot radisk!")}if(s&&(s.ws=+new Date),console.STAT&&console.STAT(c,+new Date-c,"rad stringified JSON"),t.chunk<a.length&&!i.force){var u=0;if(n.map(r,(function(){if(u++)return!0})),u>1)return e.split()}e.text=a,e.write()},l.range=function(e,t){if(e&&t){if(y===t.start&&y===t.end)return e;if(y!==(r=e)&&(!r||"object"!=typeof r))return e;var r,o=n();return n.map(e,(function(e,t){o(t,e)}),t),o("")}},l.read=function(e,r,o,c){o=o||{};var u={key:e,find:function(e){var r;u.file=e||(e=t.code.from),c&&(c=c[e]=c[e]||{}),c&&(c.rf=c.rf||+new Date),(r=l.disk[u.file=e])?u.check(y,r):l.parse(e,u.check,y,c)},get:function(i,a,f){if(c&&(c.rgl=+new Date),c&&(c.rg=c.rg||+new Date),u.err=i||u.err)r(i);else{var d=u.file=(a||"").file||u.file;if(!a&&d!==t.code.from)return l.find.bad(d),void l.read(e,r,o);if(a=l.disk[d]||(l.disk[d]=a)){a.file||(a.file=d);var p=l.range(a(e),o);if(c&&(c.rr=+new Date),o.unit=a.unit,o.chunks=(o.chunks||0)+1,o.parsed=(o.parsed||0)+((f||"").parsed||o.chunks*t.chunk),o.more=1,o.next=y,n.map(l.list,(function(e,t){if(e&&d!==t)return o.next=t,1}),o.reverse?{reverse:1,end:d}:{start:d}),c&&(c.rl=+new Date),o.next||(o.more=0),o.next&&(!o.reverse&&(e<o.next&&0!=o.next.indexOf(e)||y!==o.end&&(o.end||"￿")<o.next)&&(o.more=0),o.reverse&&(e>o.next&&0!=e.indexOf(o.next)||y!==o.start&&(o.start||"")>o.next&&d<=o.start)&&(o.more=0)),o.more){if(p&&r(u.err,p,o),!(o.parsed>=o.limit)){var h=+new Date;c&&(c.rm=h);var g=o.next;s((function(){console.STAT&&console.STAT(h,+new Date-h,"rad more"),l.parse(g,u.check)}),0)}}else r(u.err,p,o)}else r(d===t.code.from?y:"No file!")}},check:function(e,r,o){if(u.get(e,r,o),r&&!r.check){r.check=1;var s=+new Date;(o||(o={})).file||(o.file=u.file),n.map(r,(function(e,r){l.find(r,(function(n){if((n||(n=t.code.from))!==o.file){var s=(""+Math.random()).slice(-3);a((function(){l.save(r,e,(function t(a,c){a?l.save(r,e,t):console.STAT&&console.STAT("MISLOCATED DATA CORRECTED",s,i(r),i(o.file),i(n))}))}),0)}}))})),console.STAT&&console.STAT(s,+new Date-s,"rad check")}}};l.find(e||(o.reverse?o.end||"":o.start||""),u.find)},d=0,p={},h=String.fromCharCode(31),l.parse=function(r,o,s,c){var g;if(!r)return o();if(g=p[r])g.push(o);else{g=p[r]=[o];var v=function(){},m={file:r};(v.disk=n()).file=r,v.read=function(e,n){if(c&&(c.rpg=+new Date),console.STAT&&console.STAT(w,+new Date-w,"read disk",JSON.stringify(r),++d,"total all parses."),(v.err=e)||(v.not=!n))return delete p[r],void v.map(g,v.ack);if("string"!=typeof n){try{t.max<=n.length?v.err="Chunk too big!":n=n.toString()}catch(e){v.err=e}if(v.err)return delete p[r],void v.map(g,v.ack)}m.parsed=n.length,c&&(c.rpl=m.parsed),c&&(c.rpa=g.length),w=+new Date,t.jsonify||"{"===n[0]?f(n,(function(e,t){return e?"{"===n[0]?(delete p[r],v.err="JSON error!",void v.map(g,v.ack)):void v.radec(e,n):(delete p[r],v.disk.$=t,console.STAT&&(u=+new Date-w)>9&&console.STAT(w,u,"rad parsed JSON"),c&&(c.rpd=+new Date),void v.map(g,v.ack))})):v.radec(e,n)},v.map=function(){if(g&&g.length){for(var e,t=+new Date,n=v.err,o=v.not?y:v.disk,s=0;s<9&&(e=g[s++]);)e(n,o,m);console.STAT&&console.STAT(t,+new Date-t,"rad packs",i(r)),console.STAT&&console.STAT(t,s,"rad packs #",i(r)),(g=g.slice(s)).length&&a(v.map,0)}},v.ack=function(e){e&&(v.err||v.not?e(v.err,y,m):e(y,v.disk,m))},v.radec=function(e,t){delete p[r],w=+new Date;var n,o,i,s=v.split(t),a=[];if(!s||0!==s[1])return v.err="File '"+r+"' does not have root radix! ",void v.map(g,v.ack);for(;s;)o=i=y,n=s[1],"#"==(s=v.split(s[2])||"")[0]&&(o=s[1],n<=(a=a.slice(0,n)).length&&a.push(o)),"\n"!=(s=v.split(s[2])||"")[0]&&("="!=s[0]&&":"!=s[0]||(i=s[1]),y!==o&&y!==i&&v.disk(a.join(""),i),s=v.split(s[2]));console.STAT&&console.STAT(w,+new Date-w,"parsed RAD"),v.map(g,v.ack)},v.split=function(t){if(t){var r,n,o=[],i={};if(r=t.indexOf(h),t[r])return n=t.slice(0,r),o[0]=n,o[1]=e.decode(t.slice(r),i),o[2]=t.slice(r+i.i),o}},l.disk&&(s||(s=(l.disk[r]||"").raw));var w=+new Date;if(c&&(c.rp=w),s)return a((function(){v.read(y,s)}),0);t.store.get(i(r),v.read)}},function(){var e,r,o=String.fromCharCode(28);function i(r,a){if(r)return t.log("list",r),void setTimeout((function(){l.parse(o,i)}),1e3);a?s(a):(e=e||a||n(),t.store.list?t.store.list((function(t){t?l.find.add(t,v):s(e)})):s(e))}function s(t,n){(e=e||t).file=o,n=r,r=null,c(n,(function(e){l.find(e[0],e[1])}))}l.find=function(s,a){if(!e)return r?void r.push([s,a]):(r=[[s,a]],void l.parse(o,i));n.map(l.list=e,(function(e,t){if(e)return a(t)||!0}),{reverse:1,end:s})||a(t.code.from)},l.find.add=function(t,r){e(t)||t===o?r(y,1):(e(t,1),r.found=(r.found||0)+1,l.write(o,e,(function(e,t){e?r(e):(r.found=(r.found||0)-1,0===r.found&&r(y,1))}),!0))},l.find.bad=function(t,r){e(t,0),l.write(o,e,r||v)}}();try{!r.window&&require("./radmigtmp")(l)}catch(e){}var y,v=function(){};return e.has[t.file]=l,l}var t;if(t=String.fromCharCode(31),e.encode=function(e,r,n){var o=n=n||t;if("string"==typeof e){for(var i=e.indexOf(n);-1!=i;)o+=n,i=e.indexOf(n,i+1);return o+'"'+e+n}return e&&e["#"]&&1==Object.keys(e).length?o+"#"+void 0+o:"number"==typeof e?o+"+"+(e||0)+o:null===e?o+" "+o:!0===e?o+"+"+o:!1===e?o+"-"+o:void 0},e.decode=function(e,r,n){var o,i,s,a=-1,c=0;if((n=n||t)===e[0]){for(;n===e[++a];)++c;for(s=e[i=c]||!0;--c>=0;)a=e.indexOf(n,a+1);return-1==a&&(a=e.length),o=e.slice(i+1,a),r&&(r.i=a+1),'"'===s?o:"#"===s?{"#":o}:"+"===s?0===o.length||parseFloat(o):" "===s?null:"-"!==s&&void 0}},"undefined"!=typeof window){var r=window.Gun,n=window.Radix;window.Radisk=e}else{r=N.exports,n=$.exports;try{B.exports=e}catch(e){}}e.Radix=n}();var R="undefined"!=typeof window?window.Gun:N.exports;R.on("create",(function(e){R.TESTING&&(e.opt.file="radatatest"),this.to.next(e);var t,r=e.opt;if(!1!==r.rad&&!1!==r.radisk&&(t+""==typeof process||"false"!=""+(process.env||"").RAD)){var n=R.window&&R.window.Radisk||B.exports,o=n.Radix,i=n(r),s=String.fromCharCode(27),a=0;e.on("put",(function(t){if(this.to.next(t),!(t._||"").rad){var r=t["#"],n=t.put,o=n["#"],a=n["."],c=n[":"],u=n[">"],f=(t._||"").DBG;f&&(f.sp=f.sp||+new Date);var l=(t._||"").RPS||((t._||"").RPS=+new Date);i(o+s+a,{":":c,">":u},(function(t,n){f&&(f.spd=f.spd||+new Date),console.STAT&&console.STAT(l,+new Date-l,"put"),t?e.on("in",{"@":r,err:t,DBG:f}):e.on("in",{"@":r,ok:n,DBG:f})}),!1,f&&(f.r=f.r||{})),f&&(f.sps=f.sps||+new Date)}})),e.on("get",(function(u){this.to.next(u);var f=(u._||"").DBG=u.DBG;f&&(f.sg=+new Date);var l,d,p,h,g=u["#"],y=u.get,v=u.get["#"],m=u.get["."]||"",w={};if("string"==typeof v?d=v:v&&(t!==(p=v["*"])&&(w.limit=h=1),t!==v[">"]&&(w.start=v[">"]),t!==v["<"]&&(w.end=v["<"]),d=h?""+p:p||v["="],h=null),d&&!w.limit&&("string"==typeof m?d=d+s+(w.atom=m):m&&(t!==m[">"]&&(w.start=m[">"],w.limit=1),t!==m["<"]&&(w.end=m["<"],w.limit=1),t!==(p=m["*"])&&(w.limit=h=1),d&&(d=d+s+(h?""+(p||""):p||(w.atom=m["="]||""))))),((p=y["%"])||w.limit)&&(w.limit=p<=(w.pack||1e5)?p:1),(m["-"]||(v||{})["-"]||y["-"])&&(w.reverse=!0),(p=(e.next||"")[v])&&p.put)if(w.atom){if((p=(p.next||"")[w.atom])&&p.rad)return}else if(p&&p.rad)return;var b=R.state(),_=+new Date,S=0;function k(e,t,r,o){if(S++,e){var i=(t=(d+t).split(s)).slice(0,1)[0];if(t=t.slice(-1)[0],w.limit&&w.limit<=w.count)return!0;var a,c,u=i,f=t;if("string"!=typeof e)return a=e[":"],c=e[">"],(l=l||{})[u]=R.state.ify(l[u],f,c,a,u),void(w.count=(w.count||0)+((a||"").length||9));w.count=(w.count||0)+e.length;var p=e.lastIndexOf(">"),h=n.decode(e.slice(p+1),null,s);e=n.decode(e.slice(0,p),null,s),(l=l||{})[i]=R.state.ify(l[i],t,h,e,i)}}f&&(f.sgm=_),i(d||"",(function(n,i,u){f&&(f.sgr=+new Date),f&&(f.sgi=u);try{r.store.stats.get.time[c%50]=+new Date-_,++c,r.store.stats.get.count++,n&&(r.store.stats.get.err=n)}catch(e){}var p,h;if(console.STAT&&console.STAT(_,+new Date-_,"got",JSON.stringify(d)),_=+new Date,(u=u||"").unit&&i&&t!==(p=i[":"])&&t!==(h=i[">"])){var x=d.split(s),T=x[0],E=x[1];(l=l||{})[T]=R.state.ify(l[T],E,h,p,T),e.$.get(T).get(E)._.rad=b}else i&&("string"!=typeof i&&(w.atom?i=t:o.map(i,k,w)),!l&&i&&k(i,""),!w.atom&&!m&"string"==typeof v&&!w.limit&&!w.more&&(e.$.get(v)._.rad=b));f&&(f.sgp=+new Date),console.STAT&&(a=+new Date-_)>9&&(console.STAT(_,a,"got prep time"),console.STAT(_,S,"got prep #")),S=0,_=+new Date;var A=function(){};A.faith=!0,A.rad=y,e.on("in",{"@":g,put:l,"%":u.more?1:t,err:n||t,_:A,DBG:f}),console.STAT&&(a=+new Date-_)>9&&console.STAT(_,a,"got emit",Object.keys(l||{}).length),l=t}),w,f&&(f.r=f.r||{})),f&&(f.sgd=+new Date),console.STAT&&(a=+new Date-_)>9&&console.STAT(_,a,"get call")})),R.valid,(r.store||{}).stats={get:{time:{},count:0},put:{time:{},count:0}};var c=0}}));var P={exports:{}};!function(){function e(t){(t=t||{}).file=String(t.file||"radata");var r=e[t.file],n=null;if(r)return console.log("Warning: reusing same IndexedDB store and options as 1st."),e[t.file];r=e[t.file]=function(){};try{t.indexedDB=t.indexedDB||e.indexedDB||indexedDB}catch(e){}try{if(!t.indexedDB||"file:"==location.protocol){var o=r.d||(r.d={});return r.put=function(e,t,r){o[e]=t,setTimeout((function(){r(null,1)}),250)},r.get=function(e,t){setTimeout((function(){t(null,o[e]||undefined)}),5)},console.log("Warning: No indexedDB exists to persist data to!"),r}}catch(e){}return r.start=function(){var e=indexedDB.open(t.file,1);e.onupgradeneeded=function(e){e.target.result.createObjectStore(t.file)},e.onsuccess=function(){n=e.result},e.onerror=function(e){console.log(e||1)}},r.start(),r.put=function(e,o,i){if(n){var s=n.transaction([t.file],"readwrite"),a=s.objectStore(t.file),c=a.put(o,""+e);c.onsuccess=a.onsuccess=s.onsuccess=function(){i(null,1)},c.onabort=a.onabort=s.onabort=function(e){i(e||"put.tx.abort")},c.onerror=a.onerror=s.onerror=function(e){i(e||"put.tx.error")}}else setTimeout((function(){r.put(e,o,i)}),1)},r.get=function(e,o){if(n){var i=n.transaction([t.file],"readonly").objectStore(t.file).get(""+e);i.onsuccess=function(){o(null,i.result)},i.onabort=function(e){o(e||4)},i.onerror=function(e){o(e||5)}}else setTimeout((function(){r.get(e,o)}),9)},setInterval((function(){n&&n.close(),n=null,r.start()}),15e3),r}if("undefined"!=typeof window)(e.window=window).RindexedDB=e,e.indexedDB=window.indexedDB;else try{P.exports=e}catch(e){}try{(e.window.Gun||require("../gun")).on("create",(function(t){this.to.next(t),t.opt.store=t.opt.store||e(t.opt)}))}catch(e){}}();let M=new j({peers:["https://gun-relay.scobrudot.dev/gun"],axe:!1,localStorage:!1,radisk:!0}),I=M.user().recall({sessionStorage:!0});
4
+ /*! *****************************************************************************
5
+ Copyright (c) Microsoft Corporation.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
+ PERFORMANCE OF THIS SOFTWARE.
17
+ ***************************************************************************** */
18
+ var U=function(e,t){return U=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},U(e,t)};function L(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}U(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function G(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function q(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e}function F(e){return"function"==typeof e}function J(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var H=J((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function V(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var K=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._teardowns=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var s=G(i),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else i.remove(this);var c=this.initialTeardown;if(F(c))try{c()}catch(e){o=e instanceof H?e.errors:[e]}var u=this._teardowns;if(u){this._teardowns=null;try{for(var f=G(u),l=f.next();!l.done;l=f.next()){var d=l.value;try{X(d)}catch(e){o=null!=o?o:[],e instanceof H?o=q(q([],W(o)),W(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}}if(o)throw new H(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)X(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._teardowns=null!==(r=this._teardowns)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&V(t,e)},e.prototype.remove=function(t){var r=this._teardowns;r&&V(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),Y=K.EMPTY;function z(e){return e instanceof K||e&&"closed"in e&&F(e.remove)&&F(e.add)&&F(e.unsubscribe)}function X(e){F(e)?e():e.unsubscribe()}var Q={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Z={setTimeout:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Z.delegate;return((null==r?void 0:r.setTimeout)||setTimeout).apply(void 0,q([],W(e)))},clearTimeout:function(e){var t=Z.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function ee(){}var te=null;function re(e){if(Q.useDeprecatedSynchronousErrorHandling){var t=!te;if(t&&(te={errorThrown:!1,error:null}),e(),t){var r=te,n=r.errorThrown,o=r.error;if(te=null,n)throw o}}else e()}var ne=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,z(t)&&t.add(r)):r.destination=ae,r}return L(t,e),t.create=function(e,t,r){return new oe(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(K),oe=function(e){function t(t,r,n){var o,i=e.call(this)||this;if(F(t))o=t;else if(t){var s;o=t.next,r=t.error,n=t.complete,i&&Q.useDeprecatedNextContext?(s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()}:s=t,o=null==o?void 0:o.bind(s),r=null==r?void 0:r.bind(s),n=null==n?void 0:n.bind(s)}return i.destination={next:o?ie(o):ee,error:ie(null!=r?r:se),complete:n?ie(n):ee},i}return L(t,e),t}(ne);function ie(e,t){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{e.apply(void 0,q([],W(t)))}catch(e){!function(e){Z.setTimeout((function(){throw e}))}(e)}}}function se(e){throw e}var ae={closed:!0,next:ee,error:se,complete:ee},ce="function"==typeof Symbol&&Symbol.observable||"@@observable";function ue(e){return e}var fe=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,i=(n=e)&&n instanceof ne||function(e){return e&&F(e.next)&&F(e.error)&&F(e.complete)}(n)&&z(n)?e:new oe(e,t,r);return re((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=le(t))((function(t,n){var o;o=r.subscribe((function(t){try{e(t)}catch(e){n(e),null==o||o.unsubscribe()}}),n,t)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[ce]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?ue:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=le(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function le(e){var t;return null!==(t=null!=e?e:Q.Promise)&&void 0!==t?t:Promise}var de=J((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),pe=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return L(t,e),t.prototype.lift=function(e){var t=new he(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new de},t.prototype.next=function(e){var t=this;re((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){var o=t.observers.slice();try{for(var i=G(o),s=i.next();!s.done;s=i.next()){s.value.next(e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;re((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;re((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=t.hasError,n=t.isStopped,o=t.observers;return r||n?Y:(o.push(e),new K((function(){return V(o,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new fe;return e.source=this,e},t.create=function(e,t){return new he(e,t)},t}(fe),he=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return L(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:Y},t}(pe);let ge=new pe;M.on("auth",(()=>ge.next(!0)));var ye=Object.freeze({__proto__:null,checkAuth:()=>I.is?ge.next(!0):ge.next(!1),isAuthenticated:ge,loginUser:(e={},t=()=>{})=>{I.auth(e.username,e.password,(({err:e,pub:r})=>t(e?{errMessage:e,errCode:"gun-auth-error"}:{errMessage:void 0,errCode:void 0,pub:r,message:"Successfully authenticated user."})))},registerUser:(e={},t=()=>{})=>{console.log("Credentials",e),console.log("Registering user..."),(async()=>{if(await(async e=>void 0!==await M.get(`~@${e}`))(e.username))return t({errMessage:"Username in use.",errCode:"username-inuse"});I.create(e.username,e.password,(({err:e,pub:r})=>t(e?{errMessage:e,errCode:"gun-auth-error"}:{errMessage:void 0,errCode:void 0,pub:r,message:"Successfully created user."})))})()},logout:()=>{M.user().leave(),ge.next(!1)}}),ve={exports:{}},me=y.default,we=v.default,be=/\.\.+/g,_e=/\/\/+/g;function Se(e,t,r){var n,o;if("string"==typeof e)return o=e,function(e,t){e.url=(e.url||"").replace(be,"").replace(_e,"/"),Se(e,t)||(".js"===e.url.slice(-3)&&t.writeHead(200,{"Content-Type":"text/javascript"}),me.createReadStream(we.join(o,e.url)).on("error",(function(e){me.readFile(we.join(o,"index.html"),(function(e,r){try{t.writeHead(200,{"Content-Type":"text/html"}),t.end(r+"")}catch(e){}}))})).pipe(t))};if(!e||!t)return!1;if(r=r||Se,!e.url)return r();if(t.setHeader&&t.setHeader("Access-Control-Allow-Origin","*"),0<=e.url.indexOf("gun.js"))return t.writeHead(200,{"Content-Type":"text/javascript"}),t.end(Se.js=Se.js||y.default.readFileSync(__dirname+"/../gun.js")),!0;if(0<=e.url.indexOf("gun/")){var i=__dirname+"/../"+e.url.split("/").slice(2).join("/");if("/"===i.slice(-1))return me.readdir(i,(function(e,r){t.end((r||e&&404)+"")})),!0;var s=+new Date,a=me.createReadStream(i);return a.on("open",(function(){console.STAT&&console.STAT(s,+new Date-s,"serve file open"),a.pipe(t)})),a.on("error",(function(e){t.end("404")})),a.on("end",(function(){console.STAT&&console.STAT(s,+new Date-s,"serve file end")})),!0}if((n=e.socket)&&(n=n.server)&&(n=n.route)&&(n=n[((e.url||"").slice(1).split("/")[0]||"").split(".")[0]]))try{return n(e,t,r)}catch(t){console.log(e.url+" crashed with "+t)}return r()}var ke=Se;function xe(e){(e=e||{}).log=e.log||console.log,e.file=String(e.file||"radata");var t=y.default,r=function(){};if(xe[e.file])return console.log("Warning: reusing same fs store and options as 1st."),xe[e.file];xe[e.file]=r;var n={};return r.put=function(r,o,i){var s=Math.random().toString(36).slice(-3);n[r]={id:s,data:o};var a=e.file+"-"+r+"-"+s+".tmp";t.writeFile(a,o,(function(o,c){if(o)return s===(n[r]||"").id&&delete n[r],i(o);!function(e,r,n){t.rename(e,r,(function(o){if(o)if("EXDEV"===o.code){var i=t.createReadStream(e),s=t.createWriteStream(r);i.on("error",n),s.on("error",n),i.on("close",(function(){t.unlink(e,n)})),i.pipe(s)}else n(o);else n()}))}(a,e.file+"/"+r,(function(e,t){s===(n[r]||"").id&&delete n[r],i(e,t||!e)}))}))},r.get=function(r,o){var i;(i=n[r])?o(undefined,i.data):t.readFile(e.file+"/"+r,(function(t,r){if(t){if("ENOENT"===(t.code||"").toUpperCase())return o();e.log("ERROR:",t)}o(t,r)}))},t.existsSync(e.file)||t.mkdirSync(e.file),r.list=function(r,n,o,i){t.readdirSync(e.file).forEach((function(e){r(e)})),r()},r}var Te="undefined"!=typeof window?window.Gun:N.exports;Te.on("create",(function(e){this.to.next(e);var t=e.opt;!1!==t.rfs&&(t.store=t.store||!Te.window&&xe(t))}));var Ee,Ae,Oe=xe,De=N.exports;function Ce(e){(e=e||{}).file=String(e.file||"radata");var t=e.s3,r=t.s3,n={p:{},g:{},l:{}},o=function(){};return Ce[e.file]?(console.log("Warning: reusing same S3 store and options as 1st."),Ce[e.file]):(Ce[e.file]=o,o.put=function(e,o,i){var s={Bucket:t.bucket,Key:e,Body:o};n.p[e]=o,delete n.g[e],delete n.l[1],r.putObject(s,(function(t,r){delete n.p[e],i(t,"s3")}))},o.get=function(e,o){var i;if(i=n.p[e])o(Ee,i);else if(i=n.g[e])i.push(o);else{var s=n.g[e]=[o],a={Bucket:t.bucket,Key:e||""};r.getObject(a,(function(t,r){t&&"NoSuchKey"===t.code&&(t=Ee),delete n.g[e];for(var o,i=(r||"").Body,a=0;o=s[a++];)o&&o(t,i)}))}},o.list=function(e,i,s,a){if(!a){if(n.l[1])return n.l[1].push(e);a=n.l[1]=[e]}s=s||{Bucket:t.bucket},r.listObjectsV2(s,(function(t,r){if(t)return De.log(t,t.stack);var c=r.IsTruncated;De.obj.map(a,(function(e){e.end||(De.obj.map(r.Contents,(function(t){return e(t.Key)}))?e.end=!0:c||(e.end=!0,e()))})),c?(s.ContinuationToken=r.NextContinuationToken,o.list(e,i,s,a)):De.obj.del(n.l,1)}))},!1!==e.rfs&&function(e,t){var r=Oe(e),n=t.put,o=t.get;t.put=function(e,t,o){var i,s,a=function(e,t){return s?o(e||s):i?o(e,t):(i=!0,void(s=e))};n(e,t,a),r.put(e,t,a)},t.get=function(e,t){r.get(e,(function(r,n){if(n)return t(r,n);o(e,t)}))}}(e,o),o)}B.exports.Radix,De.on("create",(function(e){this.to.next(e);var t=e.opt;if(t.s3||process.env.AWS_S3_BUCKET){try{Ae=require("aws-sdk")}catch(e){console.log("Please `npm install aws-sdk` or add it to your package.json !"),AWS_SDK_NOT_INSTALLED}var r=t.s3||(t.s3={});r.bucket=r.bucket||process.env.AWS_S3_BUCKET,r.region=r.region||process.env.AWS_REGION||"us-east-1",r.accessKeyId=r.key=r.key||r.accessKeyId||process.env.AWS_ACCESS_KEY_ID,r.secretAccessKey=r.secret=r.secret||r.secretAccessKey||process.env.AWS_SECRET_ACCESS_KEY,(t.fakes3=t.fakes3||process.env.fakes3)&&(r.endpoint=t.fakes3,r.sslEnabled=!1,r.bucket=r.bucket.replace(".","p")),r.config=new Ae.Config(r),r.s3=r.s3||new Ae.S3(r.config),t.store=0===Object.keys(r.s3).length?t.store:Ce(t)}}));var Ne={exports:{}},je={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),EMPTY_BUFFER:Buffer.alloc(0),NOOP:()=>{}};const{EMPTY_BUFFER:$e}=je;function Be(e,t){if(0===e.length)return $e;if(1===e.length)return e[0];const r=Buffer.allocUnsafe(t);let n=0;for(let t=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return n<t?r.slice(0,n):r}function Re(e,t,r,n,o){for(let i=0;i<o;i++)r[n+i]=e[i]^t[3&i]}function Pe(e,t){const r=e.length;for(let n=0;n<r;n++)e[n]^=t[3&n]}function Me(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function Ie(e){if(Ie.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=Buffer.from(e):ArrayBuffer.isView(e)?t=Buffer.from(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),Ie.readOnly=!1),t}try{const e=require("bufferutil"),t=e.BufferUtil||e;Ne.exports={concat:Be,mask(e,r,n,o,i){i<48?Re(e,r,n,o,i):t.mask(e,r,n,o,i)},toArrayBuffer:Me,toBuffer:Ie,unmask(e,r){e.length<32?Pe(e,r):t.unmask(e,r)}}}catch(e){Ne.exports={concat:Be,mask:Re,toArrayBuffer:Me,toBuffer:Ie,unmask:Pe}}const Ue=Symbol("kDone"),Le=Symbol("kRun");var Ge=class{constructor(e){this[Ue]=()=>{this.pending--,this[Le]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Le]()}[Le](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[Ue])}}};const We=E.default,qe=Ne.exports,Fe=Ge,{kStatusCode:Je,NOOP:He}=je,Ve=Buffer.from([0,0,255,255]),Ke=Symbol("permessage-deflate"),Ye=Symbol("total-length"),ze=Symbol("callback"),Xe=Symbol("buffers"),Qe=Symbol("error");let Ze;var et=class{constructor(e,t,r){if(this._maxPayload=0|r,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!Ze){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;Ze=new Fe(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[ze];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,r=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(r.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?r.client_max_window_bits=t.clientMaxWindowBits:!0!==r.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete r.client_max_window_bits,r}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let r=e[t];if(r.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(r=r[0],"client_max_window_bits"===t){if(!0!==r){const e=+r;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${r}`)}else if("server_max_window_bits"===t){const e=+r;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==r)throw new TypeError(`Invalid value for parameter "${t}": ${r}`)}e[t]=r}))})),e}decompress(e,t,r){Ze.add((n=>{this._decompress(e,t,((e,t)=>{n(),r(e,t)}))}))}compress(e,t,r){Ze.add((n=>{this._compress(e,t,((e,t)=>{n(),r(e,t)}))}))}_decompress(e,t,r){const n=this._isServer?"client":"server";if(!this._inflate){const e=`${n}_max_window_bits`,t="number"!=typeof this.params[e]?We.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=We.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[Ke]=this,this._inflate[Ye]=0,this._inflate[Xe]=[],this._inflate.on("error",nt),this._inflate.on("data",rt)}this._inflate[ze]=r,this._inflate.write(e),t&&this._inflate.write(Ve),this._inflate.flush((()=>{const e=this._inflate[Qe];if(e)return this._inflate.close(),this._inflate=null,void r(e);const o=qe.concat(this._inflate[Xe],this._inflate[Ye]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ye]=0,this._inflate[Xe]=[],t&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),r(null,o)}))}_compress(e,t,r){const n=this._isServer?"server":"client";if(!this._deflate){const e=`${n}_max_window_bits`,t="number"!=typeof this.params[e]?We.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=We.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[Ye]=0,this._deflate[Xe]=[],this._deflate.on("error",He),this._deflate.on("data",tt)}this._deflate[ze]=r,this._deflate.write(e),this._deflate.flush(We.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=qe.concat(this._deflate[Xe],this._deflate[Ye]);t&&(e=e.slice(0,e.length-4)),this._deflate[ze]=null,this._deflate[Ye]=0,this._deflate[Xe]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,e)}))}};function tt(e){this[Xe].push(e),this[Ye]+=e.length}function rt(e){this[Ye]+=e.length,this[Ke]._maxPayload<1||this[Ye]<=this[Ke]._maxPayload?this[Xe].push(e):(this[Qe]=new RangeError("Max payload size exceeded"),this[Qe].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Qe][Je]=1009,this.removeListener("data",rt),this.reset())}function nt(e){this[Ke]._inflate=null,e[Je]=1007,this[ze](e)}var ot={exports:{}};function it(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999}function st(e){const t=e.length;let r=0;for(;r<t;)if(128&e[r])if(192==(224&e[r])){if(r+1===t||128!=(192&e[r+1])||192==(254&e[r]))return!1;r+=2}else if(224==(240&e[r])){if(r+2>=t||128!=(192&e[r+1])||128!=(192&e[r+2])||224===e[r]&&128==(224&e[r+1])||237===e[r]&&160==(224&e[r+1]))return!1;r+=3}else{if(240!=(248&e[r]))return!1;if(r+3>=t||128!=(192&e[r+1])||128!=(192&e[r+2])||128!=(192&e[r+3])||240===e[r]&&128==(240&e[r+1])||244===e[r]&&e[r+1]>143||e[r]>244)return!1;r+=4}else r++;return!0}try{let e=require("utf-8-validate");"object"==typeof e&&(e=e.Validation.isValidUTF8),ot.exports={isValidStatusCode:it,isValidUTF8:t=>t.length<150?st(t):e(t)}}catch(e){ot.exports={isValidStatusCode:it,isValidUTF8:st}}const{Writable:at}=T.default,ct=et,{BINARY_TYPES:ut,EMPTY_BUFFER:ft,kStatusCode:lt,kWebSocket:dt}=je,{concat:pt,toArrayBuffer:ht,unmask:gt}=Ne.exports,{isValidStatusCode:yt,isValidUTF8:vt}=ot.exports;var mt=class extends at{constructor(e,t,r,n){super(),this._binaryType=e||ut[0],this[dt]=void 0,this._extensions=t||{},this._isServer=!!r,this._maxPayload=0|n,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=0,this._loop=!1}_write(e,t,r){if(8===this._opcode&&0==this._state)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=t.slice(e),t.slice(0,e)}const t=Buffer.allocUnsafe(e);do{const r=this._buffers[0],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),this._buffers[0]=r.slice(e)),e-=r.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do{switch(this._state){case 0:t=this.getInfo();break;case 1:t=this.getPayloadLength16();break;case 2:t=this.getPayloadLength64();break;case 3:this.getMask();break;case 4:t=this.getData(e);break;default:return void(this._loop=!1)}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2)return void(this._loop=!1);const e=this.consume(2);if(48&e[0])return this._loop=!1,wt(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");const t=!(64&~e[0]);if(t&&!this._extensions[ct.extensionName])return this._loop=!1,wt(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=!(128&~e[0]),this._opcode=15&e[0],this._payloadLength=127&e[1],0===this._opcode){if(t)return this._loop=!1,wt(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,wt(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return this._loop=!1,wt(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else{if(!(this._opcode>7&&this._opcode<11))return this._loop=!1,wt(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin)return this._loop=!1,wt(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,wt(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,wt(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~e[1]),this._isServer){if(!this._masked)return this._loop=!1,wt(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,wt(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(126===this._payloadLength)this._state=1;else{if(127!==this._payloadLength)return this.haveLength();this._state=2}}getPayloadLength16(){if(!(this._bufferedBytes<2))return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength();this._loop=!1}getPayloadLength64(){if(this._bufferedBytes<8)return void(this._loop=!1);const e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,wt(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,wt(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=ft;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&gt(t,this._mask)}return this._opcode>7?this.controlMessage(t):this._compressed?(this._state=5,void this.decompress(t,e)):(t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage())}decompress(e,t){this._extensions[ct.extensionName].decompress(e,this._fin,((e,r)=>{if(e)return t(e);if(r.length){if(this._messageLength+=r.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(wt(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(r)}const n=this.dataMessage();if(n)return t(n);this.startLoop(t)}))}dataMessage(){if(this._fin){const e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?pt(t,e):"arraybuffer"===this._binaryType?ht(pt(t,e)):t,this.emit("message",r)}else{const r=pt(t,e);if(!vt(r))return this._loop=!1,wt(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r.toString())}}this._state=0}controlMessage(e){if(8===this._opcode)if(this._loop=!1,0===e.length)this.emit("conclude",1005,""),this.end();else{if(1===e.length)return wt(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{const t=e.readUInt16BE(0);if(!yt(t))return wt(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");const r=e.slice(2);if(!vt(r))return wt(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,r.toString()),this.end()}}else 9===this._opcode?this.emit("ping",e):this.emit("pong",e);this._state=0}};function wt(e,t,r,n,o){const i=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(i,wt),i.code=o,i[lt]=n,i}const{randomFillSync:bt}=x.default,_t=et,{EMPTY_BUFFER:St}=je,{isValidStatusCode:kt}=ot.exports,{mask:xt,toBuffer:Tt}=Ne.exports,Et=Buffer.alloc(4);class At{constructor(e,t){this._extensions=t||{},this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){const r=t.mask&&t.readOnly;let n=t.mask?6:2,o=e.length;e.length>=65536?(n+=8,o=127):e.length>125&&(n+=2,o=126);const i=Buffer.allocUnsafe(r?e.length+n:n);return i[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(i[0]|=64),i[1]=o,126===o?i.writeUInt16BE(e.length,2):127===o&&(i.writeUInt32BE(0,2),i.writeUInt32BE(e.length,6)),t.mask?(bt(Et,0,4),i[1]|=128,i[n-4]=Et[0],i[n-3]=Et[1],i[n-2]=Et[2],i[n-1]=Et[3],r?(xt(e,Et,i,n,e.length),[i]):(xt(e,Et,e,0,e.length),[i,e])):[i,e]}close(e,t,r,n){let o;if(void 0===e)o=St;else{if("number"!=typeof e||!kt(e))throw new TypeError("First argument must be a valid error code number");if(void 0===t||""===t)o=Buffer.allocUnsafe(2),o.writeUInt16BE(e,0);else{const r=Buffer.byteLength(t);if(r>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+r),o.writeUInt16BE(e,0),o.write(t,2)}}this._deflating?this.enqueue([this.doClose,o,r,n]):this.doClose(o,r,n)}doClose(e,t,r){this.sendFrame(At.frame(e,{fin:!0,rsv1:!1,opcode:8,mask:t,readOnly:!1}),r)}ping(e,t,r){const n=Tt(e);if(n.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPing,n,t,Tt.readOnly,r]):this.doPing(n,t,Tt.readOnly,r)}doPing(e,t,r,n){this.sendFrame(At.frame(e,{fin:!0,rsv1:!1,opcode:9,mask:t,readOnly:r}),n)}pong(e,t,r){const n=Tt(e);if(n.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPong,n,t,Tt.readOnly,r]):this.doPong(n,t,Tt.readOnly,r)}doPong(e,t,r,n){this.sendFrame(At.frame(e,{fin:!0,rsv1:!1,opcode:10,mask:t,readOnly:r}),n)}send(e,t,r){const n=Tt(e),o=this._extensions[_t.extensionName];let i=t.binary?2:1,s=t.compress;if(this._firstFragment?(this._firstFragment=!1,s&&o&&(s=n.length>=o._threshold),this._compress=s):(s=!1,i=0),t.fin&&(this._firstFragment=!0),o){const e={fin:t.fin,rsv1:s,opcode:i,mask:t.mask,readOnly:Tt.readOnly};this._deflating?this.enqueue([this.dispatch,n,this._compress,e,r]):this.dispatch(n,this._compress,e,r)}else this.sendFrame(At.frame(n,{fin:t.fin,rsv1:!1,opcode:i,mask:t.mask,readOnly:Tt.readOnly}),r)}dispatch(e,t,r,n){if(!t)return void this.sendFrame(At.frame(e,r),n);const o=this._extensions[_t.extensionName];this._bufferedBytes+=e.length,this._deflating=!0,o.compress(e,r.fin,((t,o)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof n&&n(e);for(let t=0;t<this._queue.length;t++){const r=this._queue[t][4];"function"==typeof r&&r(e)}}else this._bufferedBytes-=e.length,this._deflating=!1,r.readOnly=!1,this.sendFrame(At.frame(o,r),n),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[1].length,Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[1].length,this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}var Ot=At;class Dt{constructor(e,t){this.target=t,this.type=e}}class Ct extends Dt{constructor(e,t){super("message",t),this.data=e}}class Nt extends Dt{constructor(e,t,r){super("close",r),this.wasClean=r._closeFrameReceived&&r._closeFrameSent,this.reason=t,this.code=e}}class jt extends Dt{constructor(e){super("open",e)}}class $t extends Dt{constructor(e,t){super("error",t),this.message=e.message,this.error=e}}const Bt={addEventListener(e,t,r){if("function"!=typeof t)return;function n(e){t.call(this,new Ct(e,this))}function o(e,r){t.call(this,new Nt(e,r,this))}function i(e){t.call(this,new $t(e,this))}function s(){t.call(this,new jt(this))}const a=r&&r.once?"once":"on";"message"===e?(n._listener=t,this[a](e,n)):"close"===e?(o._listener=t,this[a](e,o)):"error"===e?(i._listener=t,this[a](e,i)):"open"===e?(s._listener=t,this[a](e,s)):this[a](e,t)},removeEventListener(e,t){const r=this.listeners(e);for(let n=0;n<r.length;n++)r[n]!==t&&r[n]._listener!==t||this.removeListener(e,r[n])}};var Rt=Bt;const Pt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Mt(e,t,r){void 0===e[t]?e[t]=[r]:e[t].push(r)}var It={format:function(e){return Object.keys(e).map((t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map((e=>[t].concat(Object.keys(e).map((t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);if(void 0===e||""===e)return t;let r,n,o=Object.create(null),i=!1,s=!1,a=!1,c=-1,u=-1,f=0;for(;f<e.length;f++){const l=e.charCodeAt(f);if(void 0===r)if(-1===u&&1===Pt[l])-1===c&&(c=f);else if(32===l||9===l)-1===u&&-1!==c&&(u=f);else{if(59!==l&&44!==l)throw new SyntaxError(`Unexpected character at index ${f}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${f}`);-1===u&&(u=f);const n=e.slice(c,u);44===l?(Mt(t,n,o),o=Object.create(null)):r=n,c=u=-1}}else if(void 0===n)if(-1===u&&1===Pt[l])-1===c&&(c=f);else if(32===l||9===l)-1===u&&-1!==c&&(u=f);else if(59===l||44===l){if(-1===c)throw new SyntaxError(`Unexpected character at index ${f}`);-1===u&&(u=f),Mt(o,e.slice(c,u),!0),44===l&&(Mt(t,r,o),o=Object.create(null),r=void 0),c=u=-1}else{if(61!==l||-1===c||-1!==u)throw new SyntaxError(`Unexpected character at index ${f}`);n=e.slice(c,f),c=u=-1}else if(s){if(1!==Pt[l])throw new SyntaxError(`Unexpected character at index ${f}`);-1===c?c=f:i||(i=!0),s=!1}else if(a)if(1===Pt[l])-1===c&&(c=f);else if(34===l&&-1!==c)a=!1,u=f;else{if(92!==l)throw new SyntaxError(`Unexpected character at index ${f}`);s=!0}else if(34===l&&61===e.charCodeAt(f-1))a=!0;else if(-1===u&&1===Pt[l])-1===c&&(c=f);else if(-1===c||32!==l&&9!==l){if(59!==l&&44!==l)throw new SyntaxError(`Unexpected character at index ${f}`);{if(-1===c)throw new SyntaxError(`Unexpected character at index ${f}`);-1===u&&(u=f);let s=e.slice(c,u);i&&(s=s.replace(/\\/g,""),i=!1),Mt(o,n,s),44===l&&(Mt(t,r,o),o=Object.create(null),r=void 0),n=void 0,c=u=-1}}else-1===u&&(u=f)}if(-1===c||a)throw new SyntaxError("Unexpected end of input");-1===u&&(u=f);const l=e.slice(c,u);return void 0===r?Mt(t,l,o):(void 0===n?Mt(o,l,!0):Mt(o,n,i?l.replace(/\\/g,""):l),Mt(t,r,o)),t}};const Ut=w.default,Lt=b.default,Gt=_.default,Wt=S.default,qt=k.default,{randomBytes:Ft,createHash:Jt}=x.default,{URL:Ht}=m.default,Vt=et,Kt=mt,Yt=Ot,{BINARY_TYPES:zt,EMPTY_BUFFER:Xt,GUID:Qt,kStatusCode:Zt,kWebSocket:er,NOOP:tr}=je,{addEventListener:rr,removeEventListener:nr}=Rt,{format:or,parse:ir}=It,{toBuffer:sr}=Ne.exports,ar=["CONNECTING","OPEN","CLOSING","CLOSED"],cr=[8,13];class ur extends Ut{constructor(e,t,r){super(),this._binaryType=zt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage="",this._closeTimer=null,this._extensions={},this._protocol="",this._readyState=ur.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Array.isArray(t)?t=t.join(", "):"object"==typeof t&&null!==t&&(r=t,t=void 0),lr(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){zt.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get onclose(){}set onclose(e){}get onerror(){}set onerror(e){}get onopen(){}set onopen(e){}get onmessage(){}set onmessage(e){}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){const n=new Kt(this.binaryType,this._extensions,this._isServer,r);this._sender=new Yt(e,this._extensions),this._receiver=n,this._socket=e,n[er]=this,e[er]=this,n.on("conclude",vr),n.on("drain",mr),n.on("error",wr),n.on("message",_r),n.on("ping",Sr),n.on("pong",kr),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Tr),e.on("data",Er),e.on("end",Ar),e.on("error",Or),this._readyState=ur.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=ur.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[Vt.extensionName]&&this._extensions[Vt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=ur.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==ur.CLOSED){if(this.readyState===ur.CONNECTING){const e="WebSocket was closed before the connection was established";return gr(this,this._req,e)}this.readyState!==ur.CLOSING?(this._readyState=ur.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end()}}ping(e,t,r){if(this.readyState===ur.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===ur.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||Xt,t,r)):yr(this,e,r)}pong(e,t,r){if(this.readyState===ur.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===ur.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||Xt,t,r)):yr(this,e,r)}send(e,t,r){if(this.readyState===ur.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(r=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==ur.OPEN)return void yr(this,e,r);const n={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[Vt.extensionName]||(n.compress=!1),this._sender.send(e||Xt,n,r)}terminate(){if(this.readyState!==ur.CLOSED){if(this.readyState===ur.CONNECTING){const e="WebSocket was closed before the connection was established";return gr(this,this._req,e)}this._socket&&(this._readyState=ur.CLOSING,this._socket.destroy())}}}Object.defineProperty(ur,"CONNECTING",{enumerable:!0,value:ar.indexOf("CONNECTING")}),Object.defineProperty(ur.prototype,"CONNECTING",{enumerable:!0,value:ar.indexOf("CONNECTING")}),Object.defineProperty(ur,"OPEN",{enumerable:!0,value:ar.indexOf("OPEN")}),Object.defineProperty(ur.prototype,"OPEN",{enumerable:!0,value:ar.indexOf("OPEN")}),Object.defineProperty(ur,"CLOSING",{enumerable:!0,value:ar.indexOf("CLOSING")}),Object.defineProperty(ur.prototype,"CLOSING",{enumerable:!0,value:ar.indexOf("CLOSING")}),Object.defineProperty(ur,"CLOSED",{enumerable:!0,value:ar.indexOf("CLOSED")}),Object.defineProperty(ur.prototype,"CLOSED",{enumerable:!0,value:ar.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach((e=>{Object.defineProperty(ur.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(ur.prototype,`on${e}`,{enumerable:!0,get(){const t=this.listeners(e);for(let e=0;e<t.length;e++)if(t[e]._listener)return t[e]._listener},set(t){const r=this.listeners(e);for(let t=0;t<r.length;t++)r[t]._listener&&this.removeListener(e,r[t]);this.addEventListener(e,t)}})})),ur.prototype.addEventListener=rr,ur.prototype.removeEventListener=nr;var fr=ur;function lr(e,t,r,n){const o={protocolVersion:cr[1],maxPayload:104857600,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,host:void 0,path:void 0,port:void 0};if(!cr.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${cr.join(", ")})`);let i;t instanceof Ht?(i=t,e._url=t.href):(i=new Ht(t),e._url=t);const s="ws+unix:"===i.protocol;if(!(i.host||s&&i.pathname)){const t=new Error(`Invalid URL: ${e.url}`);if(0===e._redirects)throw t;return void dr(e,t)}const a="wss:"===i.protocol||"https:"===i.protocol,c=a?443:80,u=Ft(16).toString("base64"),f=a?Lt.get:Gt.get;let l;if(o.createConnection=a?hr:pr,o.defaultPort=o.defaultPort||c,o.port=i.port||c,o.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,o.headers={"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket",...o.headers},o.path=i.pathname+i.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(l=new Vt(!0!==o.perMessageDeflate?o.perMessageDeflate:{},!1,o.maxPayload),o.headers["Sec-WebSocket-Extensions"]=or({[Vt.extensionName]:l.offer()})),r&&(o.headers["Sec-WebSocket-Protocol"]=r),o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(i.username||i.password)&&(o.auth=`${i.username}:${i.password}`),s){const e=o.path.split(":");o.socketPath=e[0],o.path=e[1]}let d=e._req=f(o);o.timeout&&d.on("timeout",(()=>{gr(e,d,"Opening handshake has timed out")})),d.on("error",(t=>{null===d||d.aborted||(d=e._req=null,dr(e,t))})),d.on("response",(i=>{const s=i.headers.location,a=i.statusCode;if(s&&o.followRedirects&&a>=300&&a<400){if(++e._redirects>o.maxRedirects)return void gr(e,d,"Maximum redirects exceeded");let i;d.abort();try{i=new Ht(s,t)}catch(t){return void dr(e,t)}lr(e,i,r,n)}else e.emit("unexpected-response",d,i)||gr(e,d,`Unexpected server response: ${i.statusCode}`)})),d.on("upgrade",((t,n,i)=>{if(e.emit("upgrade",t),e.readyState!==ur.CONNECTING)return;d=e._req=null;const s=Jt("sha1").update(u+Qt).digest("base64");if(t.headers["sec-websocket-accept"]!==s)return void gr(e,n,"Invalid Sec-WebSocket-Accept header");const a=t.headers["sec-websocket-protocol"],c=(r||"").split(/, */);let f;if(!r&&a?f="Server sent a subprotocol but none was requested":r&&!a?f="Server sent no subprotocol":a&&!c.includes(a)&&(f="Server sent an invalid subprotocol"),f)return void gr(e,n,f);a&&(e._protocol=a);const p=t.headers["sec-websocket-extensions"];if(void 0!==p){if(!l){return void gr(e,n,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=ir(p)}catch(t){return void gr(e,n,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(r.length){if(1!==r.length||r[0]!==Vt.extensionName){return void gr(e,n,"Server indicated an extension that was not requested")}try{l.accept(t[Vt.extensionName])}catch(t){return void gr(e,n,"Invalid Sec-WebSocket-Extensions header")}e._extensions[Vt.extensionName]=l}}e.setSocket(n,i,o.maxPayload)}))}function dr(e,t){e._readyState=ur.CLOSING,e.emit("error",t),e.emitClose()}function pr(e){return e.path=e.socketPath,Wt.connect(e)}function hr(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=Wt.isIP(e.host)?"":e.host),qt.connect(e)}function gr(e,t,r){e._readyState=ur.CLOSING;const n=new Error(r);Error.captureStackTrace(n,gr),t.setHeader?(t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),t.once("abort",e.emitClose.bind(e)),e.emit("error",n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function yr(e,t,r){if(t){const r=sr(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(r){r(new Error(`WebSocket is not open: readyState ${e.readyState} (${ar[e.readyState]})`))}}function vr(e,t){const r=this[er];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,void 0!==r._socket[er]&&(r._socket.removeListener("data",Er),process.nextTick(xr,r._socket),1005===e?r.close():r.close(e,t))}function mr(){this[er]._socket.resume()}function wr(e){const t=this[er];void 0!==t._socket[er]&&(t._socket.removeListener("data",Er),process.nextTick(xr,t._socket),t.close(e[Zt])),t.emit("error",e)}function br(){this[er].emitClose()}function _r(e){this[er].emit("message",e)}function Sr(e){const t=this[er];t.pong(e,!t._isServer,tr),t.emit("ping",e)}function kr(e){this[er].emit("pong",e)}function xr(e){e.resume()}function Tr(){const e=this[er];let t;this.removeListener("close",Tr),this.removeListener("data",Er),this.removeListener("end",Ar),e._readyState=ur.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[er]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",br),e._receiver.on("finish",br))}function Er(e){this[er]._receiver.write(e)||this.pause()}function Ar(){const e=this[er];e._readyState=ur.CLOSING,e._receiver.end(),this.end()}function Or(){const e=this[er];this.removeListener("error",Or),this.on("error",tr),e&&(e._readyState=ur.CLOSING,this.destroy())}const{Duplex:Dr}=T.default;function Cr(e){e.emit("close")}function Nr(){!this.destroyed&&this._writableState.finished&&this.destroy()}function jr(e){this.removeListener("error",jr),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}var $r=function(e,t){let r=!0,n=!0;function o(){r&&e._socket.resume()}e.readyState===e.CONNECTING?e.once("open",(function(){e._receiver.removeAllListeners("drain"),e._receiver.on("drain",o)})):(e._receiver.removeAllListeners("drain"),e._receiver.on("drain",o));const i=new Dr({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t){i.push(t)||(r=!1,e._socket.pause())})),e.once("error",(function(e){i.destroyed||(n=!1,i.destroy(e))})),e.once("close",(function(){i.destroyed||i.push(null)})),i._destroy=function(t,r){if(e.readyState===e.CLOSED)return r(t),void process.nextTick(Cr,i);let o=!1;e.once("error",(function(e){o=!0,r(e)})),e.once("close",(function(){o||r(t),process.nextTick(Cr,i)})),n&&e.terminate()},i._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),i._readableState.endEmitted&&i.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){i._final(t)}))},i._read=function(){e.readyState!==e.OPEN&&e.readyState!==e.CLOSING||r||(r=!0,e._receiver._writableState.needDrain||e._socket.resume())},i._write=function(t,r,n){e.readyState!==e.CONNECTING?e.send(t,n):e.once("open",(function(){i._write(t,r,n)}))},i.on("end",Nr),i.on("error",jr),i};const Br=w.default,Rr=_.default,{createHash:Pr}=x.default,Mr=et,Ir=fr,{format:Ur,parse:Lr}=It,{GUID:Gr,kWebSocket:Wr}=je,qr=/^[+/0-9A-Za-z]{22}==$/;var Fr=class extends Br{constructor(e,t){if(super(),null==(e={maxPayload:104857600,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=Rr.createServer(((e,t)=>{const r=Rr.STATUS_CODES[426];t.writeHead(426,{"Content-Length":r.length,"Content-Type":"text/plain"}),t.end(r)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const r of Object.keys(t))e.on(r,t[r]);return function(){for(const r of Object.keys(t))e.removeListener(r,t[r])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,r,n)=>{this.handleUpgrade(t,r,n,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(e&&this.once("close",e),2===this._state)return void process.nextTick(Jr,this);if(1===this._state)return;if(this._state=1,this.clients)for(const e of this.clients)e.terminate();const t=this._server;t&&(this._removeListeners(),this._removeListeners=this._server=null,null!=this.options.port)?t.close(Jr.bind(void 0,this)):process.nextTick(Jr,this)}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,n){t.on("error",Hr);const o=void 0!==e.headers["sec-websocket-key"]&&e.headers["sec-websocket-key"].trim(),i=+e.headers["sec-websocket-version"],s={};if("GET"!==e.method||"websocket"!==e.headers.upgrade.toLowerCase()||!o||!qr.test(o)||8!==i&&13!==i||!this.shouldHandle(e))return Vr(t,400);if(this.options.perMessageDeflate){const r=new Mr(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const t=Lr(e.headers["sec-websocket-extensions"]);t[Mr.extensionName]&&(r.accept(t[Mr.extensionName]),s[Mr.extensionName]=r)}catch(e){return Vr(t,400)}}if(this.options.verifyClient){const a={origin:e.headers[""+(8===i?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(a,((i,a,c,u)=>{if(!i)return Vr(t,a||401,c,u);this.completeUpgrade(o,s,e,t,r,n)}));if(!this.options.verifyClient(a))return Vr(t,401)}this.completeUpgrade(o,s,e,t,r,n)}completeUpgrade(e,t,r,n,o,i){if(!n.readable||!n.writable)return n.destroy();if(n[Wr])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return Vr(n,503);const s=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Pr("sha1").update(e+Gr).digest("base64")}`],a=new Ir(null);let c=r.headers["sec-websocket-protocol"];if(c&&(c=c.split(",").map(Kr),c=this.options.handleProtocols?this.options.handleProtocols(c,r):c[0],c&&(s.push(`Sec-WebSocket-Protocol: ${c}`),a._protocol=c)),t[Mr.extensionName]){const e=t[Mr.extensionName].params,r=Ur({[Mr.extensionName]:[e]});s.push(`Sec-WebSocket-Extensions: ${r}`),a._extensions=t}this.emit("headers",s,r),n.write(s.concat("\r\n").join("\r\n")),n.removeListener("error",Hr),a.setSocket(n,o,this.options.maxPayload),this.clients&&(this.clients.add(a),a.on("close",(()=>this.clients.delete(a)))),i(a,r)}};function Jr(e){e._state=2,e.emit("close")}function Hr(){this.destroy()}function Vr(e,t,r,n){e.writable&&(r=r||Rr.STATUS_CODES[t],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...n},e.write(`HTTP/1.1 ${t} ${Rr.STATUS_CODES[t]}\r\n`+Object.keys(n).map((e=>`${e}: ${n[e]}`)).join("\r\n")+"\r\n\r\n"+r)),e.removeListener("error",Hr),e.destroy()}function Kr(e){return e.trim()}const Yr=fr;Yr.createWebSocketStream=$r,Yr.Server=Fr,Yr.Receiver=mt,Yr.Sender=Ot;var zr=Yr,Xr=N.exports;Xr.on("opt",(function(e){var t=e.opt;if(!1===t.ws||t.once)this.to.next(e);else{t.mesh=t.mesh||Xr.Mesh(e),t.WebSocket=t.WebSocket||zr;var r=t.ws=t.ws||{};r.path=r.path||"/gun",r.noServer||(r.server=r.server||t.web,r.server)?(r.web=r.web||new t.WebSocket.Server(r),r.web.on("connection",(function(e,r){var n;e.headers=e.headers||(r||"").headers||"",console.STAT&&((console.STAT.sites||(console.STAT.sites={}))[e.headers.origin]=1),t.mesh.hi(n={wire:e}),e.on("message",(function(e){t.mesh.hear(e.data||e,n)})),e.on("close",(function(){t.mesh.bye(n)})),e.on("error",(function(e){})),setTimeout((function r(){if(t.peers[n.id]){try{e.send("[]")}catch(e){}setTimeout(r,2e4)}}),2e4)})),this.to.next(e)):this.to.next(e)}}));var Qr="undefined"!=typeof window?window.Gun:N.exports;Qr.on("create",(function(e){this.to.next(e);var t=e.opt;if(!1!==t.multicast&&("undefined"==typeof process||"false"!=""+(process.env||{}).MULTICAST)){var r=t.multicast=t.multicast||{};r.address=r.address||"233.255.255.255",r.pack=r.pack||5e4,r.port=r.port||8765;var n,o=function(){},i="2"+Math.random().toString().slice(-8),s=t.mesh=t.mesh||Qr.Mesh(e);try{n=require("dgram")}catch(e){return}var a=n.createSocket({type:"udp4",reuseAddr:!0});a.bind({port:r.port,exclusive:!0},(function(){a.setBroadcast(!0),a.setMulticastTTL(128)})),a.on("listening",(function(){try{a.addMembership(r.address)}catch(e){return void console.error(e)}r.peer={id:r.address+":"+r.port,wire:a},r.peer.say=function(e){var t=Buffer.from(e,"utf8");r.pack<=t.length||a.send(t,0,t.length,r.port,r.address,o)},console.log("Multicast on",r.peer.id)})),a.on("message",(function(e,n){try{if(!e)return;return"2"===(e=e.toString("utf8"))[0]?u(e,n):void t.mesh.hear(e,r.peer)}catch(e){return}})),setInterval(u,1e3)}function c(e){this.to.next(e),r.peer&&s.say(e,r.peer)}function u(t,n){var s;if(r.peer){if(!t)return t=u.id=u.id||Buffer.from(i,"utf8"),void a.send(t,0,t.length,r.port,r.address,o);(s=e.stats)&&(s=s.gap)&&n&&((s.near||(s.near={}))[n.address]=n.port||1),u.on||t===i||e.on("out",u.on=c)}}}));var Zr="undefined"!=typeof window?window.Gun:N.exports;Zr.on("opt",(function(e){if(this.to.next(e),!e.once&&"undefined"!=typeof process&&void 0!==C&&!1!==e.opt.stats){var t=e.opt.file||"radata",r=function(){},n=A.default||{},o=y.default||{};if(o.existsSync=o.existsSync||v.default.existsSync,o.existsSync&&process){process.uptime=process.uptime||r,process.cpuUsage=process.cpuUsage||r,process.memoryUsage=process.memoryUsage||r,n.totalmem=n.totalmem||r,n.freemem=n.freemem||r,n.loadavg=n.loadavg||r,n.cpus=n.cpus||r;var i,s=+new Date;setTimeout((function(){e.stats=function(e){try{e=JSON.parse(e)}catch(t){e={}}return e}(o.existsSync(__dirname+"/../stats."+(e.opt.file||t))&&o.readFileSync(__dirname+"/../stats."+(e.opt.file||t)).toString())||{},e.stats.up=e.stats.up||{},e.stats.up.start=e.stats.up.start||+new Date,e.stats.up.count=(e.stats.up.count||0)+1,e.stats.stay=e.stats.stay||{},e.stats.over=+new Date}),1),setInterval((function(){if(e.stats||(e.stats={}),!i){var r=e.stats;r.over=-(s-(s=+new Date)),(r.up||{}).time=process.uptime(),r.memory=process.memoryUsage()||{},r.memory.totalmem=n.totalmem(),r.memory.freemem=n.freemem(),r.cpu=process.cpuUsage()||{},r.cpu.loadavg=n.loadavg(),r.cpu.stack=(((setTimeout||"").turn||"").s||"").length,r.peers={},r.peers.count=console.STAT.peers||Object.keys(e.opt.peers||{}).length,r.node={},r.node.count=Object.keys(e.graph||{}).length,r.all=tn,r.sites=console.STAT.sites,tn={};var a=e.opt.mesh;a&&(r.dam={in:{count:a.hear.c,done:a.hear.d},out:{count:a.say.c,done:a.say.d}},a.hear.c=a.hear.d=a.say.c=a.say.d=0,r.peers.time=a.bye.time||0);var c=e.opt.store;(c=c&&c.stats)&&(r.rad=c,e.opt.store.stats={get:{time:{},count:0},put:{time:{},count:0}}),JSON.stringifyAsync(r,(function(r,n){r||(i=!0,o.writeFile(__dirname+"/../stats."+(e.opt.file||t),n,(function(e){i=!1,e&&console.log(console.STAT.err=e),console.STAT&&console.STAT(s,+new Date-s,"stats stash")})))}))}}),5e3)}}})),O.default.exec;var en=Zr.log,tn={};Zr.log=console.STAT=function(e,t,r,n){"number"==typeof e&&"number"==typeof t&&"string"==typeof r&&(1e3<(tn[r]||(tn[r]=[])).push([e,t])&&(tn[r]=[]));return!console.LOG||en.off?e:en.apply(Zr,arguments)},Zr.log.once=function(e,t,r){return(r=Zr.log.once)[e]=r[e]||0,r[e]++||Zr.log(t)},function(){var e,t=N.exports;t.serve=ke,t.on("opt",(function(r){e===r.opt.super&&(r.opt.super=!0),e===r.opt.faith&&(r.opt.faith=!0),r.opt.log=r.opt.log||t.log,this.to.next(r)}));try{require("../sea")}catch(e){}try{require("../axe")}catch(e){}ve.exports=t}();var rn=ve.exports;let nn=async(e,t=()=>{})=>{if(await M.user().get("certificates").get(e).get("addFriend").once())return;let r=await rn.SEA.certify([e],[{"*":"friends"}],await M.user().pair(),null);M.user().get("certificates").get(e).get("addFriend").put(r,(({err:e})=>t(e?{errMessage:e,errCode:"gun-put-error",success:void 0}:{errMessage:void 0,errCode:void 0,certificate:r,success:"Generated certificate for requested friend to add user back."})))};var on=Object.freeze({__proto__:null,generateAddFriendCertificate:nn,generateFriendRequestsCertificate:async(e=()=>{})=>{if(await M.user().get("certificates").get("friendRequests").once())return;let t=await rn.SEA.certify(["*"],[{"*":"friendRequests"}],await M.user().pair(),null);M.user().get("certificates").get("friendRequests").put(t,(({err:r})=>e(r?{errMessage:r,errCode:"gun-put-error",success:void 0}:{errMessage:void 0,errCode:void 0,certificate:t,success:"Generated new friend requests certificate."})))},createChatsCertificate:async(e,t=()=>{})=>{if(await M.user().get("certificates").get(e).get("chats").once())return;let r=await rn.SEA.certify([e],[{"*":"chats"}],await M.user().pair(),null);M.user().get("certificates").get(e).get("chats").put(r,(({err:e})=>t(e?{errMessage:e,errCode:"chats-certificate-creation-error",success:void 0}:{errMessage:void 0,errCode:void 0,certificate:r,success:"Generated new chats certificate."})))},createMessagesCertificate:async(e,t=()=>{})=>{if(await M.user().get("certificates").get(e).get("messages").once())return;let r=await rn.SEA.certify([e],[{"*":"messages"}],await M.user().pair(),null);M.user().get("certificates").get(e).get("messages").put(r,(({err:e})=>t(e?{errMessage:e,errCode:"messages-certificate-creation-error",success:void 0}:{errMessage:void 0,errCode:void 0,certificate:r,success:"Generated new messages certificate."})))}});let sn=new fe((e=>{M.user().get("friendRequests").map(((t,r)=>{t?M.user(t).once((t=>{t&&t.info&&t.pub&&t.alias?M.get(t.info["#"]).on((n=>{e.next({key:r,pub:t.pub,alias:t.alias,displayName:n.displayName,about:n.about||void 0})})):t&&t.pub&&t.alias&&e.next({key:r,pub:t.pub,alias:t.alias})})):e.next(void 0)}))})),an=new fe((e=>{M.user().get("friends").map(((t,r)=>{t?M.user(t).once((t=>{t&&t.info&&t.pub&&t.alias?M.get(t.info["#"]).on((n=>{e.next({key:r,pub:t.pub,alias:t.alias,displayName:n.displayName,about:n.about||void 0})})):t&&t.pub&&t.alias&&e.next({key:r,pub:t.pub,alias:t.alias})})):e.next(void 0)}))}));var cn=Object.freeze({__proto__:null,addFriendRequest:async(e,t=()=>{})=>{let r=await M.user(e).get("certificates").get("friendRequests");M.user(e).get("friendRequests").set(I.is.pub,(({err:r})=>{if(r)return t({errMessage:r,errCode:"friend-request-error",success:void 0});nn(e,(({errMessage:e,errCode:r,success:n})=>t(e?{errMessage:e,errCode:r,success:n}:{errMessage:void 0,errCode:void 0,success:"Friend request sent successfully."})))}),{opt:{cert:r}})},acceptFriendRequest:({key:e,publicKey:t},r=()=>{})=>{M.user().get("friendRequests").get(e).put(null,(async({err:e})=>{if(e)return r({errMessage:e,errCode:"accept-friend-request-failed",success:void 0});{let e=await M.user(t).get("certificates").get(I.is.pub).get("addFriend");M.user(t).get("friends").set(I.is.pub,(({err:e})=>{if(e)return r({errMessage:e,errCode:"add-friend-failed",success:void 0});M.user().get("friends").set(t,(({err:e})=>r(e?{errMessage:e,errCode:"add-friend-failed",success:void 0}:{errMessage:void 0,errCode:void 0,success:"Added friend successfully."})))}),{opt:{cert:e}})}}))},rejectFriendRequest:(e,t=()=>{})=>{M.user().get("friendRequests").get(e).put(null,(async({err:e})=>t(e?{errMessage:e,errCode:"reject-friend-request-failed",success:void 0}:{errMessage:void 0,errCode:void 0,success:"Friend request removed successfully."})))},friendRequests:sn,friendsList:an});let un=new fe((e=>{M.user().get("chats").on(((t,r)=>{for(let r in t)try{let n=JSON.parse(t[r]);n&&e.next({roomId:n.roomId,pub:n.pub,latestMessage:n.latestMessage})}catch(e){}}))}));var fn,ln=new Uint8Array(16);function dn(){if(!fn&&!(fn="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return fn(ln)}var pn=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var hn=[],gn=0;gn<256;++gn)hn.push((gn+256).toString(16).substr(1));function yn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(hn[e[t+0]]+hn[e[t+1]]+hn[e[t+2]]+hn[e[t+3]]+"-"+hn[e[t+4]]+hn[e[t+5]]+"-"+hn[e[t+6]]+hn[e[t+7]]+"-"+hn[e[t+8]]+hn[e[t+9]]+"-"+hn[e[t+10]]+hn[e[t+11]]+hn[e[t+12]]+hn[e[t+13]]+hn[e[t+14]]+hn[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&pn.test(e)}(r))throw TypeError("Stringified UUID is invalid");return r}function vn(e,t,r){var n=(e=e||{}).random||(e.rng||dn)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var o=0;o<16;++o)t[r+o]=n[o];return t}return yn(n)}var mn=Object.freeze({__proto__:null,createChat:async(e,t=()=>{})=>{M.user().get("chats").get(e).once((async r=>{if(r)return t({errMessage:"The chat already exists. Opening it now.",errCode:"chat-already-exists",chat:JSON.parse(r),success:void 0});let n=await M.user(e).once(),o=await M.user().pair().pub;if(!o)return t({errMessage:"Could not find pub.",errCode:"failed-to-find-pub",success:void 0});if(!n)return t({errMessage:"Could not find friend.",errCode:"failed-to-find-friend",success:void 0});let i=await M.user(e).get("certificates").get(o).get("chats");if(!i)return t({errMessage:"Could not find friend certificate to create chat",errCode:"failed-to-find-friend-chats-certificate",success:void 0});let s=vn();M.user(e).get("chats").get(o).put(JSON.stringify({pub:o,roomId:s,latestMessage:{}}),(({err:r})=>{if(r)return t({errMessage:r,errCode:"chat-creation-error",success:void 0});M.user().get("chats").get(e).put(JSON.stringify({pub:n.pub,roomId:s,latestMessage:{}}),(({err:e})=>t(e?{errMessage:e,errCode:"chat-creation-error",success:void 0}:{errMessage:void 0,errCode:void 0,chat:{pub:n.pub,roomId:s},success:"Created a chat with friend."})))}),{opt:{cert:i}})}))},chatsList:un,messageList:(e,t)=>new fe((async r=>{let n=await M.user()._.sea,o=await M.user(t);M.user().get("messages").get(e).once((t=>{(async()=>{let i=[];for(let e in t){let r=t[e].toString(),s=await SEA.secret(o.epub,n),a=await SEA.decrypt(r,s);if(a){let e={...a,encrypted:!0},t=void 0!==i.filter((t=>t.id===e.id))[0];console.log(t),t||i.push(e)}}r.next({initial:i,individual:void 0}),M.user().get("messages").get(e).map().once((async e=>{if(e.toString().startsWith("SEA")){let t=await SEA.secret(o.epub,n),s=await SEA.decrypt(e,t);if(s){let e={...s,encrypted:!0};if(!(void 0!==i.filter((t=>t.id===e.id))[0]))return r.next({initial:void 0,individual:e})}}}))})()}))})),sendMessage:(e,t,r,n=()=>{})=>{(async(n=()=>{})=>{let o=await M.user().pair().pub,i=await M.user()._.sea,s=await M.user(t);if(!o)return n({errMessage:"Impossibile trovare la chiave pubblica.",errCode:"failed-to-find-pub",success:void 0});let a=await M.user(t).get("certificates").get(o).get("messages");if(!a)return n({errMessage:"Impossibile trovare il certificato dell'amico per creare il messaggio",errCode:"failed-to-find-friend-messages-certificate",success:void 0});let c=await M.user(t).get("certificates").get(o).get("chats");if(!c)return n({errMessage:"Impossibile trovare il certificato dell'amico per aggiungere metadati alla chat",errCode:"failed-to-find-friend-chats-certificate",success:void 0});let u=vn(),f=Date.now(),l=await rn.SEA.secret(s.epub,i),d=await rn.SEA.encrypt(JSON.stringify({id:u,content:r,timeSent:f,sender:o,type:"text"}),l);M.user().get("chats").get(e).get("latestMessage").put(d),M.user(t).get("chats").get(e).get("latestMessage").put(d,null,{opt:{cert:c}}),M.user().get("messages").get(e).set(d,(({err:r})=>{if(r)return n({errMessage:r,errCode:"message-creation-error",success:void 0});M.user(t).get("messages").get(e).set(d,(({err:e})=>n(e?{errMessage:e,errCode:"message-creation-error",success:void 0}:{errMessage:void 0,errCode:void 0,success:"Messaggio creato con successo con l'amico."})),{opt:{cert:a}})}))})(n)},sendVoiceMessage:(e,t,r,n=()=>{})=>{(async(n=()=>{})=>{let o=await M.user().pair().pub;if(await M.user()._.sea,await M.user(t),!o)return n({errMessage:"Could not find pub.",errCode:"failed-to-find-pub",success:void 0});let i=await M.user(t).get("certificates").get(o).get("messages");if(!i)return n({errMessage:"Could not find friend certificate to create message",errCode:"failed-to-find-friend-messages-certificate",success:void 0});let s=await M.user(t).get("certificates").get(o).get("chats");if(!s)return n({errMessage:"Could not find friend certificate to add meta to chat",errCode:"failed-to-find-friend-chats-certificate",success:void 0});M.user().get("chats").get(e).get("latestMessage").put(r),M.user(t).get("chats").get(e).get("latestMessage").put(r,null,{opt:{cert:s}}),M.user().get("messages").get(e).set(r,(({err:o})=>{if(o)return n({errMessage:o,errCode:"message-creation-error",success:void 0});M.user(t).get("messages").get(e).set(r,(({err:e})=>n(e?{errMessage:e,errCode:"message-creation-error",success:void 0}:{errMessage:void 0,errCode:void 0,success:"Created a voice message with friend."})),{opt:{cert:i}})}))})(n)}});let wn="",bn="";async function _n(){if(wn&&bn){const e=new h.ethers.JsonRpcProvider(wn);return new h.ethers.Wallet(bn,e)}if("undefined"!=typeof window&&void 0!==window.ethereum){await window.ethereum.request({method:"eth_requestAccounts"});return new h.ethers.BrowserProvider(window.ethereum).getSigner()}throw new Error("No valid Ethereum provider found")}async function Sn(e){const t=await async function(){if(wn&&bn)return new h.ethers.JsonRpcProvider(wn);if("undefined"!=typeof window&&void 0!==window.ethereum)return new h.ethers.BrowserProvider(window.ethereum);throw new Error("No valid Ethereum provider found")}();try{const r=await t.lookupAddress(e);return r?(console.log(`The ENS name for address ${e} is: ${r}`),r):(console.log(`No ENS name found for address ${e}`),null)}catch(e){return console.error("Error while looking up ENS name:",e),null}}rn.chain.GunEth=function(e,t,r){return console.log("gunEth called"),console.log("gun in gunEth:",e),{shine:(t,r,n,o)=>rn.chain.shine.call(e,t,r,n,o),setStandaloneConfig:(e,t)=>(console.log("setStandaloneConfig called with:",e,t),function(e,t){wn=e,bn=t}(e,t),console.log("Standalone configuration set"),this.gun),verifySignature:async(e,t)=>{try{return r.verifyMessage(e,t)}catch(e){return console.error("Error verifying signature:",e),null}},generatePassword:e=>{try{const t=r.hexlify(e),n=r.keccak256(t);return console.log("Generated password:",n),n}catch(e){return console.error("Error generating password:",e),null}},createSignature:async()=>{try{const e=await _n(),t=await e.signMessage("GunDB access with Ethereum");return console.log("Signature created:",t),t}catch(e){return console.error("Error creating signature:",e),null}},createAndStoreEncryptedPair:async(r,n)=>{try{const o=await I._.sea,i=await t.encrypt(JSON.stringify(o),n);let s;try{const e=await Sn(r);s=e||r}catch(e){console.error("Error getting ENS name:",e),s=r}const a={pub:i.pub,address:r,ensName:s};await e.get("gun-eth").get("users").get(r).put({encryptedPair:i}),await e.get("gun-eth").get("usersData").get(i.pub).put({data:a}),await e.get(`~${i.pub}`).get("safe").get("enc").put({encryptedPair:i}),console.log("Encrypted pair stored for:",r)}catch(e){console.error("Error creating and storing encrypted pair:",e)}},getAndDecryptPair:async(r,n)=>{try{const o=await e.get("gun-eth").get("users").get(r).get("encryptedPair").then();if(!o)throw new Error("No encrypted data found for this address");const i=await t.decrypt(o,n);return console.log(i),i}catch(e){return console.error("Error retrieving and decrypting pair:",e),null}},gunToEthAccount:e=>{const t="0x"+(e=>{const t="=".repeat((4-e.length%4)%4),r=e.replace(/-/g,"+").replace(/_/g,"/")+t,n=atob(r);return Array.from(n,(e=>e.charCodeAt(0).toString(16).padStart(2,"0"))).join("")})(e),n=new r.Wallet(t);return{account:n,publicKey:n.address}}}};"undefined"!=typeof window&&(window.Gun=M,window.GunEthProtocol={authentication:ye,certificates:on,friends:cn,messaging:mn,gun:M,user:I},window.User=I),e.authentication=ye,e.certificates=on,e.friends=cn,e.gun=M,e.messaging=mn,e.user=I,Object.defineProperty(e,"__esModule",{value:!0})}));
package/jsdoc.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "plugins": ["node_modules/tsd-jsdoc/dist/plugin"],
3
+ "opts": {
4
+ "destination": "types",
5
+ "module": true
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,33 +1,36 @@
1
1
  {
2
2
  "name": "gun-eth",
3
- "version": "1.3.6",
3
+ "version": "2.0.0",
4
4
  "description": "A GunDB plugin for Ethereum, and Web3",
5
- "main": "./src/index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
5
+ "source": "src/index.js",
6
+ "main": "dist/gun-eth-protocol.cjs.js",
7
+ "module": "dist/gun-eth-protocol.esm.js",
8
+ "browser": "dist/gun-eth-protocol.umd.js",
9
+ "react": "dist/gun-eth-protocol.react.js",
10
+ "license": "GPL-3.0",
11
+ "private": false,
9
12
  "dependencies": {
10
- "ethers": "^6.0.0",
11
- "gun": "^0.2020.1239"
13
+ "axios": "^0.24.0",
14
+ "gun": "^0.2020.1235",
15
+ "gun-avatar": "^1.3.5",
16
+ "hyperswarm-web": "^2.1.1",
17
+ "rxjs": "^7.4.0",
18
+ "slugid": "^3.0.0",
19
+ "sodium-universal": "^3.0.4",
20
+ "uuid": "^8.3.2"
12
21
  },
13
- "author": "scobru",
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/scobru/gun-eth.git"
22
+ "devDependencies": {
23
+ "@rollup/plugin-commonjs": "^21.0.1",
24
+ "@rollup/plugin-node-resolve": "^15.3.0",
25
+ "jsdoc": "^4.0.4",
26
+ "rollup": "^2.66.1",
27
+ "rollup-plugin-terser": "^7.0.2",
28
+ "tsd-jsdoc": "^2.5.0"
17
29
  },
18
- "license": "MIT",
19
- "keywords": [
20
- "gundb",
21
- "web3",
22
- "evm",
23
- "ethereum",
24
- "decentralized",
25
- "storage",
26
- "gun",
27
- "db"
28
- ],
29
- "bugs": {
30
- "url": "https://github.com/scobru/gun-eth/issues"
30
+ "scripts": {
31
+ "test": "echo \"Error: no test specified\" && exit 1",
32
+ "build": "rollup -c",
33
+ "generate-types": "jsdoc -t node_modules/tsd-jsdoc/dist -r ./src -d types"
31
34
  },
32
- "homepage": "https://github.com/scobru/gun-eth#readme"
35
+ "author": ""
33
36
  }
@@ -0,0 +1,80 @@
1
+ import resolve from '@rollup/plugin-node-resolve';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+ import { terser } from 'rollup-plugin-terser';
4
+ import pkg from './package.json';
5
+
6
+ export default [
7
+ // UMD build
8
+ {
9
+ input: 'src/index.js',
10
+ output: {
11
+ file: pkg.browser,
12
+ format: 'umd',
13
+ name: 'gun-ethProtocol'
14
+ },
15
+ types: 'types/index.d.ts',
16
+ plugins: [
17
+ resolve(),
18
+ commonjs(),
19
+ terser()
20
+ ]
21
+ },
22
+
23
+ // ESM build
24
+ {
25
+ input: 'src/index.js',
26
+ output: {
27
+ file: pkg.module,
28
+ format: 'es'
29
+ },
30
+ plugins: [
31
+ resolve(),
32
+ commonjs()
33
+ ]
34
+ },
35
+
36
+ // CommonJS build
37
+ {
38
+ input: 'src/index.js',
39
+ output: {
40
+ file: pkg.main,
41
+ format: 'cjs'
42
+ },
43
+ plugins: [
44
+ resolve(),
45
+ commonjs()
46
+ ]
47
+ },
48
+
49
+ // React-optimized build
50
+ {
51
+ input: 'src/index.js',
52
+ output: {
53
+ file: 'dist/gun-eth-protocol.react.js',
54
+ format: 'es'
55
+ },
56
+ external: ['react', 'react-dom'],
57
+ plugins: [
58
+ resolve(),
59
+ commonjs()
60
+ ]
61
+ },
62
+
63
+ // Bundle completo
64
+ {
65
+ input: 'src/index.js',
66
+ output: {
67
+ file: 'dist/gun-eth-protocol.js',
68
+ format: 'iife',
69
+ name: 'GunEthProtocol'
70
+ },
71
+ plugins: [
72
+ resolve({
73
+ browser: true,
74
+ preferBuiltins: false
75
+ }),
76
+ commonjs(),
77
+ terser()
78
+ ]
79
+ }
80
+ ];