holosphere
Version:
Holonic Geospatial Communication Infrastructure
2 lines • 501 kB
JavaScript
/* HoloSphere Bundle v1.1.20 - Holonic Geospatial Communication Infrastructure */
var HoloSphere=(()=>{var f1=Object.create;var As=Object.defineProperty;var c1=Object.getOwnPropertyDescriptor;var d1=Object.getOwnPropertyNames;var h1=Object.getPrototypeOf,p1=Object.prototype.hasOwnProperty;var zf=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var pe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),m1=(n,e)=>{for(var i in e)As(n,i,{get:e[i],enumerable:!0})},Jf=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of d1(e))!p1.call(n,u)&&u!==i&&As(n,u,{get:()=>e[u],enumerable:!(s=c1(e,u))||s.enumerable});return n};var Ka=(n,e,i)=>(i=n!=null?f1(h1(n)):{},Jf(e||!n||!n.__esModule?As(i,"default",{value:n,enumerable:!0}):i,n)),g1=n=>Jf(As({},"__esModule",{value:!0}),n);var Lc=pe((eC,j0)=>{(function(){function n(i,s){return s?zf(i):i.slice?n[u(i)]:function(d,m){i(d={exports:{}}),n[u(m)]=d.exports};function u(d){return d.split("/").slice(-1).toString().replace(".js","")}}if(typeof j0<"u")var e=j0;n(function(i){String.random=function(u,d){var m="";for(u=u||24,d=d||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";u-- >0;)m+=d.charAt(Math.floor(Math.random()*d.length));return m},String.match=function(u,d){var m,y;return typeof u!="string"?!1:(typeof d=="string"&&(d={"=":d}),d=d||{},m=d["="]||d["*"]||d[">"]||d["<"],u===m?!0:y!==d["="]?!1:(m=d["*"]||d[">"],u.slice(0,(m||"").length)===m?!0:y!==d["*"]?!1:y!==d[">"]&&y!==d["<"]?u>=d[">"]&&u<=d["<"]:y!==d[">"]&&u>=d[">"]||y!==d["<"]&&u<=d["<"]))},String.hash=function(u,d){if(typeof u=="string"){if(d=d||0,!u.length)return d;for(var m=0,y=u.length,E;m<y;++m)E=u.charCodeAt(m),d=(d<<5)-d+E,d|=0;return d}};var s=Object.prototype.hasOwnProperty;Object.plain=function(u){return u?u instanceof Object&&u.constructor===Object||Object.prototype.toString.call(u).match(/^\[object (\w+)\]$/)[1]==="Object":!1},Object.empty=function(u,d){for(var m in u)if(s.call(u,m)&&(!d||d.indexOf(m)==-1))return!1;return!0},Object.keys=Object.keys||function(u){var d=[];for(var m in u)s.call(u,m)&&d.push(m);return d},function(){var u,d=setTimeout,m=0,y=0,E=typeof setImmediate!=""+u&&setImmediate||function(w,v){return typeof MessageChannel==""+u?d:((w=new MessageChannel).port1.onmessage=function($){$.data==""&&v()},function($){v=$,w.port2.postMessage("")})}(),b=d.check=d.check||typeof performance!=""+u&&performance||{now:function(){return+new Date}};d.hold=d.hold||9,d.poll=d.poll||function(w){if(d.hold>=b.now()-m&&y++<3333){w();return}E(function(){m=b.now(),w()},y=0)}}(),function(){var u=setTimeout,d=u.turn=u.turn||function(v){m.push(v)==1&&y(w)},m=d.s=[],y=u.poll,E=0,b,w=function(){(b=m[E++])&&b(),(E==m.length||E==99)&&(m=d.s=m.slice(E),E=0),m.length&&y(w)}}(),function(){var u,d=setTimeout,m=d.turn;(d.each=d.each||function(y,E,b,w){w=w||9,function v($,S,x){if(S=($=(y||[]).splice(0,w)).length){for(var k=0;k<S&&u===(x=E($[k]));k++);if(u===x){m(v);return}}b&&b(x)}()})()}()})(n,"./shim"),n(function(i){i.exports=function s(b,d,m){if(!b)return{to:s};var y,E=typeof d=="function",b=(this.tag||(this.tag={}))[b]||E&&(this.tag[b]={tag:b,to:s._={next:function(v){var $;($=this.to)&&$.next(v)}}});if(E){var w={off:s.off||(s.off=function(){if(this.next===s._.next)return!0;this===this.the.last&&(this.the.last=this.back),this.to.back=this.back,this.next=s._.next,this.back.to=this.to,this.the.last===this.the&&delete this.on.tag[this.the.tag]}),to:s._,next:d,the:b,on:this,as:m};return(w.back=b.last||b).to=w,b.last=w}return(b=b.to)&&y!==d&&b.next(d),b}})(n,"./onto"),n(function(i){i.exports=function(s){return s===null||typeof s=="string"||typeof s=="boolean"||typeof s=="number"&&s!=1/0&&s!=-1/0&&s===s||!!s&&typeof s["#"]=="string"&&Object.keys(s).length===1&&s["#"]}})(n,"./valid"),n(function(i){n("./shim");function s(){var b=+new Date;return y<b?(d=0,y=b+s.drift):y=b+(d+=1)/m+s.drift}s.drift=0;var u=-1/0,d=0,m=999,y=u,E;s.is=function(b,w,v){var $=w&&b&&b._&&b._[">"]||v;if($)return typeof($=$[w])=="number"?$:u},s.ify=function(b,w,v,$,S){(b=b||{})._=b._||{},S&&(b._["#"]=S);var x=b._[">"]||(b._[">"]={});return E!==w&&w!=="_"&&(typeof v=="number"&&(x[w]=v),E!==$&&(b[w]=$)),b},i.exports=s})(n,"./state"),n(function(i){n("./shim");function s(u){var d={s:{}},m=d.s;u=u||{max:999,age:1e3*9},d.check=function(E){return m[E]?y(E):!1};var y=d.track=function(E){var b=m[E]||(m[E]={});return b.was=d.now=+new Date,d.to||(d.to=setTimeout(d.drop,u.age+9)),y.ed&&y.ed(E),b};return d.drop=function(E){d.to=null,d.now=+new Date;var b=Object.keys(m);console.STAT&&console.STAT(d.now,+new Date-d.now,"dup drop keys"),setTimeout.each(b,function(w){var v=m[w];v&&(E||u.age)>d.now-v.was||delete m[w]},0,99)},d}i.exports=s})(n,"./dup"),n(function(i){n("./onto"),i.exports=function(d,m){if(this.on){var y=(this.opt||{}).lack||9e3;if(typeof d!="function"){if(!d)return;var b=d["#"]||d,E=(this.tag||"")[b];return E?(m&&(E=this.on(b,m),clearTimeout(E.err),E.err=setTimeout(function(){E.off()},y)),!0):void 0}var b=m&&m["#"]||s(9);if(!d)return b;var w=this.on(b,d,m);return w.err=w.err||setTimeout(function(){w.off(),w.next({err:"Error: No ACK yet.",lack:!0})},y),b}};var s=String.random||function(){return Math.random().toString(36).slice(2)}})(n,"./ask"),n(function(i){function s(S){return S instanceof s?(this._={$:this}).$:this instanceof s?s.create(this._={$:this,opt:S}):new s(S)}s.is=function(S){return S instanceof s||S&&S._&&S===S._.$||!1},s.version=.202,s.chain=s.prototype,s.chain.toJSON=function(){},n("./shim"),s.valid=n("./valid"),s.state=n("./state"),s.on=n("./onto"),s.dup=n("./dup"),s.ask=n("./ask"),function(){s.create=function(R){R.root=R.root||R,R.graph=R.graph||{},R.on=R.on||s.on,R.ask=R.ask||s.ask,R.dup=R.dup||s.dup();var B=R.$.opt(R.opt);return R.once||(R.on("in",S,R),R.on("out",S,R),R.on("put",M,R),s.on("create",R),R.on("create",R)),R.once=1,B};function S(R){if(R){if(R.out===S){this.to.next(R);return}var B=this,Q=B.as,X=Q.at||Q,ne=X.$,Ae=X.dup,te,de=R.DBG;if((te=R["#"])||(te=R["#"]=d(9)),!Ae.check(te)){if(Ae.track(te),te=R._,R._=typeof te=="function"?te:function(){},R.$&&R.$===(R.$._||"").$||(R.$=ne),R["@"]&&!R.put&&I(R),!X.ask(R["@"],R))if(de&&(de.u=+new Date),R.put){x(R);return}else R.get&&s.on.get(R,ne);de&&(de.uc=+new Date),B.to.next(R),de&&(de.ua=+new Date),!(R.nts||R.NTS)&&(R.out=S,X.on("out",R),de&&(de.ue=+new Date))}}}function x(R){if(R){var B=R._||"",Q=B.root=((B.$=R.$||"")._||"").root;if(R["@"]&&B.faith&&!B.miss){R.out=S,Q.on("out",R);return}B.latch=Q.hatch,B.match=Q.hatch=[];var X=R.put,ne=B.DBG=R.DBG,Ae=+new Date;if(le=le||Ae,!(X["#"]&&X["."])){ne&&(ne.p=Ae),B["#"]=R["#"],B.msg=R,B.all=0,B.stun=1;var te=Object.keys(X);console.STAT&&console.STAT(Ae,((ne||B).pk=+new Date)-Ae,"put sort");var de=0,me,ve,De,At,Ke,ze,gt;(function JA(CA){if(me!=de){if(me=de,!(De=te[de])){console.STAT&&console.STAT(Ae,((ne||B).pd=+new Date)-Ae,"put"),O(B);return}(At=X[De])?(gt=At._)?De!==gt["#"]?ze=U+V(De)+"soul not same.":(Ke=gt[">"])||(ze=U+V(De)+"no state."):ze=U+V(De)+"no meta.":ze=U+V(De)+"no node.",ve=Object.keys(At||{})}if(ze){R.err=B.err=ze,O(B);return}var sA=0,aA;for(CA=CA||0;CA++<9&&(aA=ve[sA++]);)if(aA!=="_"){var SA=At[aA],DA=Ke[aA];if(w===DA){ze=U+V(aA)+"on"+V(De)+"no state.";break}if(!y(SA)){ze=U+V(aA)+"on"+V(De)+"bad "+typeof SA+V(SA);break}k(SA,aA,De,DA,R),++J}if((ve=ve.slice(sA)).length){m(JA);return}++de,ve=null,JA(CA)})()}}}s.on.put=x;function k(R,B,Q,X,ne){var Ae=ne._||"",te=Ae.root,de=te.graph,me,ve,De=de[Q]||v,At=E(De,B,1),Ke=De[B],ze=Ae.DBG;(ve=console.STAT)&&(!de[Q]||!Ke)&&(ve.has=(ve.has||0)+1);var gt=L(),JA;if(X>gt){setTimeout(function(){k(R,B,Q,X,ne)},(ve=X-gt)>re?re:ve),console.STAT&&console.STAT((ze||Ae).Hf=+new Date,ve,"future");return}if(!(X<At)&&!(!Ae.faith&&X===At&&(R===Ke||z(R)<=z(Ke))&&!Ae.miss)){Ae.stun++;var CA=ne["#"]+Ae.all++,sA={toString:function(){return CA},_:Ae};sA.toJSON=sA.toString,te.dup.track(sA)["#"]=ne["#"],ze&&(ze.ph=ze.ph||+new Date),te.on("put",{"#":sA,"@":ne["@"],put:{"#":Q,".":B,":":R,">":X},ok:ne.ok,_:Ae})}}function M(R){var B;(B=(R._||"").DBG)&&(B.pa=+new Date,B.pm=B.pm||+new Date);var Q=this,X=Q.as,ne=X.graph,Ae=R._,te=R.put,de=te["#"],me=te["."],ve=te[":"],De=te[">"],At=R["#"],Ke;(Ke=Ae.msg)&&(Ke=Ke.put)&&(Ke=Ke[de])&&b(Ke,me,De,ve,de),ne[de]=b(ne[de],me,De,ve,de),(Ke=(X.next||"")[de])&&Ke.on("in",R),O(Ae),Q.to.next(R)}function O(R,B){var Q;if(!R.stop&&!(!R.err&&0<--R.stun)&&(R.stop=1,!!(Q=R.root))){var X=R.match;X.end=1,X===Q.hatch&&(!(X=R.latch)||X.end?delete Q.hatch:Q.hatch=X),R.hatch&&R.hatch(),setTimeout.each(R.match,function(ne){ne&&ne()}),!(!(B=R.msg)||R.err||B.err)&&(B.out=S,R.root.on("out",B),ae())}}function I(R){var B=R["@"]||"",Q,X,ne;if(!(Q=B._)){var Ae=(Ae=R.$)&&(Ae=Ae._)&&(Ae=Ae.root)&&(Ae=Ae.dup);if(!(Ae=Ae.check(B)))return;R["@"]=Ae["#"]||R["@"];return}Q.acks=(Q.acks||0)+1,(Q.err=R.err)&&(R["@"]=Q["#"],O(Q)),Q.ok=R.ok||Q.ok,!Q.stop&&!Q.crack&&(Q.crack=Q.match&&Q.match.push(function(){q(Q)})),q(Q)}function q(R){!R||!R.root||R.stun||R.acks!==R.all||R.root.on("in",{"@":R["#"],err:R.err,ok:R.err?w:R.ok||{"":1}})}var U="Error: Invalid graph!",V=function(R){return" '"+(""+R).slice(0,9)+"...' "},z=JSON.stringify,re=2147483647,L=s.state,J=0,le,ae=function(){J>999&&J/-(le-(le=+new Date))>1&&(s.window&&console.log("Warning: You're syncing 1K+ records a second, faster than DOM can update - consider limiting query."),ae=function(){J=0})}}(),function(){s.on.get=function(x,k){var M=k._,O=x.get,I=O["#"],q=M.graph[I],U=O["."],V=M.next||(M.next={}),z=V[I],re=x._||{},L=re.DBG=x.DBG;if(L&&(L.g=+new Date),!q)return M.on("get",x);if(U){if((typeof U!="string"||w===q[U])&&!((z||"").next||"")[U]){M.on("get",x);return}q=b({},U,E(q,U),q[U],I)}q&&S(x,q),M.on("get",x)};function S(x,k){var M=+new Date,O=x._||{},I=O.DBG=x.DBG,q=x["#"],U=d(9),V=Object.keys(k||"").sort(),z=((k||"")._||"")["#"],re=V.length,L=0,J=x.$._.root,le=k===J.graph[z];console.STAT&&console.STAT(M,((I||O).gk=+new Date)-M,"got keys"),k&&function ae(){M=+new Date;for(var R=0,B,Q={},X;R<9&&(B=V[R++]);)b(Q,B,E(k,B),k[B],z);V=V.slice(R),(X={})[z]=Q,Q=X;var ne;le&&(ne=function(){},ne.ram=ne.faith=!0),X=V.length,console.STAT&&console.STAT(M,-(M-(M=+new Date)),"got copied some"),I&&(I.ga=+new Date),J.on("in",{"@":q,"#":U,put:Q,"%":X?U=d(9):w,$:J.$,_:ne,DBG:I,FOO:1}),console.STAT&&console.STAT(M,+new Date-M,"got in"),X&&setTimeout.turn(ae)}(),k||J.on("in",{"@":x["#"]})}s.on.get.ack=S}(),function(){s.chain.opt=function(S){S=S||{};var x=this,k=x._,M=S.peers||S;return Object.plain(S)||(S={}),Object.plain(k.opt)||(k.opt=S),typeof M=="string"&&(M=[M]),Object.plain(k.opt.peers)||(k.opt.peers={}),M instanceof Array&&(S.peers={},M.forEach(function(O){var I={};I.id=I.url=O,S.peers[O]=k.opt.peers[O]=k.opt.peers[O]||I})),u(S,function O(I){var q=this[I];if(this&&this.hasOwnProperty(I)||typeof q=="string"||Object.empty(q)){this[I]=q;return}q&&q.constructor!==Object&&!(q instanceof Array)||u(q,O)}),k.opt.from=S,s.on("opt",k),k.opt.uuid=k.opt.uuid||function(I){return s.state().toString(36).replace(".","")+String.random(I||12)},x}}();var u=function(S,x){Object.keys(S).forEach(x,S)},d=String.random,m=setTimeout.turn,y=s.valid,E=s.state.is,b=s.state.ify,w,v={},$;s.log=function(){return!s.log.off&&$.log.apply($,arguments),[].slice.call(arguments).join(" ")},s.log.once=function(S,x,k){return(k=s.log.once)[S]=k[S]||0,k[S]++||s.log(x)},typeof window<"u"&&((window.GUN=window.Gun=s).window=window);try{typeof e<"u"&&(e.exports=s)}catch{}i.exports=s,(s.window||{}).console=(s.window||{}).console||{log:function(){}},($=console).only=function(S,x){return $.only.i&&S===$.only.i&&$.only.i++&&($.log.apply($,arguments)||x)},s.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!")})(n,"./root"),n(function(i){var s=n("./root");s.chain.back=function(m,y){var E;if(m=m||1,m===-1||m===1/0)return this._.root.$;if(m===1)return(this._.back||this._).$;var b=this,w=b._;if(typeof m=="string"&&(m=m.split(".")),m instanceof Array){var v=0,$=m.length,E=w;for(v;v<$;v++)E=(E||u)[m[v]];return d!==E?y?b:E:(E=w.back)?E.$.back(m,y):void 0}if(typeof m=="function"){for(var S,E={back:w};(E=E.back)&&d===(S=m(E,y)););return S}return typeof m=="number"?(w.back||w).$.back(m-1):this};var u={},d})(n,"./back"),n(function(i){var s=n("./root");s.chain.chain=function(O){var I=this,q=I._,U=new(O||I).constructor(I),V=U._,z;return V.root=z=q.root,V.id=++z.once,V.back=I._,V.on=s.on,V.on("in",s.on.in,V),V.on("out",s.on.out,V),U};function u(O){var I,q,U=this.as,V=U.back,z=U.root,re;if(O.$||(O.$=U.$),this.to.next(O),U.err){U.on("in",{put:U.put=w,$:U.$});return}if(q=O.get){if(z.pass&&(z.pass[U.id]=U),U.lex&&Object.keys(U.lex).forEach(function(L){re[L]=U.lex[L]},re=O.get=O.get||{}),q["#"]||U.soul){if(q["#"]=q["#"]||U.soul,O["#"]||(O["#"]=v(9)),V=z.$.get(q["#"])._,q=q["."]){if(S(V.put,q)&&(re=V.ask&&V.ask[q],(V.ask||(V.ask={}))[q]=V.$.get(q)._,V.on("in",{get:q,put:{"#":V.soul,".":q,":":V.put[q],">":k(z.graph[V.soul],q)}}),re))return}else{if(re=V.ask&&V.ask[""],(V.ask||(V.ask={}))[""]=V,w!==V.put&&(V.on("in",V),re))return;O.$=V.$}return z.ask(E,O),z.on("in",O)}if(q["."])return U.get?(O={get:{".":U.get},$:U.$},(V.ask||(V.ask={}))[U.get]=O.$._,V.on("out",O)):(O={get:U.lex?O.get:{},$:U.$},V.on("out",O));if((U.ask||(U.ask={}))[""]=U,U.get)return q["."]=U.get,(V.ask||(V.ask={}))[U.get]=O.$._,V.on("out",O)}return V.on("out",O)}s.on.out=u;function d(O,I){I=I||this.as;var q=I.root,U=O.$||(O.$=I.$),V=(U||"")._||b,z=O.put||"",re=z["#"],L=z["."],J=w!==z["="]?z["="]:z[":"],le=z[">"]||-1/0,ae;if(w!==O.put&&(w===z["#"]||w===z["."]||w===z[":"]&&w===z["="]||w===z[">"])){if(!$(z)){if(!(re=((z||"")._||"")["#"])){console.log("chain not yet supported for",z,"...",O,I);return}return U=I.root.$.get(re),setTimeout.each(Object.keys(z).sort(),function(R){R=="_"||w===(le=k(z,R))||I.on("in",{$:U,put:{"#":re,".":R,"=":z[R],">":le},VIA:O})})}I.on("in",{$:V.back.$,put:{"#":re=V.back.soul,".":L=V.has||V.get,"=":z,">":k(V.back.put,L)},via:O});return}(O.seen||"")[I.id]||((O.seen||(O.seen=function(){}))[I.id]=I,I!==V&&(Object.keys(O).forEach(function(R){z[R]=O[R]},z={}),z.get=I.get||z.get,!I.soul&&!I.has?z.$$$=z.$$$||I.$:V.soul&&(z.$=I.$,z.$$=z.$$||V.$),O=z),y(O,I),(I.soul||O.$$)&&le>=k(q.graph[re],L)&&((z=q.$.get(re)._).put=M(z.put,L,le,J,re)),!V.soul&&le>=k(q.graph[re],L)&&(ae=(q.$.get(re)._.next||"")[L])&&(ae.put=J,typeof(z=$(J))=="string"&&(ae.put=q.$.get(z)._.put||J)),this.to&&this.to.next(O),I.any&&setTimeout.each(Object.keys(I.any),function(R){(R=I.any[R])&&R(O)},0,99),I.echo&&setTimeout.each(Object.keys(I.echo),function(R){(R=I.echo[R])&&R.on("in",O)},0,99),((O.$$||"")._||V).soul&&(ae=I.next)&&(ae=ae[L])&&(z={},Object.keys(O).forEach(function(R){z[R]=O[R]}),z.$=(O.$$||O.$).get(z.get=L),delete z.$$,delete z.$$$,ae.on("in",z)),m(O,I))}s.on.in=d;function m(O,I){if(I=I||this.as||O.$._,!(O.$$&&this!==s.on)&&!(!O.put||I.soul)){var q=O.put||"",U=q["="]||q[":"],L,V=I.root,z=V.$.get(q["#"]).get(q["."])._;if(typeof(U=$(U))!="string"){this===s.on&&((z.echo||(z.echo={}))[I.id]=I);return}if(!((z.echo||(z.echo={}))[I.id]&&!(V.pass||"")[I.id])){if(L=V.pass){if(L[U+I.id])return;L[U+I.id]=1}(z.echo||(z.echo={}))[I.id]=I,I.has&&(I.link=U);var re=V.$.get(z.link=U)._;(re.echo||(re.echo={}))[z.id]=z;var L=I.ask||"";(L[""]||I.lex)&&re.on("out",{get:{"#":U}}),setTimeout.each(Object.keys(L),function(J,le){!J||!(le=L[J])||le.on("out",{get:{"#":U,".":J}})},0,99)}}}s.on.link=m;function y(O,I){var q=O.put||"",U=w!==q["="]?q["="]:q[":"],V=I.root,z,re;if(w===U){if(I.soul&&w!==I.put||(re=(O.$$||O.$||"")._||"",O["@"]&&(w!==re.put||w!==I.put)))return;(z=I.link||O.linked)&&delete(V.$.get(z)._.echo||"")[I.id],I.has&&(I.link=null),I.put=w,setTimeout.each(Object.keys(I.next||""),function(L,J){(J=I.next[L])&&(z&&delete(V.$.get(z).get(L)._.echo||"")[J.id],J.on("in",{get:L,put:w,$:J.$}))},0,99);return}I.soul||O.$$||(z=$(U),re=O.$._||"",!((z===re.link||I.has&&!re.link)&&!((V.pass||"")[I.id]&&typeof z!="string"))&&(delete(re.echo||"")[I.id],y({get:I.get,put:w,$:O.$,linked:O.linked=O.linked||re.link},I)))}s.on.unlink=y;function E(O,I){var q=this.as,U=q.$._,V=U.root,z=q.get||"",re=(O.put||"")[z["#"]]||"";if(!O.put||typeof z["."]=="string"&&w===re[z["."]]){if(w!==U.put||!U.soul&&!U.has)return;U.ack=(U.ack||0)+1,U.on("in",{get:U.get,put:U.put=w,$:U.$,"@":O["@"]});return}(O._||{}).miss=1,s.on.put(O)}var b={},w,v=String.random,$=s.valid,S=function(O,I){return O&&Object.prototype.hasOwnProperty.call(O,I)},x=s.state,k=x.is,M=x.ify})(n,"./chain"),n(function(i){var s=n("./root");s.chain.get=function(w,v,$){var S,x;if(typeof w=="string"){if(w.length==0)return(S=this.chain())._.err={err:s.log("0 length key!",w)},v&&v.call(S,S._.err),S;var k=this,M=k._,O=M.next||y;(S=O[w])||(S=w&&u(w,k)),S=S&&S.$}else if(typeof w=="function"){let L=function(J,le,ae){if(!L.stun&&!((te=q.pass)&&!te[U])){var R=J.$._,B=(J.$$||"")._,Q=(B||R).put,X=!R.has&&!R.soul,ne={},Ae,te;if((X||b===Q)&&(Q=b===((te=J.put)||"")["="]?b===(te||"")[":"]?te:te[":"]:te["="]),(Ae=typeof(te=s.valid(Q))=="string")&&(Q=b===(te=q.$.get(te)._.put)?I.not?b:Q:te),!(I.not&&b===Q)){if(b===I.stun){if((te=q.stun)&&te.on&&(M.$.back(function(de){if(te.on(""+de.id,ne={}),(ne.run||0)<L.id)return ne}),!ne.run&&te.on(""+R.id,ne={}),!ne.run&&B&&te.on(""+B.id,ne={}),L.id>ne.run&&((!ne.stun||ne.stun.end)&&(ne.stun=te.on("stun"),ne.stun=ne.stun&&ne.stun.last),ne.stun&&!ne.stun.end))){(ne.stun.add||(ne.stun.add={}))[U]=function(){L(J,le,1)};return}if(b===Q&&(ae=0),(te=q.hatch)&&!te.end&&b===I.hatch&&!ae){if(V[R.$._.id])return;V[R.$._.id]=1,te.push(function(){L(J,le,1)});return}V={}}if(q.pass){if(q.pass[U+R.id])return;q.pass[U+R.id]=1}if(I.on){I.ok.call(R.$,Q,R.get,J,le||L);return}if(I.v2020){I.ok(J,le||L);return}Object.keys(J).forEach(function(de){te[de]=J[de]},te={}),J=te,J.put=Q,I.ok.call(I.as,J,le||L)}}};var z=L;if(v===!0)return d(this,w,v,$),this;S=this;var M=S._,I=v||{},q=M.root,U;I.at=M,I.ok=w;var V={};return L.at=M,(M.any||(M.any={}))[U=String.random(7)]=L,L.off=function(){L.stun=1,M.any&&delete M.any[U]},L.rid=m,L.id=I.run||++q.once,x=q.pass,(q.pass={})[U]=1,I.out=I.out||{get:{}},M.on("out",I.out),q.pass=x,S}else{if(typeof w=="number")return this.get(""+w,v,$);if(typeof(x=E(w))=="string")return this.get(x,v,$);(x=this.get.next)&&(S=x(this,w))}return S?(v&&typeof v=="function"&&S.get(v,$),S):((S=this.chain())._.err={err:s.log("Invalid get request!",w)},v&&v.call(S,S._.err),S)};function u(w,v){var $=v._,S=$.next,x=v.chain(),k=x._;return S||(S=$.next={}),S[k.get=w]=k,v===$.root.$?k.soul=w:($.soul||$.has)&&(k.has=w),k}function d(w,v,$,S){var x=w._,k=0,M;return(M=x.soul||x.link)?v(M,S,x):x.jam?x.jam.push([v,S]):(x.jam=[[v,S]],w.get(function(I,q){if(!(b===I.put&&!x.root.opt.super&&(M=Object.keys(x.root.opt.peers).length)&&++k<=M)){q.rid(I);var U=(U=I.$)&&U._||{},V=0,z;for(M=x.jam,delete x.jam;z=M[V++];){var re=z[0],L;z=z[1],re&&re(L=U.link||U.soul||s.valid(I.put)||((I.put||{})._||{})["#"],z,I,q)}}},{out:{get:{".":!0}}}),w)}function m(w){var v=this.at||this.on;if(!w||v.soul||v.has)return this.off();if(w=(w=(w=w.$||w)._||w).id){var $=v.map,S,x;if(S=(x=this.seen||(this.seen={}))[w])return!0;x[w]=!0}}var y={},E=s.valid,b})(n,"./get"),n(function(i){var s=n("./root");s.chain.put=function(k,M,O){var I=this,q=I._,U=q.root;O=O||{},O.root=q.root,O.run||(O.run=U.once),u(O,q.id),O.ack=O.ack||M,O.via=O.via||I,O.data=O.data||k,O.soul||(O.soul=q.soul||typeof M=="string"&&M);var V=O.state=O.state||s.state();return typeof k=="function"?(k(function(z){O.data=z,I.put(E,E,O)}),I):O.soul?(O.$=U.$.get(O.soul),O.todo=[{it:O.data,ref:O.$}],O.turn=O.turn||v,O.ran=O.ran||d,function z(){var re=O.todo,L=re.pop(),J=L.it,le=L.ref&&L.ref._.id,ae,R,B,Q,X;if(u(O,L.ref),(Q=L.todo)&&(R=Q.pop(),J=J[R],Q.length&&re.push(L)),R&&(re.path||(re.path=[])).push(R),!(ae=$(J))&&!(X=s.is(J))){if(!Object.plain(J)){d.err(O,"Invalid data: "+y(J)+" at "+(O.via.back(function(me){me.get&&Q.push(me.get)},Q=[])||Q.join("."))+"."+(re.path||[]).join("."));return}for(var ne=O.seen||(O.seen=[]),Ae=ne.length;Ae--;)if(J===(Q=ne[Ae]).it){ae=J=Q.link;break}}if(R&&ae)L.node=S(L.node,R,V,J);else{let me=function(ve,De){var At=B.link["#"];De&&(De.off(),De.rid(ve));var Ke=At||ve.soul||(Q=(ve.$$||ve.$)._||"").soul||Q.link||((Q=Q.put||"")._||"")["#"]||Q["#"]||((Q=ve.put||"")&&ve.$$?Q["#"]:(Q["="]||Q[":"]||"")["#"]);if(!At&&u(O,ve.$),!Ke&&!L.link["#"]){(L.wait||(L.wait=[])).push(function(){me(ve,De)});return}Ke||(Ke=[],(ve.$$||ve.$).back(function(ze){if(Q=ze.soul||ze.link)return Ke.push(Q);Ke.push(ze.get)}),Ke=Ke.reverse().join("/")),B.link["#"]=Ke,!X&&(((O.graph||(O.graph={}))[Ke]=B.node||(B.node={_:{}}))._["#"]=Ke),delete O.wait[te],B.wait&&setTimeout.each(B.wait,function(ze){ze&&ze()}),O.ran(O)};var de=me;if(!O.seen){d.err(O,"Data at root of graph must be a node (an object).");return}O.seen.push(B={it:J,link:{},todo:X?[]:Object.keys(J).sort().reverse(),path:(re.path||[]).slice(),up:L}),L.node=S(L.node,R,V,B.link),!X&&B.todo.length&&re.push(B);var te=O.seen.length;(O.wait||(O.wait={}))[te]="",Q=(B.ref=X?J:R?L.ref.get(R):L.ref)._,(Q=J&&(J._||"")["#"]||Q.soul||Q.link)?me({soul:Q}):B.ref.get(me,{run:O.run,v2020:1,out:{get:{".":" "}}})}if(!re.length)return O.ran(O);O.turn(z)}(),I):(m(O),I)};function u(k,M){if(M){M=(M._||"").id||M;var O=k.root.stun||(k.root.stun={on:s.on}),I={},q;k.stun||(k.stun=O.on("stun",function(){})),(q=O.on(""+M))&&q.the.last.next(I),!(I.run>=k.run)&&O.on(""+M,function(U){if(k.stun.end){this.off(),this.to.next(U);return}U.run=U.run||k.run,U.stun=U.stun||k.stun})}}function d(k){if(k.err){d.end(k.stun,k.root);return}if(!(k.todo.length||k.end||!Object.empty(k.wait))){k.end=1;var M=k.$.back(-1)._,O=M.root,I=M.ask(function(z){O.on("ack",z),z.err&&!z.lack&&s.log(z),++q>(k.acks||0)&&this.off(),k.ack&&k.ack(z,this)},k.opt),q=0,U=k.stun,V;(V=function(){U&&(d.end(U,O),setTimeout.each(Object.keys(U=U.add||""),function(z){(z=U[z])&&z()}))}).hatch=V,k.ack&&!k.ok&&(k.ok=k.acks||9),k.via._.on("out",{put:k.out=k.graph,ok:k.ok&&{"@":k.ok+1},opt:k.opt,"#":I,_:V})}}d.end=function(k,M){k.end=w,k.the.to===k&&k===k.the.last&&delete M.stun,k.off()},d.err=function(k,M){(k.ack||w).call(k,k.out={err:k.err=s.log(M)}),k.ran(k)};function m(k){var M=k.via._,O;k.via=k.via.back(function(I){if(I.soul||!I.get)return I.$;O=k.data,(k.data={})[I.get]=O}),(!k.via||!k.via._.soul)&&(k.via=M.root.$.get(((k.data||"")._||"")["#"]||M.$.back("opt.uuid")())),k.via.put(k.data,k.ack,k)}function y(k,M){return k&&(M=k.constructor)&&M.name||typeof k}var E,b={},w=function(){},v=setTimeout.turn,$=s.valid,S=s.state.ify,x=function(k,M){k.call(M||b)}})(n,"./put"),n(function(i){var s=n("./root");n("./chain"),n("./back"),n("./put"),n("./get"),i.exports=s})(n,"./index"),n(function(i){var s=n("./index");s.chain.on=function(E,b,w,v){var $=this,S=$._,x=S.root,k,M,O,I;if(typeof E=="string")return b?(k=S.on(E,b,w||S,v),w&&w.$&&(w.subs||(w.subs=[])).push(k),$):S.on(E);var q=b;(q=q===!0?{change:!0}:q||{}).not=1,q.on=1;var U={};return $.get(E,q),$},s.chain.once=function(E,b){if(b=b||{},!E)return u(this,b);var w=this,v=w._,$=v.root,S=v.put,x=String.random(7),k,M;return w.get(function(O,I,q,U){var V=this,z=V._,re=z.one||(z.one={});if(U.stun||re[x]==="")return;if((M=s.valid(O))===!0){L();return}if(typeof M=="string")return;clearTimeout((v.one||"")[x]),clearTimeout(re[x]),re[x]=setTimeout(L,b.wait||99);function L(J){if(!z.has&&!z.soul&&(z={put:O,get:I}),y===(M=z.put)&&(M=((q.$$||"")._||"").put),typeof s.valid(M)=="string"&&(M=$.$.get(M)._.put,M===y&&!J)){re[x]=setTimeout(function(){L(1)},b.wait||99);return}U.stun||re[x]!==""&&(re[x]="",(v.soul||v.has)&&U.off(),E.call(V,M,z.get),clearTimeout(re[x]))}},{on:1}),w};function u(E,b,w){return s.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."),(w=E.chain())._.nix=E.once(function(v,$){w._.on("in",this._)}),w._.lex=E._.lex,w}s.chain.off=function(){var E=this,b=E._,w,v=b.back;if(v)return b.ack=0,(w=v.next)&&w[b.get]&&delete w[b.get],(w=v.any)&&(delete v.any,v.any={}),(w=v.ask)&&delete w[b.get],(w=v.put)&&delete w[b.get],(w=b.soul)&&delete v.root.graph[w],(w=b.map)&&Object.keys(w).forEach(function($,S){S=w[$],S.link&&v.root.$.get(S.link).off()}),(w=b.next)&&Object.keys(w).forEach(function($,S){S=w[$],S.$.off()}),b.on("off",{}),E};var d={},m=function(){},y})(n,"./on"),n(function(i){var s=n("./index"),u=s.chain.get.next;s.chain.get.next=function(b,w){var v;return Object.plain(w)?(v=((v=w["#"])||"")["="]||v)?b.get(v):((v=b.chain()._).lex=w,b.on("in",function($){String.match($.get||($.put||"")["."],w["."]||w["#"]||w)&&v.on("in",$),this.to.next($)}),v.$):(u||m)(b,w)},s.chain.map=function(b,w,v){var $=this,S=$._,x,k;return Object.plain(b)&&(x=b["."]?b:{".":b},b=E),b?(s.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."),k=$.chain(),$.map().on(function(M,O,I,q){var U=(b||m).call(this,M,O,I,q);if(E!==U){if(M===U)return k._.on("in",I);if(s.is(U))return k._.on("in",U._);var V={};Object.keys(I.put).forEach(function(z){V[z]=I.put[z]},V),V["="]=U,k._.on("in",{get:O,put:V})}}),k):((k=S.each)||((S.each=k=$.chain())._.lex=x||k._.lex||S.lex,k._.nix=$.back("nix"),$.on("in",d,k._)),k)};function d(b){this.to.next(b);var w=this.as,v=b.$,$=v._,S=b.put,x;!$.soul&&!b.$$||(x=w.lex)&&!String.match(b.get||(S||"")["."],x["."]||x["#"]||x)||s.on.link(b,w)}var m=function(){},y={stun:m,off:m},E})(n,"./map"),n(function(i){var s=n("./index");s.chain.set=function(u,d,m){var y=this,E=y.back(-1),b,w;return d=d||function(){},m=m||{},m.item=m.item||u,(b=((u||"")._||"")["#"])&&((u={})["#"]=b),typeof(w=s.valid(u))=="string"?y.get(b=w).put(u,d,m):s.is(u)?(y.put(function(v){u.get(function($,S,x){if(!$)return d.call(y,{err:s.log('Only a node can be linked! Not "'+x.put+'"!')});(w={})[$]={"#":$},v(w)},!0)}),u):(Object.plain(u)&&(u=E.get(b=y.back("opt.uuid")()).put(u)),y.get(b||E.back("opt.uuid")(7)).put(u,d,m))}})(n,"./set"),n(function(i){n("./shim");var s=function(){},u=JSON.parseAsync||function(w,v,$){var S,x=+new Date;try{v(S,JSON.parse(w,$),d.sucks(+new Date-x))}catch(k){v(k)}},d=JSON.stringifyAsync||function(w,v,$,S){var x,k=+new Date;try{v(x,JSON.stringify(w,$,S),d.sucks(+new Date-k))}catch(M){v(M)}};d.sucks=function(w){w>99&&(console.log("Warning: JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."),d.sucks=s)};function m(w){var v=function(){},$=w.opt||{};$.log=$.log||console.log,$.gap=$.gap||$.wait||0,$.max=$.max||($.memory?$.memory*999*999:3e8)*.3,$.pack=$.pack||$.max*.01*.01,$.puff=$.puff||9;var S=setTimeout.turn||setTimeout,x=w.dup,k=x.check,M=x.track,O=+new Date,I=O,q=v.hear=function(L,J){if(L){if($.max<=L.length)return v.say({dam:"!",err:"Message too big!"},J);v===this&&(q.d+=L.length||0,++q.c);var le=J.SH=+new Date,ae=L[0],R;if(ae==="["){u(L,function(B,Q){if(B||!Q)return v.say({dam:"!",err:"DAM JSON parse error."},J);console.STAT&&console.STAT(+new Date,Q.length,"# on hear batch");var X=$.puff;(function ne(){for(var Ae=+new Date,te=0,de;te<X&&(de=Q[te++]);)v.hear(de,J);Q=Q.slice(te),console.STAT&&console.STAT(Ae,+new Date-Ae,"hear loop"),V(J),Q.length&&S(ne,0)})()}),L="";return}if(ae==="{"||(L["#"]||Object.plain(L))&&(R=L)){if(R)return q.one(R,J,le);u(L,function(B,Q){if(B||!Q)return v.say({dam:"!",err:"DAM JSON parse error."},J);q.one(Q,J,le)});return}}};q.one=function(L,J,ne){var ae,R,B,Q,X;if(L.DBG&&(L.DBG=X={DBG:L.DBG}),X&&(X.h=ne),X&&(X.hp=+new Date),(ae=L["#"])||(ae=L["#"]=String.random(9)),!(B=k(ae))&&(R=L["##"],!(R&&(B=L["@"]||L.get&&ae)&&x.check(Q=B+R)))){if((L._=function(){}).via=v.leap=J,(B=L["><"])&&typeof B=="string"&&B.slice(0,99).split(",").forEach(function(Ae){this[Ae]=1},L._.yo={}),B=L.dam){(B=v.hear[B])&&B(L,J,w),M(ae);return}(B=L.ok)&&(L._.near=B["/"]);var ne=+new Date;X&&(X.is=ne),J.SI=ae,M.ed=function(Ae){ae===Ae&&(M.ed=0,(Ae=x.s[ae])&&(Ae.via=J,L.get&&(Ae.it=L)))},w.on("in",v.last=L),X&&(X.hd=+new Date),console.STAT&&console.STAT(ne,+new Date-ne,L.get?"msg get":L.put?"msg put":"msg"),M(ae),Q&&M(Q),v.leap=v.last=null}};var U=function(L,J,le){le(L,!0)};q.c=q.d=0,function(){var L=0,J;v.hash=function(B,Q){var X,ne,Ae,te=+new Date;d(B.put,function de(me,ve){var De=(ne||(ne=Ae=ve||"")).slice(0,32768);if(X=String.hash(De,X),ne=ne.slice(32768),ne){S(de,0);return}console.STAT&&console.STAT(te,+new Date-te,"say json+hash"),B._.$put=Ae,B["##"]=X,v.say(B,Q),delete B._.$put},le)};function le(B,Q){var X;return Q instanceof Object?(Object.keys(Q).sort().forEach(ae,{to:X={},on:Q}),X):Q}function ae(B){this.to[B]=this.on[B]}var R=v.say=function(B,Q){var X;if((X=this)&&(X=X.to)&&X.next&&X.next(B),!B)return!1;var ne,Ae,te,de=B["@"],me=B._||(B._=function(){}),ve=B.DBG,De=+new Date;if(me.y=me.y||De,Q||ve&&(ve.y=De),(ne=B["#"])||(ne=B["#"]=String.random(9)),!J&&M(ne),!(Ae=B["##"])&&b!==B.put&&!me.via&&de){v.hash(B,Q);return}if(!Q&&de&&(Q=(X=x.s[de])&&(X.via||(X=X.it)&&(X=X._)&&X.via)||(X=v.last)&&de===X["#"]&&v.leap),!Q&&de)return x.s[de]?void 0:(console.STAT&&console.STAT(+new Date,++L,"total no peer to ack to"),!1);if(de&&!B.put&&!Ae&&((x.s[de]||"").it||"")["##"])return!1;if(!Q&&v.way)return v.way(B);if(ve&&(ve.yh=+new Date),!(te=me.raw)){v.raw(B,Q);return}if(ve&&(ve.yr=+new Date),!Q||!Q.id){if(!Object.plain(Q||$.peers))return!1;var De=+new Date,At=$.puff,Ke=$.peers,ze=Object.keys(Q||$.peers||{});console.STAT&&console.STAT(De,+new Date-De,"peer keys"),function CA(){var sA=+new Date;J=1;var aA=me.raw;me.raw=te;for(var SA=0,DA;SA<9&&(DA=(ze||"")[SA++]);)(DA=Ke[DA]||(Q||"")[DA])&&v.say(B,DA);me.raw=aA,J=0,ze=ze.slice(SA),console.STAT&&console.STAT(sA,+new Date-sA,"say loop"),ze.length&&(S(CA,0),de&&M(de))}();return}if(!Q.wire&&v.wire&&v.wire(Q),ne!==Q.last){if(Q.last=ne,Q===me.via||(X=me.yo)&&(X[Q.url]||X[Q.pid]||X[Q.id]))return!1;if(console.STAT&&console.STAT(De,((ve||me).yp=+new Date)-(me.y||De),"say prep"),!J&&de&&M(de),Q.batch){if(Q.tail=(X=Q.tail||0)+te.length,Q.tail<=$.pack){Q.batch+=(X?",":"")+te;return}V(Q)}Q.batch="[";var gt=+new Date;setTimeout(function(){console.STAT&&console.STAT(gt,+new Date-gt,"0ms TO"),V(Q)},$.gap),z(te,Q),console.STAT&&de===Q.SI&&console.STAT(De,+new Date-Q.SH,"say ack")}};v.say.c=v.say.d=0,v.raw=function(B,Q){if(!B)return"";var X=B._||{},ne,Ae;if(Ae=X.raw)return Ae;if(typeof B=="string")return B;var te=B["##"],de=B["@"];if(te&&de){if(!X.via&&k(de+te))return!1;if(Ae=(x.s[de]||"").it){if(te===Ae["##"])return!1;Ae["##"]||(Ae["##"]=te)}}if(!B.dam&&!B["@"]){var me=0,ve=[];Ae=$.peers;for(var De in Ae){var At=Ae[De];if(ve.push(At.url||At.pid||At.id),++me>6)break}me>1&&(B["><"]=ve.join())}if(B.put&&(Ae=B.ok)&&(B.ok={"@":(Ae["@"]||1)-1,"/":Ae["/"]==B._.near?v.near:Ae["/"]}),ne=X.$put){Ae={},Object.keys(B).forEach(function(ze){Ae[ze]=B[ze]}),Ae.put=":])([:",d(Ae,function(ze,gt){if(!ze){var JA=+new Date;Ae=gt.indexOf('"put":":])([:"'),Ke(b,gt=gt.slice(0,Ae+6)+ne+gt.slice(Ae+14)),console.STAT&&console.STAT(JA,+new Date-JA,"say slice")}});return}d(B,Ke);function Ke(ze,gt){ze||(X.raw=gt,v.say(B,Q))}}}();function V(L){var J=L.batch,le=typeof J=="string",ae;if(le&&(J+="]"),L.batch=L.tail=null,!!J&&!(le?3>J.length:!J.length)){if(!le)try{J=J.length===1?J[0]:JSON.stringify(J)}catch(R){return $.log("DAM JSON stringify error",R)}J&&z(J,L)}}function z(L,J){try{var le=J.wire;J.say?J.say(L):le.send&&le.send(L),v.say.d+=L.length||0,++v.say.c}catch{(J.queue=J.queue||[]).push(L)}}v.near=0,v.hi=function(L){var J=L.wire,le;if(!J){v.wire(L.length&&{url:L,id:L}||L);return}L.id?$.peers[L.url||L.id]=L:(le=L.id=L.id||L.url||String.random(9),v.say({dam:"?",pid:w.opt.pid},$.peers[le]=L),delete x.s[L.last]),L.met||(v.near++,L.met=+new Date,w.on("hi",L)),le=L.queue,L.queue=[],setTimeout.each(le||[],function(ae){z(ae,L)},0,9)},v.bye=function(L){L.met&&--v.near,delete L.met,w.on("bye",L);var J=+new Date;J=J-(L.met||J),v.bye.time=((v.bye.time||J)+J)/2},v.hear["!"]=function(L,J){$.log("Error:",L.err)},v.hear["?"]=function(L,J){L.pid&&(J.pid||(J.pid=L.pid),L["@"])||(v.say({dam:"?",pid:$.pid,"@":L["#"]},J),delete x.s[J.last])},v.hear.mob=function(L,J){if(L.peers){var le=Object.keys(L.peers),ae=le[Math.random()*le.length>>0];ae&&(v.bye(J),v.hi(ae))}},w.on("create",function(L){L.opt.pid=L.opt.pid||String.random(9),this.to.next(L),L.on("out",v.say)}),w.on("bye",function(L,J){L=$.peers[L.id||L]||L,this.to.next(L),L.bye?L.bye():(J=L.wire)&&J.close&&J.close(),delete $.peers[L.id],L.wire=null});var re={};return w.on("bye",function(L,J){this.to.next(L),(J=console.STAT)&&(J.peers=v.near),(J=L.url)&&(re[J]=!0,setTimeout(function(){delete re[J]},$.lack||9e3))}),w.on("hi",function(L,J){if(this.to.next(L),(J=console.STAT)&&(J.peers=v.near),!$.super){var le=Object.keys(w.next||"");le.length>9999&&!console.SUBS&&console.log(console.SUBS="Warning: You have more than 10K live GETs, which might use more bandwidth than your screen can show - consider `.off()`."),setTimeout.each(le,function(ae){var R=w.next[ae];if($.super||(R.ask||"")[""]){v.say({get:{"#":ae}},L);return}setTimeout.each(Object.keys(R.ask||""),function(B){B&&v.say({"##":String.hash((w.graph[ae]||"")[B]),get:{"#":ae,".":B}},L)})})}}),v}var y={},E=!0,b;try{i.exports=m}catch{}})(n,"./mesh"),n(function(i){var s=n("./index");s.Mesh=n("./mesh"),s.on("opt",function(m){if(this.to.next(m),m.once)return;var y=m.opt;if(y.WebSocket===!1)return;var E=s.window||{},b=y.WebSocket||E.WebSocket||E.webkitWebSocket||E.mozWebSocket;if(!b)return;y.WebSocket=b;var w=y.mesh=y.mesh||s.Mesh(m),v=w.wire||y.wire;w.wire=y.wire=$;function $(M){try{if(!M||!M.url)return I&&I(M);var O=M.url.replace(/^http/,"ws"),I=M.wire=new y.WebSocket(O);return I.onclose=function(){x(M),y.mesh.bye(M)},I.onerror=function(q){x(M)},I.onopen=function(){y.mesh.hi(M)},I.onmessage=function(q){q&&y.mesh.hear(q.data||q,M)},I}catch{y.mesh.bye(M)}}setTimeout(function(){!y.super&&m.on("out",{dam:"hi"})},1);var S=2*999;function x(M){clearTimeout(M.defer),y.peers[M.url]&&(k&&M.retry<=0||(M.retry=(M.retry||y.retry+1||60)-(-M.tried+(M.tried=+new Date)<S*4?1:0),M.defer=setTimeout(function O(){if(k&&k.hidden)return setTimeout(O,S);$(M)},S)))}var k=""+d!=typeof document&&document});var u=function(){},d})(n,"./websocket"),n(function(i){if(!(typeof Gun>"u")){var s=function(){},u,d;try{u=(Gun.window||s).localStorage}catch{}u||(Gun.log("Warning: No localStorage exists to persist data to!"),u={setItem:function(E,b){this[E]=b},removeItem:function(E){delete this[E]},getItem:function(E){return this[E]}});var m=JSON.parseAsync||function(E,b,w){var v;try{b(v,JSON.parse(E,w))}catch($){b($)}},y=JSON.stringifyAsync||function(E,b,w,v){var $;try{b($,JSON.stringify(E,w,v))}catch(S){b(S)}};Gun.on("create",function E(b){this.to.next(b);var w=b.opt,v=b.graph,$=[],S,x,k,M;if(w.localStorage===!1)return;w.prefix=w.file||"gun/";try{S=E[w.prefix]=E[w.prefix]||JSON.parse(k=u.getItem(w.prefix))||{}}catch{S=E[w.prefix]={}}k=(k||"").length,b.on("get",function(I){this.to.next(I);var q=I.get,U,V,z,re;!q||!(U=q["#"])||(V=S[U]||re,V&&(z=q["."])&&!Object.plain(z)&&(V=Gun.state.ify({},z,Gun.state.is(V,z),V[z],U)),Gun.on.get.ack(I,V))}),b.on("put",function(I){this.to.next(I);var q=I.put,U=q["#"],V=q["."],z=I["#"],re=I.ok||"",L;if(S[U]=Gun.state.ify(S[U],V,q[">"],q[":"],U),M&&k>4999880){b.on("in",{"@":z,err:"localStorage max!"});return}!I["@"]&&(!I._.via||Math.random()<re["@"]/re["/"])&&$.push(z),!x&&(x=setTimeout(O,9+k/333))});function O(){if(!$.length&&((setTimeout.turn||"").s||"").length){setTimeout(O,99);return}var I,q=$;clearTimeout(x),x=!1,$=[],y(S,function(U,V){try{!U&&u.setItem(w.prefix,V)}catch(z){U=M=z||"localStorage failure"}U&&(Gun.log(U+" Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install"),b.on("localStorage:error",{err:U,get:w.prefix,put:S})),k=V.length,setTimeout.each(q,function(z){b.on("in",{"@":z,err:U,ok:0})},0,99)})}})}})(n,"./localStorage")})();(function(){var ae;if(""+ae!=typeof Gun){var n=function(R){console.warn("Warning! Deprecated internal utility will break in next version:",R)},e=Gun;e.fn=e.fn||{is:function(R){return n("fn"),!!R&&typeof R=="function"}},e.bi=e.bi||{is:function(R){return n("bi"),R instanceof Boolean||typeof R=="boolean"}},e.num=e.num||{is:function(R){return n("num"),!i(R)&&(R-parseFloat(R)+1>=0||R===1/0||R===-1/0)}},e.text=e.text||{is:function(R){return n("text"),typeof R=="string"}},e.text.ify=e.text.ify||function(R){return n("text.ify"),e.text.is(R)?R:typeof JSON<"u"?JSON.stringify(R):R&&R.toString?R.toString():R},e.text.random=e.text.random||function(R,B){n("text.random");var Q="";for(R=R||24,B=B||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";R>0;)Q+=B.charAt(Math.floor(Math.random()*B.length)),R--;return Q},e.text.match=e.text.match||function(R,B){var Q,X;return n("text.match"),typeof R!="string"?!1:(typeof B=="string"&&(B={"=":B}),B=B||{},Q=B["="]||B["*"]||B[">"]||B["<"],R===Q?!0:X!==B["="]?!1:(Q=B["*"]||B[">"]||B["<"],R.slice(0,(Q||"").length)===Q?!0:X!==B["*"]?!1:X!==B[">"]&&X!==B["<"]?R>=B[">"]&&R<=B["<"]:X!==B[">"]&&R>=B[">"]||X!==B["<"]&&R<=B["<"]))},e.text.hash=e.text.hash||function(R,B){if(n("text.hash"),typeof R=="string"){if(B=B||0,!R.length)return B;for(var Q=0,X=R.length,ne;Q<X;++Q)ne=R.charCodeAt(Q),B=(B<<5)-B+ne,B|=0;return B}},e.list=e.list||{is:function(R){return n("list"),R instanceof Array}},e.list.slit=e.list.slit||Array.prototype.slice,e.list.sort=e.list.sort||function(R){return n("list.sort"),function(B,Q){return!B||!Q?0:(B=B[R],Q=Q[R],B<Q?-1:B>Q?1:0)}},e.list.map=e.list.map||function(R,B,Q){return n("list.map"),J(R,B,Q)},e.list.index=1,e.obj=e.boj||{is:function(R){return n("obj"),R?R instanceof Object&&R.constructor===Object||Object.prototype.toString.call(R).match(/^\[object (\w+)\]$/)[1]==="Object":!1}},e.obj.put=e.obj.put||function(R,B,Q){return n("obj.put"),(R||{})[B]=Q,R},e.obj.has=e.obj.has||function(R,B){return n("obj.has"),R&&Object.prototype.hasOwnProperty.call(R,B)},e.obj.del=e.obj.del||function(R,B){if(n("obj.del"),!!R)return R[B]=null,delete R[B],R},e.obj.as=e.obj.as||function(R,B,Q,X){return n("obj.as"),R[B]=R[B]||(X===Q?{}:Q)},e.obj.ify=e.obj.ify||function(R){if(n("obj.ify"),U(R))return R;try{R=JSON.parse(R)}catch{R={}}return R},function(){var R;function B(Q,X){z(this,X)&&R!==this[X]||(this[X]=Q)}e.obj.to=e.obj.to||function(Q,X){return n("obj.to"),X=X||{},J(Q,B,X),X}}(),e.obj.copy=e.obj.copy||function(R){return n("obj.copy"),R&&JSON.parse(JSON.stringify(R))},function(){function R(B,Q){var X=this.n,ne;if(!(X&&(Q===X||U(X)&&z(X,Q)))&&ne!==Q)return!0}e.obj.empty=e.obj.empty||function(B,Q){return n("obj.empty"),B?!J(B,R,{n:Q}):!0}}(),function(){function R(ne,Ae){if(arguments.length===2){R.r=R.r||{},R.r[ne]=Ae;return}R.r=R.r||[],R.r.push(ne)}var B=Object.keys,Q,X;Object.keys=Object.keys||function(ne){return Q(ne,function(Ae,te,de){de(te)})},e.obj.map=Q=e.obj.map||function(ne,Ae,te){n("obj.map");var de,me=0,ve,De,At,Ke,ze=typeof Ae=="function";if(R.r=de,B&&U(ne)&&(At=B(ne),Ke=!0),te=te||{},i(ne)||At)for(ve=(At||ne).length;me<ve;me++){var gt=me+e.list.index;if(ze){if(De=Ke?Ae.call(te,ne[At[me]],At[me],R):Ae.call(te,ne[me],gt,R),De!==de)return De}else if(Ae===ne[Ke?At[me]:me])return At?At[me]:gt}else for(me in ne)if(ze){if(z(ne,me)&&(De=te?Ae.call(te,ne[me],me,R):Ae(ne[me],me,R),De!==de))return De}else if(Ae===ne[me])return me;return ze?R.r:e.list.index?0:-1}}(),e.time=e.time||{},e.time.is=e.time.is||function(R){return n("time"),R?R instanceof Date:+new Date().getTime()};var I=e.fn.is,i=e.list.is,q=e.obj,U=q.is,z=q.has,J=q.map,s={};s.is=function(R){return n("val.is"),R===ae?!1:R===null?!0:R===1/0?!1:m(R)||d(R)||x(R)?!0:s.link.is(R)||!1},s.link=s.rel={_:"#"},function(){s.link.is=function(B){if(n("val.link.is"),B&&B[u]&&!B._&&U(B)){var Q={};if(J(B,R,Q),Q.id)return Q.id}return!1};function R(B,Q){var X=this;if(X.id)return X.id=!1;if(Q==u&&m(B))X.id=B;else return X.id=!1}}(),s.link.ify=function(R){return n("val.link.ify"),L({},u,R)},e.obj.has._=".";var u=s.link._,ae,d=e.bi.is,x=e.num.is,m=e.text.is,q=e.obj,U=q.is,L=q.put,J=q.map;e.val=e.val||s;var y={_:"_"};y.soul=function(R,B){return n("node.soul"),R&&R._&&R._[B||w]},y.soul.ify=function(R,B){return n("node.soul.ify"),B=typeof B=="string"?{soul:B}:B||{},R=R||{},R._=R._||{},R._[w]=B.soul||R._[w]||b(),R},y.soul._=s.link._,function(){y.is=function(B,Q,X){n("node.is");var ne;return U(B)&&(ne=y.soul(B))?!J(B,R,{as:X,cb:Q,s:ne,n:B}):!1};function R(B,Q){if(Q!==y._){if(!s.is(B))return!0;this.cb&&this.cb.call(this.as,B,Q,this.n,this.s)}}}(),function(){y.ify=function(B,Q,X){return n("node.ify"),Q?typeof Q=="string"?Q={soul:Q}:typeof Q=="function"&&(Q={map:Q}):Q={},Q.map&&(Q.node=Q.map.call(X,B,ae,Q.node||{})),(Q.node=y.soul.ify(Q.node||{},Q))&&J(B,R,{o:Q,as:X}),Q.node};function R(B,Q){var X=this.o,ne,Ae;if(X.map){ne=X.map.call(this.as,B,""+Q,X.node),Ae===ne?V(X.node,Q):X.node&&(X.node[Q]=ne);return}s.is(B)&&(X.node[Q]=B)}}();var q=e.obj,U=q.is,V=q.del,J=q.map,E=e.text,b=E.random,w=y.soul._,ae;e.node=e.node||y;var v=e.state;v.lex=function(){return n("state.lex"),v().toString(36).replace(".","")},v.to=function(R,B,Q){n("state.to");var X=(R||{})[B];return U(X)&&(X=le(X)),v.ify(Q,B,v.is(R,B),X,y.soul(R))},function(){v.map=function(B,Q,X){n("state.map");var ne,Ae=U(Ae=B||Q)?Ae:null;return B=I(B=B||Q)?B:null,Ae&&!B?(Q=x(Q)?Q:v(),Ae[M]=Ae[M]||{},J(Ae,R,{o:Ae,s:Q}),Ae):(X=X||U(Q)?Q:ne,Q=x(Q)?Q:v(),function(te,de,me,ve){if(!B)return R.call({o:me,s:Q},te,de),te;B.call(X||this||{},te,de,me,ve),!(z(me,de)&&ne===me[de])&&R.call({o:me,s:Q},te,de)})};function R(B,Q){M!==Q&&v.ify(this.o,Q,this.s)}}();var q=e.obj,$=q.as,z=q.has,U=q.is,J=q.map,le=q.copy,S=e.num,x=S.is,k=e.fn,I=k.is,M=y._,ae,O={};(function(){O.is=function(Q,X,ne,Ae){return n("graph.is"),!Q||!U(Q)||re(Q)?!1:!J(Q,R,{cb:X,fn:ne,as:Ae})};function R(Q,X){if(!Q||X!==y.soul(Q)||!y.is(Q,this.fn,this.as))return!0;this.cb&&(B.n=Q,B.as=this.as,this.cb.call(B.as,Q,X,B))}function B(Q){Q&&y.is(B.n,Q,B.as)}})(),function(){O.ify=function(Ae,te,de){n("graph.ify");var me={path:[],obj:Ae};return te?typeof te=="string"?te={soul:te}:typeof te=="function"&&(te.map=te):te={},typeof de=="string"&&(te.soul=te.soul||de,de=ae),te.soul&&(me.link=s.link.ify(te.soul)),te.shell=(de||{}).shell,te.graph=te.graph||{},te.seen=te.seen||[],te.as=te.as||de,R(te,me),te.root=me.node,te.graph};function R(Ae,te){var de;return(de=ne(Ae,te))?de:(te.env=Ae,te.soul=Q,y.ify(te.obj,B,te)&&(te.link=te.link||s.link.ify(y.soul(te.node)),te.obj!==Ae.shell&&(Ae.graph[s.link.is(te.link)]=te.node)),te)}function B(Ae,te,de){var me=this,ve=me.env,De,At;if(y._===te&&z(Ae,s.link._))return de._;if(De=X(Ae,te,de,me,ve)){if(te||(me.node=me.node||de||{},z(Ae,y._)&&y.soul(Ae)&&(me.node._=le(Ae._)),me.node=y.soul.ify(me.node,s.link.is(me.link)),me.link=me.link||s.link.ify(y.soul(me.node))),(At=ve.map)&&(At.call(ve.as||{},Ae,te,de,me),z(de,te))){if(Ae=de[te],ae===Ae){V(de,te);return}if(!(De=X(Ae,te,de,me,ve)))return}if(!te)return me.node;if(De===!0)return Ae;if(At=R(ve,{obj:Ae,path:me.path.concat(te)}),!!At.node)return At.link}}function Q(Ae){var te=this,de=s.link.is(te.link),me=te.env.graph;te.link=te.link||s.link.ify(Ae),te.link[s.link._]=Ae,te.node&&te.node[y._]&&(te.node[y._][s.link._]=Ae),z(me,de)&&(me[Ae]=me[de],V(me,de))}function X(Ae,te,de,me,ve){var De;if(s.is(Ae))return!0;if(U(Ae))return 1;if(De=ve.invalid)return Ae=De.call(ve.as||{},Ae,te,de),X(Ae,te,de,me,ve);ve.err="Invalid value at '"+me.path.concat(te).join(".")+"'!",e.list.is(Ae)&&(ve.err+=" Use `.set(item)` instead of an Array.")}function ne(Ae,te){for(var de=Ae.seen,me=de.length,ve;me--;)if(ve=de[me],te.obj===ve.obj)return ve;de.push(te)}}(),O.node=function(R){n("graph.node");var B=y.soul(R);if(B)return L({},B,R)},function(){O.to=function(B,Q,X){if(n("graph.to"),!!B){var ne={};return X=X||{seen:{}},J(B[Q],R,{obj:ne,graph:B,opt:X}),ne}};function R(B,Q){var X,ne;if(y._===Q){if(re(B,s.link._))return;this.obj[Q]=le(B);return}if(!(X=s.link.is(B))){this.obj[Q]=B;return}if(ne=this.opt.seen[X]){this.obj[Q]=ne;return}this.obj[Q]=this.opt.seen[X]=O.to(this.graph,X,this.opt)}}();var I=e.fn.is,q=e.obj,U=q.is,V=q.del,z=q.has,re=q.empty,L=q.put,J=q.map,le=q.copy,ae;e.graph=e.graph||O}})()});var Uc=pe((AC,qc)=>{qc.exports=Lc()});var po=pe(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.regexpCode=nt.getEsmExportName=nt.getProperty=nt.safeStringify=nt.stringify=nt.strConcat=nt.addCodeArg=nt.str=nt._=nt.nil=nt._Code=nt.Name=nt.IDENTIFIER=nt._CodeOrName=void 0;var co=class{};nt._CodeOrName=co;nt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var _n=class extends co{constructor(e){if(super(),!nt.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};nt.Name=_n;var hA=class extends co{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((i,s)=>`${i}${s}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((i,s)=>(s instanceof _n&&(i[s.str]=(i[s.str]||0)+1),i),{})}};nt._Code=hA;nt.nil=new hA("");function Gc(n,...e){let i=[n[0]],s=0;for(;s<e.length;)F0(i,e[s]),i.push(n[++s]);return new hA(i)}nt._=Gc;var N0=new hA("+");function Hc(n,...e){let i=[ho(n[0])],s=0;for(;s<e.length;)i.push(N0),F0(i,e[s]),i.push(N0,ho(n[++s]));return By(i),new hA(i)}nt.str=Hc;function F0(n,e){e instanceof hA?n.push(...e._items):e instanceof _n?n.push(e):n.push(Ny(e))}nt.addCodeArg=F0;function By(n){let e=1;for(;e<n.length-1;){if(n[e]===N0){let i=My(n[e-1],n[e+1]);if(i!==void 0){n.splice(e-1,3,i);continue}n[e++]="+"}e++}}function My(n,e){if(e==='""')return n;if(n==='""')return e;if(typeof n=="string")return e instanceof _n||n[n.length-1]!=='"'?void 0:typeof e!="string"?`${n.slice(0,-1)}${e}"`:e[0]==='"'?n.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(n instanceof _n))return`"${n}${e.slice(1)}`}function jy(n,e){return e.emptyStr()?n:n.emptyStr()?e:Hc`${n}${e}`}nt.strConcat=jy;function Ny(n){return typeof n=="number"||typeof n=="boolean"||n===null?n:ho(Array.isArray(n)?n.join(","):n)}function Fy(n){return new hA(ho(n))}nt.stringify=Fy;function ho(n){return JSON.stringify(n).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}nt.safeStringify=ho;function Qy(n){return typeof n=="string"&&nt.IDENTIFIER.test(n)?new hA(`.${n}`):Gc`[${n}]`}nt.getProperty=Qy;function Ly(n){if(typeof n=="string"&&nt.IDENTIFIER.test(n))return new hA(`${n}`);throw new Error(`CodeGen: invalid export name: ${n}, use explicit $id name mapping`)}nt.getEsmExportName=Ly;function qy(n){return new hA(n.toString())}nt.regexpCode=qy});var q0=pe(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.ValueScope=Zt.ValueScopeName=Zt.Scope=Zt.varKinds=Zt.UsedValueState=void 0;var Xt=po(),Q0=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Ts;(function(n){n[n.Started=0]="Started",n[n.Completed=1]="Completed"})(Ts||(Zt.UsedValueState=Ts={}));Zt.varKinds={const:new Xt.Name("const"),let:new Xt.Name("let"),var:new Xt.Name("var")};var Os=class{constructor({prefixes:e,parent:i}={}){this._names={},this._prefixes=e,this._parent=i}toName(e){return e instanceof Xt.Name?e:this.name(e)}name(e){return new Xt.Name(this._newName(e))}_newName(e){let i=this._names[e]||this._nameGroup(e);return`${e}${i.index++}`}_nameGroup(e){var i,s;if(!((s=(i=this._parent)===null||i===void 0?void 0:i._prefixes)===null||s===void 0)&&s.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Zt.Scope=Os;var Is=class extends Xt.Name{constructor(e,i){super(i),this.prefix=e}setValue(e,{property:i,itemIndex:s}){this.value=e,this.scopePath=(0,Xt._)`.${new Xt.Name(i)}[${s}]`}};Zt.ValueScopeName=Is;var Uy=(0,Xt._)`\n`,L0=class extends Os{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Uy:Xt.nil}}get(){return this._scope}name(e){return new Is(e,this._newName(e))}value(e,i){var s;if(i.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let u=this.toName(e),{prefix:d}=u,m=(s=i.key)!==null&&s!==void 0?s:i.ref,y=this._values[d];if(y){let w=y.get(m);if(w)return w}else y=this._values[d]=new Map;y.set(m,u);let E=this._scope[d]||(this._scope[d]=[]),b=E.length;return E[b]=i.ref,u.setValue(i,{property:d,itemIndex:b}),u}getValue(e,i){let s=this._values[e];if(s)return s.get(i)}scopeRefs(e,i=this._values){return this._reduceValues(i,s=>{if(s.scopePath===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return(0,Xt._)`${e}${s.scopePath}`})}scopeCode(e=this._values,i,s){return this._reduceValues(e,u=>{if(u.value===void 0)throw new Error(`CodeGen: name "${u}" has no value`);return u.value.code},i,s)}_reduceValues(e,i,s={},u){let d=Xt.nil;for(let m in e){let y=e[m];if(!y)continue;let E=s[m]=s[m]||new Map;y.forEach(b=>{if(E.has(b))return;E.set(b,Ts.Started);let w=i(b);if(w){let v=this.opts.es5?Zt.varKinds.var:Zt.varKinds.const;d=(0,Xt._)`${d}${v} ${b} = ${w};${this.opts._n}`}else if(w=u?.(b))d=(0,Xt._)`${d}${w}${this.opts._n}`;else throw new Q0(b);E.set(b,Ts.Completed)})}return d}};Zt.ValueScope=L0});var Ge=pe(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.or=Je.and=Je.not=Je.CodeGen=Je.operators=Je.varKinds=Je.ValueScopeName=Je.ValueScope=Je.Scope=Je.Name=Je.regexpCode=Je.stringify=Je.getProperty=Je.nil=Je.strConcat=Je.str=Je._=void 0;var Ze=po(),EA=q0(),Ir=po();Object.defineProperty(Je,"_",{enumerable:!0,get:function(){return Ir._}});Object.defineProperty(Je,"str",{enumerable:!0,get:function(){return Ir.str}});Object.defineProperty(Je,"strConcat",{enumerable:!0,get:functi