);
});
@@ -4208,7 +4209,8 @@ class SendMessage extends React.PureComponent {
/* This is just a static page to display when no conversation is selected. */
class LogoView extends React.PureComponent {
render() {
- var version = Tinode.getVersion() + " build " + document.lastModified;
+ var version = APP_NAME + " (" + Tinode.getLibrary() + "-" +
+ (new Date(document.lastModified)).toISOString() + ")";
return (
@@ -4967,8 +4969,6 @@ class TinodeWeb extends React.Component {
// New topic was creted, here is the new topic name.
handleNewTopicCreated(oldName, newName) {
- console.log("handleNewTopicCreated", oldName, newName);
-
if (this.state.topicSelected == oldName && oldName != newName) {
// If the current URl contains the old topic name, replace it with new.
// Update the name of the selected topic first so the navigator doen't clear
diff --git a/umd/index.dev.js b/umd/index.dev.js
index da188a44..7c20f554 100644
--- a/umd/index.dev.js
+++ b/umd/index.dev.js
@@ -20222,7 +20222,7 @@ if (process.env.NODE_ENV === 'production') {
}).call(this,require('_process'))
},{"./cjs/react.development.js":21,"./cjs/react.production.min.js":22,"_process":27}],24:[function(require,module,exports){
(function (global){
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Tinode=e()}}(function(){var e;const t=[{name:"ST",start:/(?:^|\W)(\*)[^\s*]/,end:/[^\s*](\*)(?=$|\W)/},{name:"EM",start:/(?:^|[\W_])(_)[^\s_]/,end:/[^\s_](_)(?=$|[\W_])/},{name:"DL",start:/(?:^|\W)(~)[^\s~]/,end:/[^\s~](~)(?=$|\W)/},{name:"CO",start:/(?:^|\W)(`)[^`]/,end:/[^`](`)(?=$|\W)/}],n=[{name:"LN",dataName:"url",pack:function(e){return/^[a-z]+:\/\//i.test(e)||(e="http://"+e),{url:e}},re:/(https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/g},{name:"MN",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B@(\w\w+)/g},{name:"HT",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B#(\w\w+)/g}],s={ST:{name:"b",isVoid:!1},EM:{name:"i",isVoid:!1},DL:{name:"del",isVoid:!1},CO:{name:"tt",isVoid:!1},BR:{name:"br",isVoid:!0},LN:{name:"a",isVoid:!1},MN:{name:"a",isVoid:!1},HT:{name:"a",isVoid:!1},IM:{name:"img",isVoid:!0}};function i(e,t){var n;try{n=atob(e)}catch(e){console.log("Drafty: failed to decode base64-encoded object",e.message),n=atob("")}for(var s=n.length,i=new ArrayBuffer(s),r=new Uint8Array(i),a=0;a"},close:function(){return""}},EM:{open:function(){return""},close:function(){return""}},DL:{open:function(){return""},close:function(){return""}},CO:{open:function(){return""},close:function(){return""}},BR:{open:function(){return""},close:function(){return" "}},LN:{open:function(e){return''},close:function(e){return""},props:function(e){return{href:e.url,target:"_blank"}}},MN:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},HT:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},IM:{open:function(e){var t=i(e.val,e.mime),n=e.ref?e.ref:t,s=(e.name?'':"")+'';return console.log("open: "+s),s},close:function(e){return e.name?"":""},props:function(e){return{src:i(e.val,e.mime),title:e.name,"data-width":e.width,"data-height":e.height,"data-name":e.name,"data-size":.75*e.val.length|0,"data-mime":e.mime}}}},a=function(){};a.parse=function(e){if("string"!=typeof e)return null;var s=e.split(/\r?\n/),i=[],r={},a=[];s.map(function(e){var s,o,c=[];if(t.map(function(t){c=c.concat(function(e,t,n,s){for(var i=[],r=0,a=e.slice(0);a.length>0;){var o=t.exec(a);if(null==o)break;var c=o.index+o[0].lastIndexOf(o[1]);a=a.slice(c+1),r=(c+=r)+1;var u=n?n.exec(a):null;if(null==u)break;var h=u.index+u[0].indexOf(u[1]);a=a.slice(h+1),r=(h+=r)+1,i.push({text:e.slice(c+1,h),children:[],start:c,end:h,type:s})}return i}(e,t.start,t.end,t.name))}),0==c.length)o={txt:e};else{c.sort(function(e,t){return e.start-t.start}),c=function e(t){if(0==t.length)return[];for(var n=[t[0]],s=t[0],i=1;is.end?(n.push(t[i]),s=t[i]):t[i].endn&&r.push({text:t.slice(n,o.start)});var c={type:o.type},u=e(t,o.start+1,o.end-1,o.children);u.length>0?c.children=u:c.text=o.text,r.push(c),n=o.end+1}return ni;return i=e.offset+e.len,t})}(o.txt)).length>0){var h=[];for(var l in s){var d=s[l],f=r[d.unique];f||(f=i.length,r[d.unique]=f,i.push({tp:d.type,data:d.data})),h.push({at:d.offset,len:d.len,key:f})}o.ent=h}a.push(o)});var o={txt:""};if(a.length>0){o.txt=a[0].txt,o.fmt=(a[0].fmt||[]).concat(a[0].ent||[]);for(var c=1;c0&&(o.ent=i)}return o},a.insertImage=function(e,t,n,s,i,r,a,o,c){return(e=e||{txt:" "}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:t,len:1,key:e.ent.length}),e.ent.push({tp:"IM",data:{mime:n,val:s,width:i,height:r,name:a,ref:c,size:0|o}}),e},a.attachFile=function(e,t,n,s,i,r){(e=e||{txt:""}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:-1,len:0,key:e.ent.length});let a={tp:"EX",data:{mime:t,val:n,name:s,ref:r,size:0|i}};return r instanceof Promise&&(a.data.ref=r.then(e=>{a.data.ref=e},e=>{})),e.ent.push(a),e},a.UNSAFE_toHTML=function(e){var t,n,s,{txt:i,fmt:a,ent:o}=e,c=[];if(a)for(var u in a){var h,l=a[u],d=l.tp;if(!d){var f=o[l.key];f&&(d=f.tp,h=f.data)}r[d]&&(c.push({idx:l.at+l.len,what:r[d].close(h)}),c.push({idx:l.at,what:r[d].open(h)}))}for(var u in c.sort(function(e,t){return t.idx-e.idx}),c)c[u].what&&(t=i,n=c[u].idx,s=c[u].what,i=t.slice(0,n)+s+t.slice(n));return i},a.format=function(e,t,n){var{txt:i,fmt:r,ent:a}=e;if(i=i||"",!r)return[i];var o=[].concat(r);return o.map(function(e){e.at=e.at||0,e.len=e.len||0}),o.sort(function(e,t){return e.at-t.at==0?t.len-e.len:e.at-t.at}),o=o.map(function(e){var t,n=e.tp;return n||(e.key=e.key||0,t=a[e.key].data,n=a[e.key].tp),{tp:n,data:t,at:e.at,len:e.len}}),function e(t,n,i,r,a,o){for(var c=[],u=0;u0)for(var t in e.ent)if("EX"==e.ent[t].tp)return!0;return!1},a.attachments=function(e,t,n){if(e.ent&&e.ent.length>0)for(var s in e.ent)"EX"==e.ent[s].tp&&t.call(n,e.ent[s].data,s)},a.getDownloadUrl=function(e){let t=null;return e.val?t=i(e.val,e.mime):"string"==typeof e.ref&&(t=e.ref),t},a.isUploading=function(e){return e.ref instanceof Promise},a.getPreviewUrl=function(e){return e.val?i(e.val,e.mime):null},a.getEntitySize=function(e){return e.size?e.size:e.val?.75*e.val.length|0:0},a.getEntityMimeType=function(e){return e.mime||"text/plain"},a.tagName=function(e){return s[e]?s[e].name:void 0},a.attrValue=function(e,t){if(t&&r[e])return r[e].props(t)},a.getContentType=function(){return"text/x-drafty"},e=a;const o="0";function c(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function u(e,t,n){if(null==t)return e;if("object"!=typeof t)return t||e;if(t instanceof Date)return t;if(t instanceof v)return new v(t);if(t instanceof Array)return t.length>0?t:e;for(var s in e||(e=t.constructor()),t)!t.hasOwnProperty(s)||!t[s]&&!1!==t[s]||n&&n[s]||"_generated"==s||(e[s]=u(e[s],t[s]));return e}function h(e,t,n,s){return e[t]=u(e[t],n,s),e[t]}function l(){var e=null;if("withCredentials"in new XMLHttpRequest)e=new XMLHttpRequest;else{if("undefined"==typeof XDomainRequest)throw new Error("browser not supported");e=new XDomainRequest}return e}function d(e,t){if("ts"===e&&"string"==typeof t&&t.length>=20&&t.length<=24){var n=new Date(t);if(n)return n}else if("acs"===e&&"object"==typeof t)return new v(t);return t}function f(e,t){return"string"==typeof t&&t.length>128?"<"+t.length+", bytes: "+t.substring(0,12)+"..."+t.substring(t.length-12)+">":function(e,t){if(t instanceof Date)t=function(e){if(e&&0!=e.getTime()){var t=e.getUTCMilliseconds();return e.getUTCFullYear()+"-"+n(e.getUTCMonth()+1)+"-"+n(e.getUTCDate())+"T"+n(e.getUTCHours())+":"+n(e.getUTCMinutes())+":"+n(e.getUTCSeconds())+(t?"."+n(t,3):"")+"Z"}function n(e,t){return"0".repeat((t=t||2)-(""+e).length)+e}}(t);else if(null==t||!1===t||Array.isArray(t)&&0==t.length||"object"==typeof t&&0===Object.keys(t).length)return;return t}(0,t)}function p(e,t,n){var s=null;return"http"!==t&&"https"!==t&&"ws"!==t&&"wss"!==t||(s=t+"://","/"!==(s+=e).charAt(s.length-1)&&(s+="/"),s+="v"+o+"/channels","http"!==t&&"https"!==t||(s+="/lp"),s+="?apikey="+n),s}var g=function(e,t,n,s,i){let r=e,a=s,o=t;var c=i;const u=2e3,h=10,f=.3;let g=null,_=0,m=!1,v=e=>{this.logger&&this.logger(e)};function b(e){var t=null;e.connect=function(n){return t&&1===t.readyState?Promise.resolve():(n&&(r=n),new Promise(function(n,s){var i=p(r,a?"wss":"ws",o);v("Connecting to: "+i);var l=new WebSocket(i);l.onopen=function(t){m=!1,e.onOpen&&e.onOpen(),n(),c&&(window.clearTimeout(g),g=null,_=0)},l.onclose=function(n){t=null,e.onDisconnect&&e.onDisconnect(null),!m&&c&&function(){clearTimeout(g);var e=u*(Math.pow(2,_)*(1+f*Math.random()));_=_>=h?_:_+1,g=setTimeout(()=>{v("Reconnecting, iter="+_+", timeout="+e),m||this.connect().catch(function(){})},e)}.call(e)},l.onerror=function(e){s(e)},l.onmessage=function(t){e.onMessage&&e.onMessage(t.data)},t=l}))},e.disconnect=function(){t&&(m=!0,t.close()),t=null},e.sendText=function(e){if(!t||t.readyState!=t.OPEN)throw new Error("Websocket is not connected");t.send(e)},e.isConnected=function(){return t&&1===t.readyState}}function w(e){var t=null,n=null,s=null;e.connect=function(s){return s&&(r=s),new Promise(function(s,i){var c=p(r,a?"https":"http",o);v("Connecting to: "+c),(n=function n(s,i,r){var a=l();return a.onreadystatechange=function(o){if(4==a.readyState)if(201==a.status){var c=JSON.parse(a.responseText,d);a.responseText,t=s+"&sid="+c.ctrl.params.sid,(a=n(t)).send(null),e.onOpen&&e.onOpen(),i&&i()}else 200==a.status?(e.onMessage&&e.onMessage(a.responseText),(a=n(t)).send(null)):(r&&r(a.responseText),e.onMessage&&e.onMessage(a.responseText),e.onDisconnect&&e.onDisconnect(new Error(a.status+" "+a.responseText)))},a.open("GET",s,!0),a}(c,s,i)).send(null)}).catch(function(){})},e.disconnect=function(){s&&(s.abort(),s=null),n&&(n.abort(),n=null),e.onDisconnect&&e.onDisconnect(null),t=null},e.sendText=function(e){var n,i;if(n=t,(i=l()).onreadystatechange=function(e){if(4==i.readyState&&i.status>=400)throw new Error("LP sender failed, "+i.status)},i.open("POST",n,!0),!(s=i)||1!=s.readyState)throw new Error("Long poller failed to connect");s.send(e)},e.isConnected=function(){return n&&!0}}"lp"===n?w(this):"ws"===n?b(this):"object"==typeof window&&window.WebSocket?b(this):w(this),this.onMessage=void 0,this.onDisconnect=void 0,this.onOpen=void 0,this.logger=void 0},_=function(e,t,n,s,i){this._appName=e||"Undefined",this._apiKey=n,this._browser="",this._platform="undefined","undefined"!=typeof navigator&&(this._browser=function(e){var t,n=(e=(e||"").replace(" (KHTML, like Gecko)","")).match(/(AppleWebKit\/[.\d]+)/i);if(n){for(var s=["chrome","safari","mobile","version"],i=e.substr(n.index+n[0].length).split(" "),r=[],a=0;a0?r[0][0]+"/"+r[0][1]:n[1]}else t=/trident/i.test(e)?(n=/(?:\brv[ :]+([.\d]+))|(?:\bMSIE ([.\d]+))/g.exec(e))?"MSIE/"+(n[1]||n[2]):"MSIE/?":/firefox/i.test(e)?(n=/Firefox\/([.\d]+)/g.exec(e))?"Firefox/"+n[1]:"Firefox/?":/presto/i.test(e)?(n=/Opera\/([.\d]+)/g.exec(e))?"Opera/"+n[1]:"Opera/?":(n=/([\w.]+)\/([.\d]+)/.exec(e))?n[1]+"/"+n[2]:(n=e.split(" "))[0];if((n=t.split("/")).length>1){var c=n[1].split(".");t=n[0]+"/"+c[0]+(c[1]?"."+c[1]:"")}return t}(navigator.userAgent),this._platform=navigator.platform),this._loggingEnabled=!1,this._trimLongStrings=!1,this._myUID=null,this._authenticated=!1,this._login=null,this._authToken=null,this._inPacketCount=0,this._messageId=Math.floor(65535*Math.random()+65535),this._serverInfo=null,this._pendingPromises={},this._connection=new g(t,n,s,i,!0),this.logger=(e=>{if(this._loggingEnabled){var t=new Date,n=("0"+t.getUTCHours()).slice(-2)+":"+("0"+t.getUTCMinutes()).slice(-2)+":"+("0"+t.getUTCSeconds()).slice(-2)+":"+("0"+t.getUTCMilliseconds()).slice(-3);console.log("["+n+"] "+e)}}),this._connection.logger=this.logger,this._cache={};let r=this.cachePut=((e,t,n)=>{this._cache[e+":"+t]=n}),a=this.cacheGet=((e,t)=>this._cache[e+":"+t]),o=this.cacheDel=((e,t)=>{delete this._cache[e+":"+t]}),c=this.cacheMap=((e,t)=>{for(var n in this._cache)if(e(this._cache[n],n,t))break});this.attachCacheToTopic=(e=>{e._tinode=this,e._cacheGetUser=(e=>{var t=a("user",e);if(t)return{user:e,public:u({},t)}}),e._cachePutUser=((e,t)=>r("user",e,u({},t.public))),e._cacheDelUser=(e=>o("user",e)),e._cachePutSelf=(()=>r("topic",e.name,e)),e._cacheDelSelf=(()=>o("topic",e.name))});let h=(e,t,n,s)=>{var i=this._pendingPromises[e];i&&(delete this._pendingPromises[e],t>=200&&t<400?i.resolve&&i.resolve(n):i.reject&&i.reject(new Error("Error: "+s+" ("+t+")")))},l=e=>{var t=null;return e&&(t=new Promise((t,n)=>{this._pendingPromises[e]={resolve:t,reject:n}})),t},p=this.getNextUniqueId=(()=>0!=this._messageId?""+this._messageId++:void 0),_=()=>this._appName+" ("+(this._browser?this._browser+"; ":"")+this._platform+"); tinodejs/0.15";this.initPacket=((e,t)=>{switch(e){case"hi":return{hi:{id:p(),ver:"0.15",ua:_()}};case"acc":return{acc:{id:p(),user:null,scheme:null,secret:null,login:!1,tags:null,desc:{},cred:{}}};case"login":return{login:{id:p(),scheme:null,secret:null}};case"sub":return{sub:{id:p(),topic:t,set:{},get:{}}};case"leave":return{leave:{id:p(),topic:t,unsub:!1}};case"pub":return{pub:{id:p(),topic:t,noecho:!1,head:null,content:{}}};case"get":return{get:{id:p(),topic:t,what:null,desc:{},sub:{},data:{}}};case"set":return{set:{id:p(),topic:t,desc:{},sub:{},tags:[]}};case"del":return{del:{id:p(),topic:t,what:null,delseq:null,user:null,hard:!1}};case"note":return{note:{topic:t,what:null,seq:void 0}};default:throw new Error("Unknown packet type requested: "+e)}}),this.send=((e,t)=>{let n;t&&(n=l(t)),e=function e(t){return Object.keys(t).forEach(function(n){"_"==n[0]?delete t[n]:t[n]?Array.isArray(t[n])&&0==t[n].length?delete t[n]:t[n]?"object"!=typeof t[n]||t[n]instanceof Date||(e(t[n]),0==Object.getOwnPropertyNames(t[n]).length&&delete t[n]):delete t[n]:delete t[n]}),t}(e);var s=JSON.stringify(e);return this.logger("out: "+(this._trimLongStrings?JSON.stringify(e,f):s)),this._connection.sendText(s),n}),this.loginSuccessful=(e=>{this._myUID=e.params.user,this._authenticated=e&&e.code>=200&&e.code<300,e.params&&e.params.token&&e.params.expires?this._authToken={token:e.params.token,expires:new Date(e.params.expires)}:this._authToken=null,this.onLogin&&this.onLogin(e.code,e.text)}),this._connection.onMessage=(e=>{if(e){this._inPacketCount++,this.onRawMessage&&this.onRawMessage(e);var t=JSON.parse(e,d);if(t)if(this.logger("in: "+(this._trimLongStrings?JSON.stringify(t,f):e)),this.onMessage&&this.onMessage(t),t.ctrl)this.onCtrlMessage&&this.onCtrlMessage(t.ctrl),t.ctrl.id&&h(t.ctrl.id,t.ctrl.code,t.ctrl,t.ctrl.text),t.ctrl.params&&"data"==t.ctrl.params.what&&(n=a("topic",t.ctrl.topic))&&n._allMessagesReceived(t.ctrl.params.count);else if(t.meta)(n=a("topic",t.meta.topic))&&n._routeMeta(t.meta),this.onMetaMessage&&this.onMetaMessage(t.meta);else if(t.data)(n=a("topic",t.data.topic))&&n._routeData(t.data),this.onDataMessage&&this.onDataMessage(t.data);else if(t.pres)(n=a("topic",t.pres.topic))&&n._routePres(t.pres),this.onPresMessage&&this.onPresMessage(t.pres);else if(t.info){var n;(n=a("topic",t.info.topic))&&n._routeInfo(t.info),this.onInfoMessage&&this.onInfoMessage(t.info)}else this.logger("ERROR: Unknown packet received.");else this.logger("in: "+e),this.logger("ERROR: failed to parse data")}}),this._connection.onOpen=(()=>{this.hello()}),this._connection.onDisconnect=(e=>{this._inPacketCount=0,this._serverInfo=null,this._authenticated=!1,c((e,t)=>{0===t.lastIndexOf("topic:",0)&&e._resetSub()}),this.onDisconnect&&this.onDisconnect(e)})};_.credential=function(e,t,n,s){return"object"==typeof e&&({val:t,params:n,resp:s,meth:e}=e),e&&(t||s)?[{meth:e,val:t,resp:s,params:n}]:null},_.topicType=function(e){return{me:"me",fnd:"fnd",grp:"grp",new:"grp",usr:"p2p"}["string"==typeof e?e.substring(0,3):"xxx"]},_.isNewGroupTopicName=function(e){return"string"==typeof e&&"new"==e.substring(0,3)},_.getVersion=function(){return"0.15"},_.MESSAGE_STATUS_NONE=0,_.MESSAGE_STATUS_QUEUED=1,_.MESSAGE_STATUS_SENDING=2,_.MESSAGE_STATUS_SENT=3,_.MESSAGE_STATUS_RECEIVED=4,_.MESSAGE_STATUS_READ=5,_.MESSAGE_STATUS_TO_ME=6,_.DEL_CHAR="\u2421",_.prototype={connect:function(e){return this._connection.connect(e)},disconnect:function(){this._connection&&this._connection.disconnect()},isConnected:function(){return this._connection&&this._connection.isConnected()},isAuthenticated:function(){return this._authenticated},account:function(e,t,n,s,i){var r=this.initPacket("acc");return r.acc.user=e,r.acc.scheme=t,r.acc.secret=n,r.acc.login=s,i&&(r.acc.desc.defacs=i.defacs,r.acc.desc.public=i.public,r.acc.desc.private=i.private,r.acc.tags=i.tags,r.acc.cred=i.cred),this.send(r,r.acc.id)},createAccount:function(e,t,n,s){var i=this.account("new",e,t,n,s);return n&&(i=i.then(e=>(this.loginSuccessful(e),e))),i},createAccountBasic:function(e,t,n){return e=e||"",t=t||"",this.createAccount("basic",c(e+":"+t),!0,n)},updateAccountBasic:function(e,t,n){return t=t||"",n=n||"",this.account(e,"basic",c(t+":"+n),!1,null)},hello:function(){var e=this.initPacket("hi");return this.send(e,e.hi.id).then(e=>(e.params&&(this._serverInfo=e.params),this.onConnect&&this.onConnect(),e)).catch(e=>{this.onDisconnect&&this.onDisconnect(e)})},login:function(e,t,n){var s=this.initPacket("login");return s.login.scheme=e,s.login.secret=t,s.login.cred=n,this.send(s,s.login.id).then(e=>(this.loginSuccessful(e),e))},loginBasic:function(e,t,n){return this.login("basic",c(e+":"+t),n).then(t=>(this._login=e,t))},loginToken:function(e,t){return this.login("token",e,t)},getAuthToken:function(){return this._authToken&&this._authToken.expires.getTime()>Date.now()?this._authToken:(this._authToken=null,null)},setAuthToken:function(e){this._authToken=e},subscribe:function(e,t,n){var s=this.initPacket("sub",e);return e||(e="new"),s.sub.get=t,n&&(n.sub&&(s.sub.set.sub=n.sub),_.isNewGroupTopicName(e)&&n.desc&&(s.sub.set.desc=n.desc),n.tags&&(s.sub.set.tags=n.tags)),this.send(s,s.sub.id)},leave:function(e,t){var n=this.initPacket("leave",e);return n.leave.unsub=t,this.send(n,n.leave.id)},createMessage:function(e,t,n){let s=this.initPacket("pub",e),i="string"==typeof t?Drafty.parse(t):t;return i&&!Drafty.isPlainText(i)&&(s.pub.head={mime:Drafty.getContentType()},t=i),s.pub.noecho=n,s.pub.content=t,s.pub},publish:function(e,t,n){return this.publishMessage(this.createMessage(e,t,n))},publishMessage:function(e){return(e=Object.assign({},e)).seq=void 0,e.from=void 0,e.ts=void 0,this.send({pub:e},e.id)},getMeta:function(e,t){var n=this.initPacket("get",e);return n.get=u(n.get,t),this.send(n,n.get.id)},setMeta:function(e,t){var n=this.initPacket("set",e),s=[];return t&&["desc","sub","tags"].map(function(e){t.hasOwnProperty(e)&&(s.push(e),n.set[e]=t[e])}),0==s.length?Promise.reject(new Error("Invalid {set} parameters")):this.send(n,n.set.id)},delMessages:function(e,t,n){var s=this.initPacket("del",e);return s.del.what="msg",s.del.delseq=t,s.del.hard=n,this.send(s,s.del.id)},delTopic:function(e){var t=this.initPacket("del",e);return t.del.what="topic",this.send(t,t.del.id).then(t=>(this.cacheDel("topic",e),this.ctrl))},delSubscription:function(e,t){var n=this.initPacket("del",e);return n.del.what="sub",n.del.user=t,this.send(n,n.del.id)},note:function(e,t,n){if(n<=0||n>=268435455)throw new Error("Invalid message id "+n);var s=this.initPacket("note",e);s.note.what=t,s.note.seq=n,this.send(s)},noteKeyPress:function(e){var t=this.initPacket("note",e);t.note.what="kp",this.send(t)},getTopic:function(e){var t=this.cacheGet("topic",e);return!t&&e&&(t="me"==e?new w:"fnd"==e?new M:new b(e),this.cachePut("topic",e,t),this.attachCacheToTopic(t)),t},newTopic:function(e){var t=new b("new",e);return this.attachCacheToTopic(t),t},newGroupTopicName:function(){return"new"+this.getNextUniqueId()},newTopicWith:function(e,t){var n=new b(e,t);return this.attachCacheToTopic(n),n},getMeTopic:function(){return this.getTopic("me")},getFndTopic:function(){return this.getTopic("fnd")},getLargeFileHelper:function(){return new S(this)},getCurrentUserID:function(){return this._myUID},getCurrentLogin:function(){return this._login},getServerInfo:function(){return this._serverInfo},enableLogging:function(e,t){this._loggingEnabled=e,this._trimLongStrings=t},isTopicOnline:function(e){var t=this.getMeTopic(),n=t&&t.getContact(e);return n&&n.online},wantAkn:function(e){this._messageId=e?Math.floor(16777215*Math.random()+16777215):0},onWebsocketOpen:void 0,onConnect:void 0,onDisconnect:void 0,onLogin:void 0,onCtrlMessage:void 0,onDataMessage:void 0,onPresMessage:void 0,onMessage:void 0,onRawMessage:void 0};var m=function(e){this.topic=e;var t=e._tinode.getMeTopic();this.contact=t&&t.getContact(e.name),this.what={}};m.prototype={_get_ims:function(){let e=this.contact&&this.contact.updated,t=this.topic._lastDescUpdate||0;return e>t?e:t},withData:function(e,t,n){return this.what.data={since:e,before:t,limit:n},this},withLaterData:function(e){return this.withData(this.topic._maxSeq>0?this.topic._maxSeq+1:void 0,void 0,e)},withEarlierData:function(e){return this.withData(void 0,this.topic._minSeq>0?this.topic._minSeq:void 0,e)},withDesc:function(e){return this.what.desc={ims:e},this},withLaterDesc:function(){return this.withDesc(this._get_ims())},withSub:function(e,t,n){var s={ims:e,limit:t};return"me"==this.topic.getType()?s.topic=n:s.user=n,this.what.sub=s,this},withOneSub:function(e,t){return this.withSub(e,void 0,t)},withLaterOneSub:function(e){return this.withOneSub(this.topic._lastSubsUpdate,e)},withLaterSub:function(e){return this.withSub("p2p"==this.topic.getType()?this._get_ims():this.topic._lastSubsUpdate,e)},withTags:function(){return this.what.tags=!0,this},withDel:function(e,t){return(e||t)&&(this.what.del={since:e,limit:t}),this},withLaterDel:function(e){return this.withDel(this.topic._maxSeq>0?this.topic._maxDel+1:void 0,e)},build:function(){var e={},t=[],n=this;return["data","sub","desc","tags","del"].map(function(s){n.what.hasOwnProperty(s)&&(t.push(s),Object.getOwnPropertyNames(n.what[s]).length>0&&(e[s]=n.what[s]))}),t.length>0?e.what=t.join(" "):e=void 0,e}};var v=function(e){e&&(this.given="number"==typeof e.given?e.given:v.decode(e.given),this.want="number"==typeof e.want?e.want:v.decode(e.want),this.mode=e.mode?"number"==typeof e.mode?e.mode:v.decode(e.mode):this.given&this.want)};v._NONE=0,v._JOIN=1,v._READ=2,v._WRITE=4,v._PRES=8,v._APPROVE=16,v._SHARE=32,v._DELETE=64,v._OWNER=128,v._BITMASK=v._JOIN|v._READ|v._WRITE|v._PRES|v._APPROVE|v._SHARE|v._DELETE|v._OWNER,v._INVALID=1048576,v.decode=function(e){if(!e)return null;if("number"==typeof e)return e&v._BITMASK;if("N"===e||"n"===e)return v._NONE;for(var t={J:v._JOIN,R:v._READ,W:v._WRITE,P:v._PRES,A:v._APPROVE,S:v._SHARE,D:v._DELETE,O:v._OWNER},n=v._NONE,s=0;s0)){c=!0;break}r=a-1}return c?a:s?-1:o<0?a+1:a}function s(e,t){var s=n(e,t,!1);return t.splice(s,0,e),t}return e=e||function(e,t){return e===t?0:e0)return n[0]},delRange:function(e,n){return t.splice(e,n-e)},size:function(){return t.length},reset:function(e){t=[]},forEach:function(e,n,s,i){n|=0,s=s||t.length;for(var r=n;r{if(e.code>=300)return e;if(this._subscribed=!0,this.acs=e.params&&e.params.acs?e.params.acs:this.acs,this._new){this._new=!1,this.name=e.topic,this.created=e.ts,this.updated=e.ts,this.touched=e.ts,this._cachePutSelf();var n=this._tinode.getMeTopic();n&&n._processMetaSub([{_generated:!0,topic:this.name,created:e.ts,updated:e.ts,touched:e.ts,acs:this.acs}]),t&&t.desc&&(t.desc._generated=!0,this._processMetaDesc(t.desc))}return e})},publish:function(e,t){return this.publishMessage(this.createMessage(e,t))},createMessage:function(e,t){return this._tinode.createMessage(this.name,e,t)},publishMessage:function(e){if(!this._subscribed)return Promise.reject(new Error("Cannot publish on inactive topic"));if(Drafty.hasAttachments(e.content)){let t=[];Drafty.attachments(e.content,e=>{t.push(e.ref)}),e.head.attachments=t}return e._sending=!0,this._tinode.publishMessage(e)},publishDraft:function(e,t){return t||this._subscribed?(e.seq=this._getQueuedSeqId(),e._generated=!0,e.ts=new Date,e.from=this._tinode.getCurrentUserID(),e.noecho=!0,this._messages.put(e),this.onData&&this.onData(e),(t||Promise.resolve()).then(()=>e._cancelled?{code:300,text:"cancelled"}:this.publishMessage(e).then(t=>(e._sending=!1,e.seq=t.params.seq,e.ts=t.ts,this._routeData(e),t)),t=>{e._sending=!1,this._messages.delAt(this._messages.find(e)),this.onData&&this.onData()})):Promise.reject(new Error("Cannot publish on inactive topic"))},leave:function(e){return this._subscribed||e?this._tinode.leave(this.name,e).then(t=>(this._resetSub(),e&&this._gone(),t)):Promise.reject(new Error("Cannot leave inactive topic"))},getMeta:function(e){return this._subscribed?this._tinode.getMeta(this.name,e):Promise.reject(new Error("Cannot query inactive topic"))},getMessagesPage:function(e,t){var n=this.startMetaQuery();t?n.withLaterData(e):n.withEarlierData(e);var s=this.getMeta(n.build());return t||(s=s.then(e=>{e&&e.params&&!e.params.count&&(this._noEarlierMsgs=!0)})),s},setMeta:function(e){return this._subscribed?(e.tags&&(e.tags=function(e){var t=[];if(Array.isArray(e)){for(var n=0,s=e.length;n1&&t.push(i)}t.sort().filter(function(e,t,n){return!t||e!=n[t-1]})}return 0==t.length&&t.push(_.DEL_CHAR),t}(e.tags)),this._tinode.setMeta(this.name,e).then(t=>t&&t.code>=300?t:(e.sub&&(t.params&&t.params.acs&&(e.sub.acs=t.params.acs,e.sub.updated=t.ts),e.sub.user||(e.sub.user=this._tinode.getCurrentUserID(),e.desc||(e.desc={})),e.sub._generated=!0,this._processMetaSub([e.sub])),e.desc&&(t.params&&t.params.acs&&(e.desc.acs=t.params.acs,e.desc.updated=t.ts),this._processMetaDesc(e.desc)),e.tags&&this._processMetaTags(e.tags),t))):Promise.reject(new Error("Cannot update inactive topic"))},invite:function(e,t){return this.setMeta({sub:{user:e,mode:t}})},delMessages:function(e,t){if(!this._subscribed)return Promise.reject(new Error("Cannot delete messages in inactive topic"));e.sort(function(e,t){return e.low=t.hi)});let n,s=e.reduce((e,t)=>(t.low<268435455&&(!t.hi||t.hi<268435455?e.push(t):e.push({low:t.low,hi:this._maxSeq+1})),e),[]);return(n=e.length>0?this._tinode.delMessages(this.name,s,t):Promise.resolve({params:{del:0}})).then(t=>(t.params.del>this._maxDel&&(this._maxDel=t.params.del),e.map(e=>{e.hi?this.flushMessageRange(e.low,e.hi):this.flushMessage(e.low)}),this.onData&&this.onData(),t))},delMessagesAll:function(e){return this.delMessages([{low:1,hi:this._maxSeq+1,_all:!0}],e)},delMessagesList:function(e,t){e.sort((e,t)=>e-t);var n=e.reduce((e,t)=>{if(0==e.length)e.push({low:t});else{let n=e[e.length-1];!n.hi&&t!=n.low+1||t>n.hi?e.push({low:t}):n.hi=n.hi?Math.max(n.hi,t+1):t+1}return e},[]);return this.delMessages(n,t)},delTopic:function(){var e=this;return this._tinode.delTopic(this.name).then(function(t){return e._resetSub(),e._gone(),t})},delSubscription:function(e){return this._subscribed?this._tinode.delSubscription(this.name,e).then(t=>(delete this._users[e],this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._users)),t)):Promise.reject(new Error("Cannot delete subscription in inactive topic"))},note:function(e,t){var n=this._users[this._tinode.getCurrentUserID()];n?((!n[e]||n[e]0)for(var i in this._users){var r=this._users[i];r.user!==s&&r[e]>=t&&n++}return n},msgReadCount:function(e){return this.msgReceiptCount("read",e)},msgRecvCount:function(e){return this.msgReceiptCount("recv",e)},msgHasMoreMessages:function(e){return e?this.seq>this._maxSeq:this._minSeq>1&&!this._noEarlierMsgs},isNewMessage:function(e){return this._maxSeq<=e},flushMessage:function(e){let t=this._messages.find({seq:e});return t>=0?this._messages.delAt(t):void 0},flushMessageRange:function(e,t){let n=this._messages.find({seq:e});return n>=0?this._messages.delRange(n,this._messages.find({seq:t},!0)):[]},cancelSend:function(e){let t=this._messages.find({seq:e});if(t>=0){let e=this._messages.getAt(t);if(1==this.msgStatus(e))return e._cancelled=!0,this._messages.delAt(t),!0}return!1},getType:function(){return _.topicType(this.name)},getAccessMode:function(){return this.acs},getDefaultAccess:function(){return this.defacs},startMetaQuery:function(){return new m(this)},msgStatus:function(e){var t=0;return e.from==this._tinode.getCurrentUserID()?e._sending?t=2:e.seq>=268435455?t=1:this.msgReadCount(e.seq)>0?t=5:this.msgRecvCount(e.seq)>0?t=4:e.seq>0&&(t=3):t=6,t},_routeData:function(e){e.content&&((!this.touched||this.touchedthis._maxSeq&&(this._maxSeq=e.seq),(e.seq0&&(this._lastSubsUpdate=e.ts,this._processMetaSub(e.sub)),e.del&&this._processDelMessages(e.del.clear,e.del.delseq),e.tags&&this._processMetaTags(e.tags),this.onMeta&&this.onMeta(e)},_routePres:function(e){var t;switch(e.what){case"del":this._processDelMessages(e.clear,e.delseq);break;case"on":case"off":(t=this._users[e.src])?t.online="on"==e.what:this._tinode.logger("Presence update for an unknown user",this.name,e.src);break;case"acs":let s="me"==e.src?this._tinode.getCurrentUserID():e.src;if(t=this._users[s])t.acs.updateAll(e.dacs),s==this._tinode.getCurrentUserID()&&this.acs.updateAll(e.dacs),t.acs&&t.acs.mode!=v._NONE||("p2p"==this.getType()&&this.leave(),this._processMetaSub([{user:s,deleted:new Date,_generated:!0}]));else{var n=(new v).updateAll(e.dacs);n&&n.mode!=v._NONE&&((t=this._cacheGetUser(s))?t.acs=n:(t={user:s,acs:n},this.getMeta(this.startMetaQuery().withOneSub(void 0,s).build())),t._generated=!0,t.updated=new Date,this._processMetaSub([t]))}break;default:this._tinode.logger("Ignored presence update",e.what)}this.onPres&&this.onPres(e)},_routeInfo:function(e){if("kp"!==e.what){var t=this._users[e.from];t&&(t[e.what]=e.seq)}this.onInfo&&this.onInfo(e)},_processMetaDesc:function(e,t){if(u(this,e),"string"==typeof this.created&&(this.created=new Date(this.created)),"string"==typeof this.updated&&(this.updated=new Date(this.updated)),"string"==typeof this.touched&&(this.touched=new Date(this.touched)),"me"!==this.name&&!t&&!e._generated){var n=this._tinode.getMeTopic();n&&n._processMetaSub([{_generated:!0,topic:this.name,updated:this.updated,touched:this.touched,acs:this.acs,public:this.public,private:this.private}])}this.onMetaDesc&&this.onMetaDesc(this)},_processMetaSub:function(e){var t=void 0;for(var n in e){var s=e[n];if(s.user){s.updated=new Date(s.updated),s.deleted=s.deleted?new Date(s.deleted):null;var i=null;s.deleted?(delete this._users[s.user],i=s):((i=this._users[s.user])||(i=this._cacheGetUser(s.user)),i=this._updateCachedUser(s.user,s,s._generated)),this.onMetaSub&&this.onMetaSub(i)}else s._generated||(t=s)}t&&this.onMetaDesc&&this.onMetaDesc(t),this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._users))},_processMetaTags:function(e){1==e.length&&e[0]==_.DEL_CHAR&&(e=[]),this._tags=e,this.onTagsUpdated&&this.onTagsUpdated(e)},_processDelMessages:function(e,t){this._maxDel=Math.max(e,this._maxDel),this.clear=Math.max(e,this.clear);var n=this,s=0;Array.isArray(t)&&t.map(function(e){if(e.hi)for(var t=e.low;t0&&this.onData&&this.onData()},_allMessagesReceived:function(e){this.onAllMessagesReceived&&this.onAllMessagesReceived(e)},_resetSub:function(){this._subscribed=!1},_gone:function(){var e=this._tinode.getMeTopic();e&&e._routePres({_generated:!0,what:"gone",topic:"me",src:this.name}),this.onDeleteTopic&&this.onDeleteTopic()},_updateCachedUser:function(e,t,n){var s=this._cacheGetUser(e);return s?s=u(s,t):(n&&this.getMeta(this.startMetaQuery().withLaterOneSub(e).build()),s=u({},t)),this._cachePutUser(e,s),h(this._users,e,s)},_getQueuedSeqId:function(){return this._queuedSeqId++}};var w=function(e){b.call(this,"me",e),this._contacts={},e&&(this.onContactUpdate=e.onContactUpdate)};w.prototype=Object.create(b.prototype,{_processMetaSub:{value:function(e){var t=0;for(var n in e){var s=e[n],i=s.topic;if("fnd"!=i&&"me"!=i){s.updated=new Date(s.updated),s.touched=s.touched?new Date(s.touched):null,s.deleted=s.deleted?new Date(s.deleted):null,s.seq=0|s.seq,s.recv=0|s.recv,s.read=0|s.read,s.unread=s.seq-s.read;var r=null;if(s.deleted)r=s,delete this._contacts[i];else if(s.seen&&s.seen.when&&(s.seen.when=new Date(s.seen.when)),r=h(this._contacts,i,s),"p2p"==_.topicType(i)&&this._cachePutUser(i,r),!s._generated){var a=this._tinode.getTopic(i);a&&a._processMetaDesc(s,!0)}t++,this.onMetaSub&&this.onMetaSub(r)}}t>0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},_routePres:{value:function(e){var t=this._contacts[e.src];if(t){switch(e.what){case"on":t.online=!0;break;case"off":t.online&&(t.online=!1,t.seen?t.seen.when=new Date:t.seen={when:new Date});break;case"msg":t.touched=new Date,t.seq=0|e.seq,t.unread=t.seq-t.read;break;case"upd":this.getMeta(this.startMetaQuery().withLaterOneSub(e.src).build());break;case"acs":t.acs?t.acs.updateAll(e.dacs):t.acs=(new v).updateAll(e.dacs);break;case"ua":t.seen={when:new Date,ua:e.ua};break;case"recv":t.recv=t.recv?Math.max(t.recv,e.seq):0|e.seq;break;case"read":t.read=t.read?Math.max(t.read,e.seq):0|e.seq,t.unread=t.seq-t.read;break;case"gone":delete this._contacts[e.src]}this.onContactUpdate&&this.onContactUpdate(e.what,t)}else if("acs"==e.what){var n=new v(e.dacs);if(!n||n.mode==v._INVALID)return void this._tinode.logger("Invalid access mode update",e.src,e.dacs);if(n.mode==v._NONE)return void this._tinode.logger("Removing non-existent subscription",e.src,e.dacs);this.getMeta(this.startMetaQuery().withOneSub(void 0,e.src).build()),this._contacts[e.src]={topic:e.src,online:!1,acs:n}}this.onPres&&this.onPres(e)},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'me' is not supported"))},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var s in this._contacts)n.call(t,this._contacts[s],s,this._contacts)},enumerable:!0,configurable:!0,writable:!0},setMsgReadRecv:{value:function(e,t,n,s){var i,r=this._contacts[e],a=!1;r&&(n|=0,"recv"===t?(i=r.recv,r.recv=r.recv?Math.max(r.recv,n):n,a=i!=r.recv):"read"===t?(i=r.read,r.read=r.read?Math.max(r.read,n):n,r.unread=r.seq-r.read,a=i!=r.read,r.recv0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'fnd' is not supported"))},enumerable:!0,configurable:!0,writable:!1},setMeta:{value:function(e){var t=this;return Object.getPrototypeOf(M.prototype).setMeta.call(this,e).then(function(){Object.keys(t._contacts).length>0&&(t._contacts={},t.onSubsUpdated&&t.onSubsUpdated([]))})},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var s in this._contacts)n.call(t,this._contacts[s],s,this._contacts)},enumerable:!0,configurable:!0,writable:!0}}),M.prototype.constructor=M;var S=function(e){this._tinode=e,this._apiKey=e._apiKey,this._authToken=e.getAuthToken(),this._msgId=e.getNextUniqueId(),this.xhr=l(),this.toResolve=null,this.toReject=null,this.onProgress=null,this.onSuccess=null,this.onFailure=null};S.prototype={upload:function(e,t,n,s){if(!this._authToken)throw new Error("Must authenticate first");var i=this;this.xhr.open("POST","/v"+o+"/file/u/",!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token);var r=new Promise((e,t)=>{this.toResolve=e,this.toReject=t});this.onProgress=t,this.onSuccess=n,this.onFailure=s,this.xhr.upload.onprogress=function(e){e.lengthComputable&&i.onProgress&&i.onProgress(e.loaded/e.total)},this.xhr.onload=function(){var e;try{e=JSON.parse(this.response,d)}catch(e){i._tinode.logger("Invalid server response in LargeFileHelper",this.response)}this.status>=200&&this.status<300?(i.toResolve&&i.toResolve(e.ctrl.params.url),i.onSuccess&&i.onSuccess(e.ctrl)):this.status>=400?(i.toReject&&i.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")")),i.onFailure&&i.onFailure(e.ctrl)):i._tinode.logger("Unexpected server response status",this.status,this.response)},this.xhr.onerror=function(e){i.toReject&&i.toReject(new Error("failed")),i.onFailure&&i.onFailure(null)},this.xhr.onabort=function(e){i.toReject&&i.toReject(new Error("upload cancelled by user")),i.onFailure&&i.onFailure(null)};try{var a=new FormData;a.append("file",e),a.set("id",this._msgId),this.xhr.send(a)}catch(e){this.toReject&&this.toReject(e),this.onFailure&&this.onFailure(null)}return r},download:function(e,t,n,s){if(/^(?:(?:[a-z]+:)?\/\/)/i.test(e))throw new Error("The URL '"+e+"' must be relative, not absolute");if(!this._authToken)throw new Error("Must authenticate first");var i=this;this.xhr.open("GET",e,!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token),this.xhr.responseType="blob",this.onProgress=s,this.xhr.onprogress=function(e){i.onProgress&&i.onProgress(e.loaded)};var r=new Promise((e,t)=>{this.toResolve=e,this.toReject=t});this.xhr.onload=function(){if(200==this.status){var e=document.createElement("a");e.href=window.URL.createObjectURL(new Blob([this.response],{type:n})),e.style.display="none",e.setAttribute("download",t),document.body.appendChild(e),e.click(),document.body.removeChild(e),window.URL.revokeObjectURL(e.href),i.toResolve&&i.toResolve()}else if(this.status>=400&&i.toReject){var s=new FileReader;s.onload=function(){try{var e=JSON.parse(this.result,d);i.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")"))}catch(e){i._tinode.logger("Invalid server response in LargeFileHelper",this.result),i.toReject(e)}},s.readAsText(this.response)}},this.xhr.onerror=function(e){i.toReject&&i.toReject(new Error("failed"))},this.xhr.onabort=function(){i.toReject&&i.toReject(null)};try{this.xhr.send()}catch(e){this.toReject&&this.toReject(e)}return r},cancel:function(){this.xhr&&this.xhr.readyState<4&&this.xhr.abort()},getId:function(){return this._msgId}};var T=function(e,t){this.status=T.STATUS_NONE,this.topic=e,this.content=t};T.STATUS_NONE=0,T.STATUS_QUEUED=1,T.STATUS_SENDING=2,T.STATUS_SENT=3,T.STATUS_RECEIVED=4,T.STATUS_READ=5,T.STATUS_TO_ME=6,T.prototype={toJSON:function(){},fromJSON:function(e){}},T.prototype.constructor=T;var D={};return(D=_).Drafty=e,D});
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Tinode=e()}}(function(){var e={};const t=[{name:"ST",start:/(?:^|\W)(\*)[^\s*]/,end:/[^\s*](\*)(?=$|\W)/},{name:"EM",start:/(?:^|[\W_])(_)[^\s_]/,end:/[^\s_](_)(?=$|[\W_])/},{name:"DL",start:/(?:^|\W)(~)[^\s~]/,end:/[^\s~](~)(?=$|\W)/},{name:"CO",start:/(?:^|\W)(`)[^`]/,end:/[^`](`)(?=$|\W)/}],n=[{name:"LN",dataName:"url",pack:function(e){return/^[a-z]+:\/\//i.test(e)||(e="http://"+e),{url:e}},re:/(https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/g},{name:"MN",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B@(\w\w+)/g},{name:"HT",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B#(\w\w+)/g}],s={ST:{name:"b",isVoid:!1},EM:{name:"i",isVoid:!1},DL:{name:"del",isVoid:!1},CO:{name:"tt",isVoid:!1},BR:{name:"br",isVoid:!0},LN:{name:"a",isVoid:!1},MN:{name:"a",isVoid:!1},HT:{name:"a",isVoid:!1},IM:{name:"img",isVoid:!0}};function i(e,t){var n;try{n=atob(e)}catch(e){console.log("Drafty: failed to decode base64-encoded object",e.message),n=atob("")}for(var s=n.length,i=new ArrayBuffer(s),r=new Uint8Array(i),a=0;a"},close:function(){return""}},EM:{open:function(){return""},close:function(){return""}},DL:{open:function(){return""},close:function(){return""}},CO:{open:function(){return""},close:function(){return""}},BR:{open:function(){return""},close:function(){return" "}},LN:{open:function(e){return''},close:function(e){return""},props:function(e){return{href:e.url,target:"_blank"}}},MN:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},HT:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},IM:{open:function(e){var t=i(e.val,e.mime),n=e.ref?e.ref:t,s=(e.name?'':"")+'';return console.log("open: "+s),s},close:function(e){return e.name?"":""},props:function(e){return{src:i(e.val,e.mime),title:e.name,"data-width":e.width,"data-height":e.height,"data-name":e.name,"data-size":.75*e.val.length|0,"data-mime":e.mime}}}},a=function(){};a.parse=function(e){if("string"!=typeof e)return null;var s=e.split(/\r?\n/),i=[],r={},a=[];s.map(function(e){var s,o,c=[];if(t.map(function(t){c=c.concat(function(e,t,n,s){for(var i=[],r=0,a=e.slice(0);a.length>0;){var o=t.exec(a);if(null==o)break;var c=o.index+o[0].lastIndexOf(o[1]);a=a.slice(c+1),r=(c+=r)+1;var u=n?n.exec(a):null;if(null==u)break;var h=u.index+u[0].indexOf(u[1]);a=a.slice(h+1),r=(h+=r)+1,i.push({text:e.slice(c+1,h),children:[],start:c,end:h,type:s})}return i}(e,t.start,t.end,t.name))}),0==c.length)o={txt:e};else{c.sort(function(e,t){return e.start-t.start}),c=function e(t){if(0==t.length)return[];for(var n=[t[0]],s=t[0],i=1;is.end?(n.push(t[i]),s=t[i]):t[i].endn&&r.push({text:t.slice(n,o.start)});var c={type:o.type},u=e(t,o.start+1,o.end-1,o.children);u.length>0?c.children=u:c.text=o.text,r.push(c),n=o.end+1}return ni;return i=e.offset+e.len,t})}(o.txt)).length>0){var h=[];for(var l in s){var d=s[l],f=r[d.unique];f||(f=i.length,r[d.unique]=f,i.push({tp:d.type,data:d.data})),h.push({at:d.offset,len:d.len,key:f})}o.ent=h}a.push(o)});var o={txt:""};if(a.length>0){o.txt=a[0].txt,o.fmt=(a[0].fmt||[]).concat(a[0].ent||[]);for(var c=1;c0&&(o.ent=i)}return o},a.insertImage=function(e,t,n,s,i,r,a,o,c){return(e=e||{txt:" "}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:t,len:1,key:e.ent.length}),e.ent.push({tp:"IM",data:{mime:n,val:s,width:i,height:r,name:a,ref:c,size:0|o}}),e},a.attachFile=function(e,t,n,s,i,r){(e=e||{txt:""}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:-1,len:0,key:e.ent.length});let a={tp:"EX",data:{mime:t,val:n,name:s,ref:r,size:0|i}};return r instanceof Promise&&(a.data.ref=r.then(e=>{a.data.ref=e},e=>{})),e.ent.push(a),e},a.UNSAFE_toHTML=function(e){var t,n,s,{txt:i,fmt:a,ent:o}=e,c=[];if(a)for(var u in a){var h,l=a[u],d=l.tp;if(!d){var f=o[l.key];f&&(d=f.tp,h=f.data)}r[d]&&(c.push({idx:l.at+l.len,what:r[d].close(h)}),c.push({idx:l.at,what:r[d].open(h)}))}for(var u in c.sort(function(e,t){return t.idx-e.idx}),c)c[u].what&&(t=i,n=c[u].idx,s=c[u].what,i=t.slice(0,n)+s+t.slice(n));return i},a.format=function(e,t,n){var{txt:i,fmt:r,ent:a}=e;if(i=i||"",!r)return[i];var o=[].concat(r);return o.map(function(e){e.at=e.at||0,e.len=e.len||0}),o.sort(function(e,t){return e.at-t.at==0?t.len-e.len:e.at-t.at}),o=o.map(function(e){var t,n=e.tp;return n||(e.key=e.key||0,t=a[e.key].data,n=a[e.key].tp),{tp:n,data:t,at:e.at,len:e.len}}),function e(t,n,i,r,a,o){for(var c=[],u=0;u0)for(var t in e.ent)if("EX"==e.ent[t].tp)return!0;return!1},a.attachments=function(e,t,n){if(e.ent&&e.ent.length>0)for(var s in e.ent)"EX"==e.ent[s].tp&&t.call(n,e.ent[s].data,s)},a.getDownloadUrl=function(e){let t=null;return e.val?t=i(e.val,e.mime):"string"==typeof e.ref&&(t=e.ref),t},a.isUploading=function(e){return e.ref instanceof Promise},a.getPreviewUrl=function(e){return e.val?i(e.val,e.mime):null},a.getEntitySize=function(e){return e.size?e.size:e.val?.75*e.val.length|0:0},a.getEntityMimeType=function(e){return e.mime||"text/plain"},a.tagName=function(e){return s[e]?s[e].name:void 0},a.attrValue=function(e,t){if(t&&r[e])return r[e].props(t)},a.getContentType=function(){return"text/x-drafty"},e=a;var o={};if("function"==typeof require)var c="0.15.6-rc3";const u="0",h=c||"0.15",l="tinodejs/"+h;function d(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function f(e,t,n){if(null==t)return e;if("object"!=typeof t)return t||e;if(t instanceof Date)return t;if(t instanceof S)return new S(t);if(t instanceof Array)return t.length>0?t:e;for(var s in e||(e=t.constructor()),t)!t.hasOwnProperty(s)||!t[s]&&!1!==t[s]||n&&n[s]||"_generated"==s||(e[s]=f(e[s],t[s]));return e}function p(e,t,n,s){return e[t]=f(e[t],n,s),e[t]}function g(){var e=null;if("withCredentials"in new XMLHttpRequest)e=new XMLHttpRequest;else{if("undefined"==typeof XDomainRequest)throw new Error("browser not supported");e=new XDomainRequest}return e}function _(e,t){if("ts"===e&&"string"==typeof t&&t.length>=20&&t.length<=24){var n=new Date(t);if(n)return n}else if("acs"===e&&"object"==typeof t)return new S(t);return t}function m(e,t){return"string"==typeof t&&t.length>128?"<"+t.length+", bytes: "+t.substring(0,12)+"..."+t.substring(t.length-12)+">":function(e,t){if(t instanceof Date)t=function(e){if(e&&0!=e.getTime()){var t=e.getUTCMilliseconds();return e.getUTCFullYear()+"-"+n(e.getUTCMonth()+1)+"-"+n(e.getUTCDate())+"T"+n(e.getUTCHours())+":"+n(e.getUTCMinutes())+":"+n(e.getUTCSeconds())+(t?"."+n(t,3):"")+"Z"}function n(e,t){return"0".repeat((t=t||2)-(""+e).length)+e}}(t);else if(null==t||!1===t||Array.isArray(t)&&0==t.length||"object"==typeof t&&0===Object.keys(t).length)return;return t}(0,t)}function v(e,t,n){var s=null;return"http"!==t&&"https"!==t&&"ws"!==t&&"wss"!==t||(s=t+"://","/"!==(s+=e).charAt(s.length-1)&&(s+="/"),s+="v"+u+"/channels","http"!==t&&"https"!==t||(s+="/lp"),s+="?apikey="+n),s}var b=function(e,t,n,s,i){let r=e,a=s,o=t;var c=i;const u=2e3,h=10,l=.3;let d=null,f=0,p=!1,m=e=>{this.logger&&this.logger(e)};function b(e){var t=null;e.connect=function(n){return t&&1===t.readyState?Promise.resolve():(n&&(r=n),new Promise(function(n,s){var i=v(r,a?"wss":"ws",o);m("Connecting to: "+i);var g=new WebSocket(i);g.onopen=function(t){p=!1,e.onOpen&&e.onOpen(),n(),c&&(window.clearTimeout(d),d=null,f=0)},g.onclose=function(n){t=null,e.onDisconnect&&e.onDisconnect(null),!p&&c&&function(){clearTimeout(d);var e=u*(Math.pow(2,f)*(1+l*Math.random()));f=f>=h?f:f+1,d=setTimeout(()=>{m("Reconnecting, iter="+f+", timeout="+e),p||this.connect().catch(function(){})},e)}.call(e)},g.onerror=function(e){s(e)},g.onmessage=function(t){e.onMessage&&e.onMessage(t.data)},t=g}))},e.disconnect=function(){t&&(p=!0,t.close()),t=null},e.sendText=function(e){if(!t||t.readyState!=t.OPEN)throw new Error("Websocket is not connected");t.send(e)},e.isConnected=function(){return t&&1===t.readyState}}function w(e){var t=null,n=null,s=null;e.connect=function(s){return s&&(r=s),new Promise(function(s,i){var c=v(r,a?"https":"http",o);m("Connecting to: "+c),(n=function n(s,i,r){var a=g();return a.onreadystatechange=function(o){if(4==a.readyState)if(201==a.status){var c=JSON.parse(a.responseText,_);a.responseText,t=s+"&sid="+c.ctrl.params.sid,(a=n(t)).send(null),e.onOpen&&e.onOpen(),i&&i()}else 200==a.status?(e.onMessage&&e.onMessage(a.responseText),(a=n(t)).send(null)):(r&&r(a.responseText),e.onMessage&&e.onMessage(a.responseText),e.onDisconnect&&e.onDisconnect(new Error(a.status+" "+a.responseText)))},a.open("GET",s,!0),a}(c,s,i)).send(null)}).catch(function(){})},e.disconnect=function(){s&&(s.abort(),s=null),n&&(n.abort(),n=null),e.onDisconnect&&e.onDisconnect(null),t=null},e.sendText=function(e){var n,i;if(n=t,(i=g()).onreadystatechange=function(e){if(4==i.readyState&&i.status>=400)throw new Error("LP sender failed, "+i.status)},i.open("POST",n,!0),!(s=i)||1!=s.readyState)throw new Error("Long poller failed to connect");s.send(e)},e.isConnected=function(){return n&&!0}}"lp"===n?w(this):"ws"===n?b(this):"object"==typeof window&&window.WebSocket?b(this):w(this),this.onMessage=void 0,this.onDisconnect=void 0,this.onOpen=void 0,this.logger=void 0},w=function(e,t,n,s,i){this._appName=e||"Undefined",this._apiKey=n,this._browser="",this._platform="undefined","undefined"!=typeof navigator&&(this._browser=function(e){var t,n=(e=(e||"").replace(" (KHTML, like Gecko)","")).match(/(AppleWebKit\/[.\d]+)/i);if(n){for(var s=["chrome","safari","mobile","version"],i=e.substr(n.index+n[0].length).split(" "),r=[],a=0;a0?r[0][0]+"/"+r[0][1]:n[1]}else t=/trident/i.test(e)?(n=/(?:\brv[ :]+([.\d]+))|(?:\bMSIE ([.\d]+))/g.exec(e))?"MSIE/"+(n[1]||n[2]):"MSIE/?":/firefox/i.test(e)?(n=/Firefox\/([.\d]+)/g.exec(e))?"Firefox/"+n[1]:"Firefox/?":/presto/i.test(e)?(n=/Opera\/([.\d]+)/g.exec(e))?"Opera/"+n[1]:"Opera/?":(n=/([\w.]+)\/([.\d]+)/.exec(e))?n[1]+"/"+n[2]:(n=e.split(" "))[0];if((n=t.split("/")).length>1){var c=n[1].split(".");t=n[0]+"/"+c[0]+(c[1]?"."+c[1]:"")}return t}(navigator.userAgent),this._platform=navigator.platform),this._loggingEnabled=!1,this._trimLongStrings=!1,this._myUID=null,this._authenticated=!1,this._login=null,this._authToken=null,this._inPacketCount=0,this._messageId=Math.floor(65535*Math.random()+65535),this._serverInfo=null,this._pendingPromises={},this._connection=new b(t,n,s,i,!0),this.logger=(e=>{if(this._loggingEnabled){var t=new Date,n=("0"+t.getUTCHours()).slice(-2)+":"+("0"+t.getUTCMinutes()).slice(-2)+":"+("0"+t.getUTCSeconds()).slice(-2)+":"+("0"+t.getUTCMilliseconds()).slice(-3);console.log("["+n+"] "+e)}}),this._connection.logger=this.logger,this._cache={};let r=this.cachePut=((e,t,n)=>{this._cache[e+":"+t]=n}),a=this.cacheGet=((e,t)=>this._cache[e+":"+t]),o=this.cacheDel=((e,t)=>{delete this._cache[e+":"+t]}),c=this.cacheMap=((e,t)=>{for(var n in this._cache)if(e(this._cache[n],n,t))break});this.attachCacheToTopic=(e=>{e._tinode=this,e._cacheGetUser=(e=>{var t=a("user",e);if(t)return{user:e,public:f({},t)}}),e._cachePutUser=((e,t)=>r("user",e,f({},t.public))),e._cacheDelUser=(e=>o("user",e)),e._cachePutSelf=(()=>r("topic",e.name,e)),e._cacheDelSelf=(()=>o("topic",e.name))});let u=(e,t,n,s)=>{var i=this._pendingPromises[e];i&&(delete this._pendingPromises[e],t>=200&&t<400?i.resolve&&i.resolve(n):i.reject&&i.reject(new Error("Error: "+s+" ("+t+")")))},d=e=>{var t=null;return e&&(t=new Promise((t,n)=>{this._pendingPromises[e]={resolve:t,reject:n}})),t},p=this.getNextUniqueId=(()=>0!=this._messageId?""+this._messageId++:void 0),g=()=>this._appName+" ("+(this._browser?this._browser+"; ":"")+this._platform+"); "+l;this.initPacket=((e,t)=>{switch(e){case"hi":return{hi:{id:p(),ver:h,ua:g()}};case"acc":return{acc:{id:p(),user:null,scheme:null,secret:null,login:!1,tags:null,desc:{},cred:{}}};case"login":return{login:{id:p(),scheme:null,secret:null}};case"sub":return{sub:{id:p(),topic:t,set:{},get:{}}};case"leave":return{leave:{id:p(),topic:t,unsub:!1}};case"pub":return{pub:{id:p(),topic:t,noecho:!1,head:null,content:{}}};case"get":return{get:{id:p(),topic:t,what:null,desc:{},sub:{},data:{}}};case"set":return{set:{id:p(),topic:t,desc:{},sub:{},tags:[]}};case"del":return{del:{id:p(),topic:t,what:null,delseq:null,user:null,hard:!1}};case"note":return{note:{topic:t,what:null,seq:void 0}};default:throw new Error("Unknown packet type requested: "+e)}}),this.send=((e,t)=>{let n;t&&(n=d(t)),e=function e(t){return Object.keys(t).forEach(function(n){"_"==n[0]?delete t[n]:t[n]?Array.isArray(t[n])&&0==t[n].length?delete t[n]:t[n]?"object"!=typeof t[n]||t[n]instanceof Date||(e(t[n]),0==Object.getOwnPropertyNames(t[n]).length&&delete t[n]):delete t[n]:delete t[n]}),t}(e);var s=JSON.stringify(e);return this.logger("out: "+(this._trimLongStrings?JSON.stringify(e,m):s)),this._connection.sendText(s),n}),this.loginSuccessful=(e=>{this._myUID=e.params.user,this._authenticated=e&&e.code>=200&&e.code<300,e.params&&e.params.token&&e.params.expires?this._authToken={token:e.params.token,expires:new Date(e.params.expires)}:this._authToken=null,this.onLogin&&this.onLogin(e.code,e.text)}),this._connection.onMessage=(e=>{if(e){this._inPacketCount++,this.onRawMessage&&this.onRawMessage(e);var t=JSON.parse(e,_);if(t)if(this.logger("in: "+(this._trimLongStrings?JSON.stringify(t,m):e)),this.onMessage&&this.onMessage(t),t.ctrl)this.onCtrlMessage&&this.onCtrlMessage(t.ctrl),t.ctrl.id&&u(t.ctrl.id,t.ctrl.code,t.ctrl,t.ctrl.text),t.ctrl.params&&"data"==t.ctrl.params.what&&(n=a("topic",t.ctrl.topic))&&n._allMessagesReceived(t.ctrl.params.count);else if(t.meta)(n=a("topic",t.meta.topic))&&n._routeMeta(t.meta),this.onMetaMessage&&this.onMetaMessage(t.meta);else if(t.data)(n=a("topic",t.data.topic))&&n._routeData(t.data),this.onDataMessage&&this.onDataMessage(t.data);else if(t.pres)(n=a("topic",t.pres.topic))&&n._routePres(t.pres),this.onPresMessage&&this.onPresMessage(t.pres);else if(t.info){var n;(n=a("topic",t.info.topic))&&n._routeInfo(t.info),this.onInfoMessage&&this.onInfoMessage(t.info)}else this.logger("ERROR: Unknown packet received.");else this.logger("in: "+e),this.logger("ERROR: failed to parse data")}}),this._connection.onOpen=(()=>{this.hello()}),this._connection.onDisconnect=(e=>{this._inPacketCount=0,this._serverInfo=null,this._authenticated=!1,c((e,t)=>{0===t.lastIndexOf("topic:",0)&&e._resetSub()}),this.onDisconnect&&this.onDisconnect(e)})};w.credential=function(e,t,n,s){return"object"==typeof e&&({val:t,params:n,resp:s,meth:e}=e),e&&(t||s)?[{meth:e,val:t,resp:s,params:n}]:null},w.topicType=function(e){return{me:"me",fnd:"fnd",grp:"grp",new:"grp",usr:"p2p"}["string"==typeof e?e.substring(0,3):"xxx"]},w.isNewGroupTopicName=function(e){return"string"==typeof e&&"new"==e.substring(0,3)},w.getVersion=function(){return h},w.getLibrary=function(){return l},w.MESSAGE_STATUS_NONE=0,w.MESSAGE_STATUS_QUEUED=1,w.MESSAGE_STATUS_SENDING=2,w.MESSAGE_STATUS_SENT=3,w.MESSAGE_STATUS_RECEIVED=4,w.MESSAGE_STATUS_READ=5,w.MESSAGE_STATUS_TO_ME=6,w.DEL_CHAR="\u2421",w.prototype={connect:function(e){return this._connection.connect(e)},disconnect:function(){this._connection&&this._connection.disconnect()},isConnected:function(){return this._connection&&this._connection.isConnected()},isAuthenticated:function(){return this._authenticated},account:function(e,t,n,s,i){var r=this.initPacket("acc");return r.acc.user=e,r.acc.scheme=t,r.acc.secret=n,r.acc.login=s,i&&(r.acc.desc.defacs=i.defacs,r.acc.desc.public=i.public,r.acc.desc.private=i.private,r.acc.tags=i.tags,r.acc.cred=i.cred),this.send(r,r.acc.id)},createAccount:function(e,t,n,s){var i=this.account("new",e,t,n,s);return n&&(i=i.then(e=>(this.loginSuccessful(e),e))),i},createAccountBasic:function(e,t,n){return e=e||"",t=t||"",this.createAccount("basic",d(e+":"+t),!0,n)},updateAccountBasic:function(e,t,n){return t=t||"",n=n||"",this.account(e,"basic",d(t+":"+n),!1,null)},hello:function(){var e=this.initPacket("hi");return this.send(e,e.hi.id).then(e=>(e.params&&(this._serverInfo=e.params),this.onConnect&&this.onConnect(),e)).catch(e=>{this.onDisconnect&&this.onDisconnect(e)})},login:function(e,t,n){var s=this.initPacket("login");return s.login.scheme=e,s.login.secret=t,s.login.cred=n,this.send(s,s.login.id).then(e=>(this.loginSuccessful(e),e))},loginBasic:function(e,t,n){return this.login("basic",d(e+":"+t),n).then(t=>(this._login=e,t))},loginToken:function(e,t){return this.login("token",e,t)},getAuthToken:function(){return this._authToken&&this._authToken.expires.getTime()>Date.now()?this._authToken:(this._authToken=null,null)},setAuthToken:function(e){this._authToken=e},subscribe:function(e,t,n){var s=this.initPacket("sub",e);return e||(e="new"),s.sub.get=t,n&&(n.sub&&(s.sub.set.sub=n.sub),w.isNewGroupTopicName(e)&&n.desc&&(s.sub.set.desc=n.desc),n.tags&&(s.sub.set.tags=n.tags)),this.send(s,s.sub.id)},leave:function(e,t){var n=this.initPacket("leave",e);return n.leave.unsub=t,this.send(n,n.leave.id)},createMessage:function(t,n,s){let i=this.initPacket("pub",t),r="string"==typeof n?e.parse(n):n;return r&&!e.isPlainText(r)&&(i.pub.head={mime:e.getContentType()},n=r),i.pub.noecho=s,i.pub.content=n,i.pub},publish:function(e,t,n){return this.publishMessage(this.createMessage(e,t,n))},publishMessage:function(e){return(e=Object.assign({},e)).seq=void 0,e.from=void 0,e.ts=void 0,this.send({pub:e},e.id)},getMeta:function(e,t){var n=this.initPacket("get",e);return n.get=f(n.get,t),this.send(n,n.get.id)},setMeta:function(e,t){var n=this.initPacket("set",e),s=[];return t&&["desc","sub","tags"].map(function(e){t.hasOwnProperty(e)&&(s.push(e),n.set[e]=t[e])}),0==s.length?Promise.reject(new Error("Invalid {set} parameters")):this.send(n,n.set.id)},delMessages:function(e,t,n){var s=this.initPacket("del",e);return s.del.what="msg",s.del.delseq=t,s.del.hard=n,this.send(s,s.del.id)},delTopic:function(e){var t=this.initPacket("del",e);return t.del.what="topic",this.send(t,t.del.id).then(t=>(this.cacheDel("topic",e),this.ctrl))},delSubscription:function(e,t){var n=this.initPacket("del",e);return n.del.what="sub",n.del.user=t,this.send(n,n.del.id)},note:function(e,t,n){if(n<=0||n>=268435455)throw new Error("Invalid message id "+n);var s=this.initPacket("note",e);s.note.what=t,s.note.seq=n,this.send(s)},noteKeyPress:function(e){var t=this.initPacket("note",e);t.note.what="kp",this.send(t)},getTopic:function(e){var t=this.cacheGet("topic",e);return!t&&e&&(t="me"==e?new y:"fnd"==e?new D:new T(e),this.cachePut("topic",e,t),this.attachCacheToTopic(t)),t},newTopic:function(e){var t=new T("new",e);return this.attachCacheToTopic(t),t},newGroupTopicName:function(){return"new"+this.getNextUniqueId()},newTopicWith:function(e,t){var n=new T(e,t);return this.attachCacheToTopic(n),n},getMeTopic:function(){return this.getTopic("me")},getFndTopic:function(){return this.getTopic("fnd")},getLargeFileHelper:function(){return new E(this)},getCurrentUserID:function(){return this._myUID},getCurrentLogin:function(){return this._login},getServerInfo:function(){return this._serverInfo},enableLogging:function(e,t){this._loggingEnabled=e,this._trimLongStrings=t},isTopicOnline:function(e){var t=this.getMeTopic(),n=t&&t.getContact(e);return n&&n.online},wantAkn:function(e){this._messageId=e?Math.floor(16777215*Math.random()+16777215):0},onWebsocketOpen:void 0,onConnect:void 0,onDisconnect:void 0,onLogin:void 0,onCtrlMessage:void 0,onDataMessage:void 0,onPresMessage:void 0,onMessage:void 0,onRawMessage:void 0};var M=function(e){this.topic=e;var t=e._tinode.getMeTopic();this.contact=t&&t.getContact(e.name),this.what={}};M.prototype={_get_ims:function(){let e=this.contact&&this.contact.updated,t=this.topic._lastDescUpdate||0;return e>t?e:t},withData:function(e,t,n){return this.what.data={since:e,before:t,limit:n},this},withLaterData:function(e){return this.withData(this.topic._maxSeq>0?this.topic._maxSeq+1:void 0,void 0,e)},withEarlierData:function(e){return this.withData(void 0,this.topic._minSeq>0?this.topic._minSeq:void 0,e)},withDesc:function(e){return this.what.desc={ims:e},this},withLaterDesc:function(){return this.withDesc(this._get_ims())},withSub:function(e,t,n){var s={ims:e,limit:t};return"me"==this.topic.getType()?s.topic=n:s.user=n,this.what.sub=s,this},withOneSub:function(e,t){return this.withSub(e,void 0,t)},withLaterOneSub:function(e){return this.withOneSub(this.topic._lastSubsUpdate,e)},withLaterSub:function(e){return this.withSub("p2p"==this.topic.getType()?this._get_ims():this.topic._lastSubsUpdate,e)},withTags:function(){return this.what.tags=!0,this},withDel:function(e,t){return(e||t)&&(this.what.del={since:e,limit:t}),this},withLaterDel:function(e){return this.withDel(this.topic._maxSeq>0?this.topic._maxDel+1:void 0,e)},build:function(){var e={},t=[],n=this;return["data","sub","desc","tags","del"].map(function(s){n.what.hasOwnProperty(s)&&(t.push(s),Object.getOwnPropertyNames(n.what[s]).length>0&&(e[s]=n.what[s]))}),t.length>0?e.what=t.join(" "):e=void 0,e}};var S=function(e){e&&(this.given="number"==typeof e.given?e.given:S.decode(e.given),this.want="number"==typeof e.want?e.want:S.decode(e.want),this.mode=e.mode?"number"==typeof e.mode?e.mode:S.decode(e.mode):this.given&this.want)};S._NONE=0,S._JOIN=1,S._READ=2,S._WRITE=4,S._PRES=8,S._APPROVE=16,S._SHARE=32,S._DELETE=64,S._OWNER=128,S._BITMASK=S._JOIN|S._READ|S._WRITE|S._PRES|S._APPROVE|S._SHARE|S._DELETE|S._OWNER,S._INVALID=1048576,S.decode=function(e){if(!e)return null;if("number"==typeof e)return e&S._BITMASK;if("N"===e||"n"===e)return S._NONE;for(var t={J:S._JOIN,R:S._READ,W:S._WRITE,P:S._PRES,A:S._APPROVE,S:S._SHARE,D:S._DELETE,O:S._OWNER},n=S._NONE,s=0;s0)){c=!0;break}r=a-1}return c?a:s?-1:o<0?a+1:a}function s(e,t){var s=n(e,t,!1);return t.splice(s,0,e),t}return e=e||function(e,t){return e===t?0:e0)return n[0]},delRange:function(e,n){return t.splice(e,n-e)},size:function(){return t.length},reset:function(e){t=[]},forEach:function(e,n,s,i){n|=0,s=s||t.length;for(var r=n;r{if(e.code>=300)return e;if(this._subscribed=!0,this.acs=e.params&&e.params.acs?e.params.acs:this.acs,this._new){this._new=!1,this.name=e.topic,this.created=e.ts,this.updated=e.ts,this.touched=e.ts,this._cachePutSelf();var n=this._tinode.getMeTopic();n&&n._processMetaSub([{_generated:!0,topic:this.name,created:e.ts,updated:e.ts,touched:e.ts,acs:this.acs}]),t&&t.desc&&(t.desc._generated=!0,this._processMetaDesc(t.desc))}return e})},publish:function(e,t){return this.publishMessage(this.createMessage(e,t))},createMessage:function(e,t){return this._tinode.createMessage(this.name,e,t)},publishMessage:function(t){if(!this._subscribed)return Promise.reject(new Error("Cannot publish on inactive topic"));if(e.hasAttachments(t.content)){let n=[];e.attachments(t.content,e=>{n.push(e.ref)}),t.head.attachments=n}return t._sending=!0,this._tinode.publishMessage(t)},publishDraft:function(e,t){return t||this._subscribed?(e.seq=this._getQueuedSeqId(),e._generated=!0,e.ts=new Date,e.from=this._tinode.getCurrentUserID(),e.noecho=!0,this._messages.put(e),this.onData&&this.onData(e),(t||Promise.resolve()).then(()=>e._cancelled?{code:300,text:"cancelled"}:this.publishMessage(e).then(t=>(e._sending=!1,e.seq=t.params.seq,e.ts=t.ts,this._routeData(e),t)),t=>{e._sending=!1,this._messages.delAt(this._messages.find(e)),this.onData&&this.onData()})):Promise.reject(new Error("Cannot publish on inactive topic"))},leave:function(e){return this._subscribed||e?this._tinode.leave(this.name,e).then(t=>(this._resetSub(),e&&this._gone(),t)):Promise.reject(new Error("Cannot leave inactive topic"))},getMeta:function(e){return this._subscribed?this._tinode.getMeta(this.name,e):Promise.reject(new Error("Cannot query inactive topic"))},getMessagesPage:function(e,t){var n=this.startMetaQuery();t?n.withLaterData(e):n.withEarlierData(e);var s=this.getMeta(n.build());return t||(s=s.then(e=>{e&&e.params&&!e.params.count&&(this._noEarlierMsgs=!0)})),s},setMeta:function(e){return this._subscribed?(e.tags&&(e.tags=function(e){var t=[];if(Array.isArray(e)){for(var n=0,s=e.length;n1&&t.push(i)}t.sort().filter(function(e,t,n){return!t||e!=n[t-1]})}return 0==t.length&&t.push(w.DEL_CHAR),t}(e.tags)),this._tinode.setMeta(this.name,e).then(t=>t&&t.code>=300?t:(e.sub&&(t.params&&t.params.acs&&(e.sub.acs=t.params.acs,e.sub.updated=t.ts),e.sub.user||(e.sub.user=this._tinode.getCurrentUserID(),e.desc||(e.desc={})),e.sub._generated=!0,this._processMetaSub([e.sub])),e.desc&&(t.params&&t.params.acs&&(e.desc.acs=t.params.acs,e.desc.updated=t.ts),this._processMetaDesc(e.desc)),e.tags&&this._processMetaTags(e.tags),t))):Promise.reject(new Error("Cannot update inactive topic"))},invite:function(e,t){return this.setMeta({sub:{user:e,mode:t}})},delMessages:function(e,t){if(!this._subscribed)return Promise.reject(new Error("Cannot delete messages in inactive topic"));e.sort(function(e,t){return e.low=t.hi)});let n,s=e.reduce((e,t)=>(t.low<268435455&&(!t.hi||t.hi<268435455?e.push(t):e.push({low:t.low,hi:this._maxSeq+1})),e),[]);return(n=e.length>0?this._tinode.delMessages(this.name,s,t):Promise.resolve({params:{del:0}})).then(t=>(t.params.del>this._maxDel&&(this._maxDel=t.params.del),e.map(e=>{e.hi?this.flushMessageRange(e.low,e.hi):this.flushMessage(e.low)}),this.onData&&this.onData(),t))},delMessagesAll:function(e){return this.delMessages([{low:1,hi:this._maxSeq+1,_all:!0}],e)},delMessagesList:function(e,t){e.sort((e,t)=>e-t);var n=e.reduce((e,t)=>{if(0==e.length)e.push({low:t});else{let n=e[e.length-1];!n.hi&&t!=n.low+1||t>n.hi?e.push({low:t}):n.hi=n.hi?Math.max(n.hi,t+1):t+1}return e},[]);return this.delMessages(n,t)},delTopic:function(){var e=this;return this._tinode.delTopic(this.name).then(function(t){return e._resetSub(),e._gone(),t})},delSubscription:function(e){return this._subscribed?this._tinode.delSubscription(this.name,e).then(t=>(delete this._users[e],this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._users)),t)):Promise.reject(new Error("Cannot delete subscription in inactive topic"))},note:function(e,t){var n=this._users[this._tinode.getCurrentUserID()];n?((!n[e]||n[e]0)for(var i in this._users){var r=this._users[i];r.user!==s&&r[e]>=t&&n++}return n},msgReadCount:function(e){return this.msgReceiptCount("read",e)},msgRecvCount:function(e){return this.msgReceiptCount("recv",e)},msgHasMoreMessages:function(e){return e?this.seq>this._maxSeq:this._minSeq>1&&!this._noEarlierMsgs},isNewMessage:function(e){return this._maxSeq<=e},flushMessage:function(e){let t=this._messages.find({seq:e});return t>=0?this._messages.delAt(t):void 0},flushMessageRange:function(e,t){let n=this._messages.find({seq:e});return n>=0?this._messages.delRange(n,this._messages.find({seq:t},!0)):[]},cancelSend:function(e){let t=this._messages.find({seq:e});if(t>=0){let e=this._messages.getAt(t);if(1==this.msgStatus(e))return e._cancelled=!0,this._messages.delAt(t),!0}return!1},getType:function(){return w.topicType(this.name)},getAccessMode:function(){return this.acs},getDefaultAccess:function(){return this.defacs},startMetaQuery:function(){return new M(this)},msgStatus:function(e){var t=0;return e.from==this._tinode.getCurrentUserID()?e._sending?t=2:e.seq>=268435455?t=1:this.msgReadCount(e.seq)>0?t=5:this.msgRecvCount(e.seq)>0?t=4:e.seq>0&&(t=3):t=6,t},_routeData:function(e){e.content&&((!this.touched||this.touchedthis._maxSeq&&(this._maxSeq=e.seq),(e.seq0&&(this._lastSubsUpdate=e.ts,this._processMetaSub(e.sub)),e.del&&this._processDelMessages(e.del.clear,e.del.delseq),e.tags&&this._processMetaTags(e.tags),this.onMeta&&this.onMeta(e)},_routePres:function(e){var t;switch(e.what){case"del":this._processDelMessages(e.clear,e.delseq);break;case"on":case"off":(t=this._users[e.src])?t.online="on"==e.what:this._tinode.logger("Presence update for an unknown user",this.name,e.src);break;case"acs":let s="me"==e.src?this._tinode.getCurrentUserID():e.src;if(t=this._users[s])t.acs.updateAll(e.dacs),s==this._tinode.getCurrentUserID()&&this.acs.updateAll(e.dacs),t.acs&&t.acs.mode!=S._NONE||("p2p"==this.getType()&&this.leave(),this._processMetaSub([{user:s,deleted:new Date,_generated:!0}]));else{var n=(new S).updateAll(e.dacs);n&&n.mode!=S._NONE&&((t=this._cacheGetUser(s))?t.acs=n:(t={user:s,acs:n},this.getMeta(this.startMetaQuery().withOneSub(void 0,s).build())),t._generated=!0,t.updated=new Date,this._processMetaSub([t]))}break;default:this._tinode.logger("Ignored presence update",e.what)}this.onPres&&this.onPres(e)},_routeInfo:function(e){if("kp"!==e.what){var t=this._users[e.from];t&&(t[e.what]=e.seq)}this.onInfo&&this.onInfo(e)},_processMetaDesc:function(e,t){if(f(this,e),"string"==typeof this.created&&(this.created=new Date(this.created)),"string"==typeof this.updated&&(this.updated=new Date(this.updated)),"string"==typeof this.touched&&(this.touched=new Date(this.touched)),"me"!==this.name&&!t&&!e._generated){var n=this._tinode.getMeTopic();n&&n._processMetaSub([{_generated:!0,topic:this.name,updated:this.updated,touched:this.touched,acs:this.acs,public:this.public,private:this.private}])}this.onMetaDesc&&this.onMetaDesc(this)},_processMetaSub:function(e){var t=void 0;for(var n in e){var s=e[n];if(s.user){s.updated=new Date(s.updated),s.deleted=s.deleted?new Date(s.deleted):null;var i=null;s.deleted?(delete this._users[s.user],i=s):((i=this._users[s.user])||(i=this._cacheGetUser(s.user)),i=this._updateCachedUser(s.user,s,s._generated)),this.onMetaSub&&this.onMetaSub(i)}else s._generated||(t=s)}t&&this.onMetaDesc&&this.onMetaDesc(t),this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._users))},_processMetaTags:function(e){1==e.length&&e[0]==w.DEL_CHAR&&(e=[]),this._tags=e,this.onTagsUpdated&&this.onTagsUpdated(e)},_processDelMessages:function(e,t){this._maxDel=Math.max(e,this._maxDel),this.clear=Math.max(e,this.clear);var n=this,s=0;Array.isArray(t)&&t.map(function(e){if(e.hi)for(var t=e.low;t0&&this.onData&&this.onData()},_allMessagesReceived:function(e){this.onAllMessagesReceived&&this.onAllMessagesReceived(e)},_resetSub:function(){this._subscribed=!1},_gone:function(){var e=this._tinode.getMeTopic();e&&e._routePres({_generated:!0,what:"gone",topic:"me",src:this.name}),this.onDeleteTopic&&this.onDeleteTopic()},_updateCachedUser:function(e,t,n){var s=this._cacheGetUser(e);return s?s=f(s,t):(n&&this.getMeta(this.startMetaQuery().withLaterOneSub(e).build()),s=f({},t)),this._cachePutUser(e,s),p(this._users,e,s)},_getQueuedSeqId:function(){return this._queuedSeqId++}};var y=function(e){T.call(this,"me",e),this._contacts={},e&&(this.onContactUpdate=e.onContactUpdate)};y.prototype=Object.create(T.prototype,{_processMetaSub:{value:function(e){var t=0;for(var n in e){var s=e[n],i=s.topic;if("fnd"!=i&&"me"!=i){s.updated=new Date(s.updated),s.touched=s.touched?new Date(s.touched):null,s.deleted=s.deleted?new Date(s.deleted):null,s.seq=0|s.seq,s.recv=0|s.recv,s.read=0|s.read,s.unread=s.seq-s.read;var r=null;if(s.deleted)r=s,delete this._contacts[i];else if(s.seen&&s.seen.when&&(s.seen.when=new Date(s.seen.when)),r=p(this._contacts,i,s),"p2p"==w.topicType(i)&&this._cachePutUser(i,r),!s._generated){var a=this._tinode.getTopic(i);a&&a._processMetaDesc(s,!0)}t++,this.onMetaSub&&this.onMetaSub(r)}}t>0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},_routePres:{value:function(e){var t=this._contacts[e.src];if(t){switch(e.what){case"on":t.online=!0;break;case"off":t.online&&(t.online=!1,t.seen?t.seen.when=new Date:t.seen={when:new Date});break;case"msg":t.touched=new Date,t.seq=0|e.seq,t.unread=t.seq-t.read;break;case"upd":this.getMeta(this.startMetaQuery().withLaterOneSub(e.src).build());break;case"acs":t.acs?t.acs.updateAll(e.dacs):t.acs=(new S).updateAll(e.dacs);break;case"ua":t.seen={when:new Date,ua:e.ua};break;case"recv":t.recv=t.recv?Math.max(t.recv,e.seq):0|e.seq;break;case"read":t.read=t.read?Math.max(t.read,e.seq):0|e.seq,t.unread=t.seq-t.read;break;case"gone":delete this._contacts[e.src]}this.onContactUpdate&&this.onContactUpdate(e.what,t)}else if("acs"==e.what){var n=new S(e.dacs);if(!n||n.mode==S._INVALID)return void this._tinode.logger("Invalid access mode update",e.src,e.dacs);if(n.mode==S._NONE)return void this._tinode.logger("Removing non-existent subscription",e.src,e.dacs);this.getMeta(this.startMetaQuery().withOneSub(void 0,e.src).build()),this._contacts[e.src]={topic:e.src,online:!1,acs:n}}this.onPres&&this.onPres(e)},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'me' is not supported"))},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var s in this._contacts)n.call(t,this._contacts[s],s,this._contacts)},enumerable:!0,configurable:!0,writable:!0},setMsgReadRecv:{value:function(e,t,n,s){var i,r=this._contacts[e],a=!1;r&&(n|=0,"recv"===t?(i=r.recv,r.recv=r.recv?Math.max(r.recv,n):n,a=i!=r.recv):"read"===t?(i=r.read,r.read=r.read?Math.max(r.read,n):n,r.unread=r.seq-r.read,a=i!=r.read,r.recv0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'fnd' is not supported"))},enumerable:!0,configurable:!0,writable:!1},setMeta:{value:function(e){var t=this;return Object.getPrototypeOf(D.prototype).setMeta.call(this,e).then(function(){Object.keys(t._contacts).length>0&&(t._contacts={},t.onSubsUpdated&&t.onSubsUpdated([]))})},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var s in this._contacts)n.call(t,this._contacts[s],s,this._contacts)},enumerable:!0,configurable:!0,writable:!0}}),D.prototype.constructor=D;var E=function(e){this._tinode=e,this._apiKey=e._apiKey,this._authToken=e.getAuthToken(),this._msgId=e.getNextUniqueId(),this.xhr=g(),this.toResolve=null,this.toReject=null,this.onProgress=null,this.onSuccess=null,this.onFailure=null};E.prototype={upload:function(e,t,n,s){if(!this._authToken)throw new Error("Must authenticate first");var i=this;this.xhr.open("POST","/v"+u+"/file/u/",!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token);var r=new Promise((e,t)=>{this.toResolve=e,this.toReject=t});this.onProgress=t,this.onSuccess=n,this.onFailure=s,this.xhr.upload.onprogress=function(e){e.lengthComputable&&i.onProgress&&i.onProgress(e.loaded/e.total)},this.xhr.onload=function(){var e;try{e=JSON.parse(this.response,_)}catch(e){i._tinode.logger("Invalid server response in LargeFileHelper",this.response)}this.status>=200&&this.status<300?(i.toResolve&&i.toResolve(e.ctrl.params.url),i.onSuccess&&i.onSuccess(e.ctrl)):this.status>=400?(i.toReject&&i.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")")),i.onFailure&&i.onFailure(e.ctrl)):i._tinode.logger("Unexpected server response status",this.status,this.response)},this.xhr.onerror=function(e){i.toReject&&i.toReject(new Error("failed")),i.onFailure&&i.onFailure(null)},this.xhr.onabort=function(e){i.toReject&&i.toReject(new Error("upload cancelled by user")),i.onFailure&&i.onFailure(null)};try{var a=new FormData;a.append("file",e),a.set("id",this._msgId),this.xhr.send(a)}catch(e){this.toReject&&this.toReject(e),this.onFailure&&this.onFailure(null)}return r},download:function(e,t,n,s){if(/^(?:(?:[a-z]+:)?\/\/)/i.test(e))throw new Error("The URL '"+e+"' must be relative, not absolute");if(!this._authToken)throw new Error("Must authenticate first");var i=this;this.xhr.open("GET",e,!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token),this.xhr.responseType="blob",this.onProgress=s,this.xhr.onprogress=function(e){i.onProgress&&i.onProgress(e.loaded)};var r=new Promise((e,t)=>{this.toResolve=e,this.toReject=t});this.xhr.onload=function(){if(200==this.status){var e=document.createElement("a");e.href=window.URL.createObjectURL(new Blob([this.response],{type:n})),e.style.display="none",e.setAttribute("download",t),document.body.appendChild(e),e.click(),document.body.removeChild(e),window.URL.revokeObjectURL(e.href),i.toResolve&&i.toResolve()}else if(this.status>=400&&i.toReject){var s=new FileReader;s.onload=function(){try{var e=JSON.parse(this.result,_);i.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")"))}catch(e){i._tinode.logger("Invalid server response in LargeFileHelper",this.result),i.toReject(e)}},s.readAsText(this.response)}},this.xhr.onerror=function(e){i.toReject&&i.toReject(new Error("failed"))},this.xhr.onabort=function(){i.toReject&&i.toReject(null)};try{this.xhr.send()}catch(e){this.toReject&&this.toReject(e)}return r},cancel:function(){this.xhr&&this.xhr.readyState<4&&this.xhr.abort()},getId:function(){return this._msgId}};var x=function(e,t){this.status=x.STATUS_NONE,this.topic=e,this.content=t};return x.STATUS_NONE=0,x.STATUS_QUEUED=1,x.STATUS_SENDING=2,x.STATUS_SENT=3,x.STATUS_RECEIVED=4,x.STATUS_READ=5,x.STATUS_TO_ME=6,x.prototype={toJSON:function(){},fromJSON:function(e){}},x.prototype.constructor=x,(o=w).Drafty=e,o});
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],25:[function(require,module,exports){
// Put all packages together.
@@ -20238,6 +20238,10 @@ ReactDOM.render(
);
},{"./webapp.js":26,"react":23,"react-dom":20}],26:[function(require,module,exports){
+// Babel JSX
+
+'use strict';
+
if (typeof require == 'function') {
if (typeof React == 'undefined') {
var React = require('react');
@@ -20248,8 +20252,6 @@ if (typeof require == 'function') {
}
}
-// Babel JSX
-
// Name of this application, used in the User-Agent.
const APP_NAME = "TinodeWeb/0.15";
@@ -21488,12 +21490,11 @@ class GroupSubs extends React.Component {
this.state.onlineSubs.map(sub => {
usersOnline.push(React.createElement(
'div',
- { className: 'avatar-box' },
+ { className: 'avatar-box', key: sub.user },
React.createElement(LetterTile, {
topic: sub.user,
avatar: makeImageUrl(sub.public ? sub.public.photo : null) || true,
- title: sub.public ? sub.public.fn : null,
- key: sub.user })
+ title: sub.public ? sub.public.fn : null })
));
});
return React.createElement(
@@ -21555,13 +21556,13 @@ class LoginView extends React.Component {
'form',
{ id: 'login-form', onSubmit: this.handleSubmit },
React.createElement('input', { type: 'text', id: 'inputLogin',
- placeholder: 'Login (alice, bob, carol, dave, frank)',
+ placeholder: 'Login',
autoComplete: 'username',
value: this.state.login,
onChange: this.handleLoginChange,
required: true, autoFocus: true }),
React.createElement('input', { type: 'password', id: 'inputPassword',
- placeholder: 'Password (alice123, bob123, ...)',
+ placeholder: 'Password',
autoComplete: 'current-password',
value: this.state.password,
onChange: this.handlePasswordChange,
@@ -25104,7 +25105,7 @@ class SendMessage extends React.PureComponent {
/* This is just a static page to display when no conversation is selected. */
class LogoView extends React.PureComponent {
render() {
- var version = Tinode.getVersion() + " build " + document.lastModified;
+ var version = APP_NAME + " (" + Tinode.getLibrary() + "-" + new Date(document.lastModified).toISOString() + ")";
return React.createElement(
'div',
{ id: 'dummy-view', className: this.props.hideSelf ? 'nodisplay' : null },
@@ -25960,8 +25961,6 @@ class TinodeWeb extends React.Component {
// New topic was creted, here is the new topic name.
handleNewTopicCreated(oldName, newName) {
- console.log("handleNewTopicCreated", oldName, newName);
-
if (this.state.topicSelected == oldName && oldName != newName) {
// If the current URl contains the old topic name, replace it with new.
// Update the name of the selected topic first so the navigator doen't clear
diff --git a/umd/index.prod.js b/umd/index.prod.js
index be714e65..c91effcd 100644
--- a/umd/index.prod.js
+++ b/umd/index.prod.js
@@ -1 +1 @@
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Webapp=e()}}(function(){var e=!("undefined"==typeof window||!window.document||!window.document.createElement),t={canUseDOM:e,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:e&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:e&&!!window.screen,isInWorker:!e},n=function(e){return function(e){var t=(e?e.ownerDocument||e:document).defaultView||window;return!(!e||!("function"==typeof t.Node?e instanceof t.Node:"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName))}(e)&&3==e.nodeType},s=function e(t,s){return!(!t||!s)&&(t===s||!n(t)&&(n(s)?e(t,s.parentNode):"contains"in t?t.contains(s):!!t.compareDocumentPosition&&!!(16&t.compareDocumentPosition(s))))},a={};function i(e){return function(){return e}}var r=function(){};r.thatReturns=i,r.thatReturnsFalse=i(!1),r.thatReturnsTrue=i(!0),r.thatReturnsNull=i(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},a=r;var o={},l=function(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}},c=function(e,t,n,s,a,i,r,o){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,s,a,i,r,o],u=0;(l=new Error(t.replace(/%s/g,function(){return c[u++]}))).name="Invariant Violation"}throw l.framesToPop=1,l}},u=Object.prototype.hasOwnProperty;function d(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}var h=function(e,t){if(d(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(var a=0;az.length&&z.push(e)}function H(e,t,n){return null==e?0:function e(t,n,s,a){var i=typeof t;"undefined"!==i&&"boolean"!==i||(t=null);var r=!1;if(null===t)r=!0;else switch(i){case"string":case"number":r=!0;break;case"object":switch(t.$$typeof){case b:case y:r=!0}}if(r)return s(a,t,""===n?"."+B(t,0):n),1;if(r=0,n=""===n?".":n+":",Array.isArray(t))for(var o=0;othis.eventPool.length&&this.eventPool.push(e)}function ut(e){e.eventPool=[],e.getPooled=lt,e.release=ct}g(ot.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=a.thatReturnsTrue)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=a.thatReturnsTrue)},persist:function(){this.isPersistent=a.thatReturnsTrue},isPersistent:a.thatReturnsFalse,destructor:function(){var e,t=this.constructor.Interface;for(e in t)this[e]=null;for(t=0;t=ft),bt=String.fromCharCode(32),yt={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["compositionend","keypress","textInput","paste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"blur compositionend keydown keypress keyup mousedown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:"blur compositionstart keydown keypress keyup mousedown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"blur compositionupdate keydown keypress keyup mousedown".split(" ")}},wt=!1;function Et(e,t){switch(e){case"keyup":return-1!==pt.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"blur":return!0;default:return!1}}function St(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Ct=!1,Tt={eventTypes:yt,extractEvents:function(e,t,n,s){var a=void 0,i=void 0;if(mt)e:{switch(e){case"compositionstart":a=yt.compositionStart;break e;case"compositionend":a=yt.compositionEnd;break e;case"compositionupdate":a=yt.compositionUpdate;break e}a=void 0}else Ct?Et(e,n)&&(a=yt.compositionEnd):"keydown"===e&&229===n.keyCode&&(a=yt.compositionStart);return a?(vt&&(Ct||a!==yt.compositionStart?a===yt.compositionEnd&&Ct&&(i=st()):(nt._root=s,nt._startText=at(),Ct=!0)),a=dt.getPooled(a,t,n,s),i?a.data=i:null!==(i=St(n))&&(a.data=i),ze(a),i=a):i=null,(e=gt?function(e,t){switch(e){case"compositionend":return St(t);case"keypress":return 32!==t.which?null:(wt=!0,bt);case"textInput":return(e=t.data)===bt&&wt?null:e;default:return null}}(e,n):function(e,t){if(Ct)return"compositionend"===e||!mt&&Et(e,t)?(e=st(),nt._root=null,nt._startText=null,nt._fallbackText=null,Ct=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1t}return!1}(t,n,a,s)&&(n=null),s||null===a?function(e){return!!un.call(hn,e)||!un.call(dn,e)&&(cn.test(e)?hn[e]=!0:(dn[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):a.mustUseProperty?e[a.propertyName]=null===n?3!==a.type&&"":n:(t=a.attributeName,s=a.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(a=a.type)||4===a&&!0===n?"":""+n,s?e.setAttributeNS(s,t,n):e.setAttribute(t,n))))}function bn(e,t){var n=t.checked;return g({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function yn(e,t){var n=null==t.defaultValue?"":t.defaultValue,s=null!=t.checked?t.checked:t.defaultChecked;n=Tn(null!=t.value?t.value:n),e._wrapperState={initialChecked:s,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function wn(e,t){null!=(t=t.checked)&&vn(e,"checked",t,!1)}function En(e,t){wn(e,t);var n=Tn(t.value);null!=n&&("number"===t.type?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n)),t.hasOwnProperty("value")?Cn(e,t.type,n):t.hasOwnProperty("defaultValue")&&Cn(e,t.type,Tn(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function Sn(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){t=""+e._wrapperState.initialValue;var s=e.value;n||t===s||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!e.defaultChecked,e.defaultChecked=!e.defaultChecked,""!==n&&(e.name=n)}function Cn(e,t,n){"number"===t&&e.ownerDocument.activeElement===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}function Tn(e){switch(typeof e){case"boolean":case"number":case"object":case"string":case"undefined":return e;default:return""}}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(fn,gn);mn[t]=new pn(t,1,!1,e,null)}),"xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(fn,gn);mn[t]=new pn(t,1,!1,e,"http://www.w3.org/1999/xlink")}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(fn,gn);mn[t]=new pn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace")}),mn.tabIndex=new pn("tabIndex",1,!1,"tabindex",null);var _n={change:{phasedRegistrationNames:{bubbled:"onChange",captured:"onChangeCapture"},dependencies:"blur change click focus input keydown keyup selectionchange".split(" ")}};function kn(e,t,n){return(e=ot.getPooled(_n.change,e,t,n)).type="change",Pt(n),ze(e),e}var xn=null,Mn=null;function Nn(e){Te(e,!1)}function Pn(e){if(Bt(Ue(e)))return e}function Un(e,t){if("change"===e)return t}var Dn=!1;function An(){xn&&(xn.detachEvent("onpropertychange",In),Mn=xn=null)}function In(e){"value"===e.propertyName&&Pn(Mn)&&Ft(Nn,e=kn(Mn,e,zt(e)))}function Rn(e,t,n){"focus"===e?(An(),Mn=n,(xn=t).attachEvent("onpropertychange",In)):"blur"===e&&An()}function On(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Pn(Mn)}function Ln(e,t){if("click"===e)return Pn(t)}function Fn(e,t){if("input"===e||"change"===e)return Pn(t)}t.canUseDOM&&(Dn=Wt("input")&&(!document.documentMode||9ms.length&&ms.push(e)}}}var Ss={get _enabled(){return gs},setEnabled:vs,isEnabled:function(){return gs},trapBubbledEvent:bs,trapCapturedEvent:ys,dispatchEvent:Es},Cs={},Ts=0,_s="_reactListenersID"+(""+Math.random()).slice(2);function ks(e){return Object.prototype.hasOwnProperty.call(e,_s)||(e[_s]=Ts++,Cs[e[_s]]={}),Cs[e[_s]]}function xs(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ms(e,t){var n,s=xs(e);for(e=0;s;){if(3===s.nodeType){if(n=e+s.textContent.length,e<=t&&n>=t)return{node:s,offset:t-e};e=n}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=xs(s)}}function Ns(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var Ps=t.canUseDOM&&"documentMode"in document&&11>=document.documentMode,Us={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"blur contextmenu focus keydown keyup mousedown mouseup selectionchange".split(" ")}},Ds=null,As=null,Is=null,Rs=!1;function Os(e,t){if(Rs||null==Ds||Ds!==l())return null;var n=Ds;return n="selectionStart"in n&&Ns(n)?{start:n.selectionStart,end:n.selectionEnd}:window.getSelection?{anchorNode:(n=window.getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}:void 0,Is&&h(Is,n)?null:(Is=n,(e=ot.getPooled(Us.select,As,e,t)).type="select",e.target=Ds,ze(e),e)}var Ls={eventTypes:Us,extractEvents:function(e,t,n,s){var a,i=s.window===s?s.document:9===s.nodeType?s:s.ownerDocument;if(!(a=!i)){e:{i=ks(i),a=le.onSelect;for(var r=0;rt)){e=-1;for(var n=[],s=Ks;null!==s;){var a=s.timeoutTime;-1!==a&&a<=t?n.push(s):-1!==a&&(-1===e||at&&(t=8),ea=t=t.length||Z("93"),t=t[0]),n=""+t),null==n&&(n="")),e._wrapperState={initialValue:""+n}}function da(e,t){var n=t.value;null!=n&&((n=""+n)!==e.value&&(e.value=n),null==t.defaultValue&&(e.defaultValue=n)),null!=t.defaultValue&&(e.defaultValue=t.defaultValue)}function ha(e){var t=e.textContent;t===e._wrapperState.initialValue&&(e.value=t)}var pa={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};function ma(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function fa(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?ma(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var ga,va=void 0,ba=(ga=function(e,t){if(e.namespaceURI!==pa.svg||"innerHTML"in e)e.innerHTML=t;else{for((va=va||document.createElement("div")).innerHTML="",t=va.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,s){MSApp.execUnsafeLocalFunction(function(){return ga(e,t)})}:ga);function ya(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var wa={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ea=["Webkit","ms","Moz","O"];function Sa(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var s=0===n.indexOf("--"),a=n,i=t[n];a=null==i||"boolean"==typeof i||""===i?"":s||"number"!=typeof i||0===i||wa.hasOwnProperty(a)&&wa[a]?(""+i).trim():i+"px","float"===n&&(n="cssFloat"),s?e.setProperty(n,a):e[n]=a}}Object.keys(wa).forEach(function(e){Ea.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),wa[t]=wa[e]})});var Ca=g({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ta(e,t,n){t&&(Ca[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML)&&Z("137",e,n()),null!=t.dangerouslySetInnerHTML&&(null!=t.children&&Z("60"),"object"==typeof t.dangerouslySetInnerHTML&&"__html"in t.dangerouslySetInnerHTML||Z("61")),null!=t.style&&"object"!=typeof t.style&&Z("62",n()))}function _a(e,t){if(-1===e.indexOf("-"))return"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ka=a.thatReturns("");function xa(e,t){var n=ks(e=9===e.nodeType||11===e.nodeType?e:e.ownerDocument);t=le[t];for(var s=0;s<\/script>",e=e.removeChild(e.firstChild)):e="string"==typeof t.is?n.createElement(e,{is:t.is}):n.createElement(e):e=n.createElementNS(s,e),e}function Na(e,t){return(9===t.nodeType?t:t.ownerDocument).createTextNode(e)}function Pa(e,t,n,s){var i=_a(t,n);switch(t){case"iframe":case"object":bs("load",e);var r=n;break;case"video":case"audio":for(r=0;rGa||(e.current=Ba[Ga],Ba[Ga]=null,Ga--)}function $a(e,t){Ba[++Ga]=e.current,e.current=t}var Ja=Ka(o),Xa=Ka(!1),Ya=o;function Za(e){return ti(e)?Ya:Ja.current}function ei(e,t){var n=e.type.contextTypes;if(!n)return o;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===t)return s.__reactInternalMemoizedMaskedChildContext;var a,i={};for(a in n)i[a]=t[a];return s&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function ti(e){return 2===e.tag&&null!=e.type.childContextTypes}function ni(e){ti(e)&&(Qa(Xa),Qa(Ja))}function si(e){Qa(Xa),Qa(Ja)}function ai(e,t,n){Ja.current!==o&&Z("168"),$a(Ja,t),$a(Xa,n)}function ii(e,t){var n=e.stateNode,s=e.type.childContextTypes;if("function"!=typeof n.getChildContext)return t;for(var a in n=n.getChildContext())a in s||Z("108",on(e)||"Unknown",a);return g({},t,n)}function ri(e){if(!ti(e))return!1;var t=e.stateNode;return t=t&&t.__reactInternalMemoizedMergedChildContext||o,Ya=Ja.current,$a(Ja,t),$a(Xa,Xa.current),!0}function oi(e,t){var n=e.stateNode;if(n||Z("169"),t){var s=ii(e,Ya);n.__reactInternalMemoizedMergedChildContext=s,Qa(Xa),Qa(Ja),$a(Ja,s)}else Qa(Xa);$a(Xa,t)}function li(e,t,n,s){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=null,this.index=0,this.ref=null,this.pendingProps=t,this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.effectTag=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.expirationTime=0,this.alternate=null}function ci(e,t,n){var s=e.alternate;return null===s?((s=new li(e.tag,t,e.key,e.mode)).type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.effectTag=0,s.nextEffect=null,s.firstEffect=null,s.lastEffect=null),s.expirationTime=n,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function ui(e,t,n){var s=e.type,a=e.key;if(e=e.props,"function"==typeof s)var i=s.prototype&&s.prototype.isReactComponent?2:0;else if("string"==typeof s)i=5;else switch(s){case Jt:return di(e.children,t,n,a);case tn:i=11,t|=3;break;case Xt:i=11,t|=2;break;case Yt:return(s=new li(15,e,a,4|t)).type=Yt,s.expirationTime=n,s;case sn:i=16,t|=2;break;default:e:{switch("object"==typeof s&&null!==s?s.$$typeof:null){case Zt:i=13;break e;case en:i=12;break e;case nn:i=14;break e;default:Z("130",null==s?s:typeof s,"")}i=void 0}}return(t=new li(i,e,a,t)).type=s,t.expirationTime=n,t}function di(e,t,n,s){return(e=new li(10,e,s,t)).expirationTime=n,e}function hi(e,t,n){return(e=new li(6,e,null,t)).expirationTime=n,e}function pi(e,t,n){return(t=new li(4,null!==e.children?e.children:[],e.key,t)).expirationTime=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var mi=null,fi=null;function gi(e){return function(t){try{return e(t)}catch(e){}}}var vi=!1;function bi(e){return{expirationTime:0,baseState:e,firstUpdate:null,lastUpdate:null,firstCapturedUpdate:null,lastCapturedUpdate:null,firstEffect:null,lastEffect:null,firstCapturedEffect:null,lastCapturedEffect:null}}function yi(e){return{expirationTime:e.expirationTime,baseState:e.baseState,firstUpdate:e.firstUpdate,lastUpdate:e.lastUpdate,firstCapturedUpdate:null,lastCapturedUpdate:null,firstEffect:null,lastEffect:null,firstCapturedEffect:null,lastCapturedEffect:null}}function wi(e){return{expirationTime:e,tag:0,payload:null,callback:null,next:null,nextEffect:null}}function Ei(e,t,n){null===e.lastUpdate?e.firstUpdate=e.lastUpdate=t:(e.lastUpdate.next=t,e.lastUpdate=t),(0===e.expirationTime||e.expirationTime>n)&&(e.expirationTime=n)}function Si(e,t,n){var s=e.alternate;if(null===s){var a=e.updateQueue,i=null;null===a&&(a=e.updateQueue=bi(e.memoizedState))}else a=e.updateQueue,i=s.updateQueue,null===a?null===i?(a=e.updateQueue=bi(e.memoizedState),i=s.updateQueue=bi(s.memoizedState)):a=e.updateQueue=yi(i):null===i&&(i=s.updateQueue=yi(a));null===i||a===i?Ei(a,t,n):null===a.lastUpdate||null===i.lastUpdate?(Ei(a,t,n),Ei(i,t,n)):(Ei(a,t,n),i.lastUpdate=t)}function Ci(e,t,n){var s=e.updateQueue;null===(s=null===s?e.updateQueue=bi(e.memoizedState):Ti(e,s)).lastCapturedUpdate?s.firstCapturedUpdate=s.lastCapturedUpdate=t:(s.lastCapturedUpdate.next=t,s.lastCapturedUpdate=t),(0===s.expirationTime||s.expirationTime>n)&&(s.expirationTime=n)}function Ti(e,t){var n=e.alternate;return null!==n&&t===n.updateQueue&&(t=e.updateQueue=yi(t)),t}function _i(e,t,n,s,a,i){switch(n.tag){case 1:return"function"==typeof(e=n.payload)?e.call(i,s,a):e;case 3:e.effectTag=-1025&e.effectTag|64;case 0:if(null==(a="function"==typeof(e=n.payload)?e.call(i,s,a):e))break;return g({},s,a);case 2:vi=!0}return s}function ki(e,t,n,s,a){if(vi=!1,!(0===t.expirationTime||t.expirationTime>a)){for(var i=(t=Ti(e,t)).baseState,r=null,o=0,l=t.firstUpdate,c=i;null!==l;){var u=l.expirationTime;u>a?(null===r&&(r=l,i=c),(0===o||o>u)&&(o=u)):(c=_i(e,0,l,c,n,s),null!==l.callback&&(e.effectTag|=32,l.nextEffect=null,null===t.lastEffect?t.firstEffect=t.lastEffect=l:(t.lastEffect.nextEffect=l,t.lastEffect=l))),l=l.next}for(u=null,l=t.firstCapturedUpdate;null!==l;){var d=l.expirationTime;d>a?(null===u&&(u=l,null===r&&(i=c)),(0===o||o>d)&&(o=d)):(c=_i(e,0,l,c,n,s),null!==l.callback&&(e.effectTag|=32,l.nextEffect=null,null===t.lastCapturedEffect?t.firstCapturedEffect=t.lastCapturedEffect=l:(t.lastCapturedEffect.nextEffect=l,t.lastCapturedEffect=l))),l=l.next}null===r&&(t.lastUpdate=null),null===u?t.lastCapturedUpdate=null:e.effectTag|=32,null===r&&null===u&&(i=c),t.baseState=i,t.firstUpdate=r,t.firstCapturedUpdate=u,t.expirationTime=o,e.memoizedState=c}}function xi(e,t){"function"!=typeof e&&Z("191",e),e.call(t)}function Mi(e,t,n){for(null!==t.firstCapturedUpdate&&(null!==t.lastUpdate&&(t.lastUpdate.next=t.firstCapturedUpdate,t.lastUpdate=t.lastCapturedUpdate),t.firstCapturedUpdate=t.lastCapturedUpdate=null),e=t.firstEffect,t.firstEffect=t.lastEffect=null;null!==e;){var s=e.callback;null!==s&&(e.callback=null,xi(s,n)),e=e.nextEffect}for(e=t.firstCapturedEffect,t.firstCapturedEffect=t.lastCapturedEffect=null;null!==e;)null!==(t=e.callback)&&(e.callback=null,xi(t,n)),e=e.nextEffect}function Ni(e,t){return{value:e,source:t,stack:ln(t)}}var Pi=Ka(null),Ui=Ka(null),Di=Ka(0);function Ai(e){var t=e.type._context;$a(Di,t._changedBits),$a(Ui,t._currentValue),$a(Pi,e),t._currentValue=e.pendingProps.value,t._changedBits=e.stateNode}function Ii(e){var t=Di.current,n=Ui.current;Qa(Pi),Qa(Ui),Qa(Di),(e=e.type._context)._currentValue=n,e._changedBits=t}var Ri={},Oi=Ka(Ri),Li=Ka(Ri),Fi=Ka(Ri);function qi(e){return e===Ri&&Z("174"),e}function ji(e,t){$a(Fi,t),$a(Li,e),$a(Oi,Ri);var n=t.nodeType;switch(n){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:fa(null,"");break;default:t=fa(t=(n=8===n?t.parentNode:t).namespaceURI||null,n=n.tagName)}Qa(Oi),$a(Oi,t)}function zi(e){Qa(Oi),Qa(Li),Qa(Fi)}function Wi(e){Li.current===e&&(Qa(Oi),Qa(Li))}function Vi(e,t,n){var s=e.memoizedState;s=null==(t=t(n,s))?s:g({},s,t),e.memoizedState=s,null!==(e=e.updateQueue)&&0===e.expirationTime&&(e.baseState=s)}var Hi={isMounted:function(e){return!!(e=e._reactInternalFiber)&&2===Qn(e)},enqueueSetState:function(e,t,n){e=e._reactInternalFiber;var s=eo(),a=wi(s=Yr(s,e));a.payload=t,null!=n&&(a.callback=n),Si(e,a,s),Zr(e,s)},enqueueReplaceState:function(e,t,n){e=e._reactInternalFiber;var s=eo(),a=wi(s=Yr(s,e));a.tag=1,a.payload=t,null!=n&&(a.callback=n),Si(e,a,s),Zr(e,s)},enqueueForceUpdate:function(e,t){e=e._reactInternalFiber;var n=eo(),s=wi(n=Yr(n,e));s.tag=2,null!=t&&(s.callback=t),Si(e,s,n),Zr(e,n)}};function Bi(e,t,n,s,a,i){var r=e.stateNode;return e=e.type,"function"==typeof r.shouldComponentUpdate?r.shouldComponentUpdate(n,a,i):!(e.prototype&&e.prototype.isPureReactComponent&&h(t,n)&&h(s,a))}function Gi(e,t,n,s){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,s),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,s),t.state!==e&&Hi.enqueueReplaceState(t,t.state,null)}function Ki(e,t){var n=e.type,s=e.stateNode,a=e.pendingProps,i=Za(e);s.props=a,s.state=e.memoizedState,s.refs=o,s.context=ei(e,i),null!==(i=e.updateQueue)&&(ki(e,i,a,s,t),s.state=e.memoizedState),"function"==typeof(i=e.type.getDerivedStateFromProps)&&(Vi(e,i,a),s.state=e.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof s.getSnapshotBeforeUpdate||"function"!=typeof s.UNSAFE_componentWillMount&&"function"!=typeof s.componentWillMount||(n=s.state,"function"==typeof s.componentWillMount&&s.componentWillMount(),"function"==typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount(),n!==s.state&&Hi.enqueueReplaceState(s,s.state,null),null!==(i=e.updateQueue)&&(ki(e,i,a,s,t),s.state=e.memoizedState)),"function"==typeof s.componentDidMount&&(e.effectTag|=4)}var Qi=Array.isArray;function $i(e,t,n){if(null!==(e=n.ref)&&"function"!=typeof e&&"object"!=typeof e){if(n._owner){n=n._owner;var s=void 0;n&&(2!==n.tag&&Z("110"),s=n.stateNode),s||Z("147",e);var a=""+e;return null!==t&&null!==t.ref&&"function"==typeof t.ref&&t.ref._stringRef===a?t.ref:((t=function(e){var t=s.refs===o?s.refs={}:s.refs;null===e?delete t[a]:t[a]=e})._stringRef=a,t)}"string"!=typeof e&&Z("148"),n._owner||Z("254",e)}return e}function Ji(e,t){"textarea"!==e.type&&Z("31","[object Object]"===Object.prototype.toString.call(t)?"object with keys {"+Object.keys(t).join(", ")+"}":t,"")}function Xi(e){function t(t,n){if(e){var s=t.lastEffect;null!==s?(s.nextEffect=n,t.lastEffect=n):t.firstEffect=t.lastEffect=n,n.nextEffect=null,n.effectTag=8}}function n(n,s){if(!e)return null;for(;null!==s;)t(n,s),s=s.sibling;return null}function s(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function a(e,t,n){return(e=ci(e,t,n)).index=0,e.sibling=null,e}function i(t,n,s){return t.index=s,e?null!==(s=t.alternate)?(s=s.index)f?(g=m,m=null):g=m.sibling;var v=h(a,m,o[f],l);if(null===v){null===m&&(m=g);break}e&&m&&null===v.alternate&&t(a,m),r=i(v,r,f),null===u?c=v:u.sibling=v,u=v,m=g}if(f===o.length)return n(a,m),c;if(null===m){for(;ff?(g=m,m=null):g=m.sibling;var b=h(a,m,v.value,l);if(null===b){m||(m=g);break}e&&m&&null===b.alternate&&t(a,m),r=i(b,r,f),null===u?c=b:u.sibling=b,u=b,m=g}if(v.done)return n(a,m),c;if(null===m){for(;!v.done;f++,v=o.next())null!==(v=d(a,v.value,l))&&(r=i(v,r,f),null===u?c=v:u.sibling=v,u=v);return c}for(m=s(a,m);!v.done;f++,v=o.next())null!==(v=p(m,a,f,v.value,l))&&(e&&null!==v.alternate&&m.delete(null===v.key?f:v.key),r=i(v,r,f),null===u?c=v:u.sibling=v,u=v);return e&&m.forEach(function(e){return t(a,e)}),c}return function(e,s,i,o){var l="object"==typeof i&&null!==i&&i.type===Jt&&null===i.key;l&&(i=i.props.children);var c="object"==typeof i&&null!==i;if(c)switch(i.$$typeof){case Qt:e:{for(c=i.key,l=s;null!==l;){if(l.key===c){if(10===l.tag?i.type===Jt:l.type===i.type){n(e,l.sibling),(s=a(l,i.type===Jt?i.props.children:i.props,o)).ref=$i(e,l,i),s.return=e,e=s;break e}n(e,l);break}t(e,l),l=l.sibling}i.type===Jt?((s=di(i.props.children,e.mode,o,i.key)).return=e,e=s):((o=ui(i,e.mode,o)).ref=$i(e,s,i),o.return=e,e=o)}return r(e);case $t:e:{for(l=i.key;null!==s;){if(s.key===l){if(4===s.tag&&s.stateNode.containerInfo===i.containerInfo&&s.stateNode.implementation===i.implementation){n(e,s.sibling),(s=a(s,i.children||[],o)).return=e,e=s;break e}n(e,s);break}t(e,s),s=s.sibling}(s=pi(i,e.mode,o)).return=e,e=s}return r(e)}if("string"==typeof i||"number"==typeof i)return i=""+i,null!==s&&6===s.tag?(n(e,s.sibling),(s=a(s,i,o)).return=e,e=s):(n(e,s),(s=hi(i,e.mode,o)).return=e,e=s),r(e);if(Qi(i))return m(e,s,i,o);if(rn(i))return f(e,s,i,o);if(c&&Ji(e,i),void 0===i&&!l)switch(e.tag){case 2:case 1:Z("152",(o=e.type).displayName||o.name||"Component")}return n(e,s)}}var Yi=Xi(!0),Zi=Xi(!1),er=null,tr=null,nr=!1;function sr(e,t){var n=new li(5,null,null,0);n.type="DELETED",n.stateNode=t,n.return=e,n.effectTag=8,null!==e.lastEffect?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}function ar(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,!0);default:return!1}}function ir(e){if(nr){var t=tr;if(t){var n=t;if(!ar(e,t)){if(!(t=Va(n))||!ar(e,t))return e.effectTag|=2,nr=!1,void(er=e);sr(er,n)}er=e,tr=Ha(t)}else e.effectTag|=2,nr=!1,er=e}}function rr(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag;)e=e.return;er=e}function or(e){if(e!==er)return!1;if(!nr)return rr(e),nr=!0,!1;var t=e.type;if(5!==e.tag||"head"!==t&&"body"!==t&&!qa(t,e.memoizedProps))for(t=tr;t;)sr(e,t),t=Va(t);return rr(e),tr=er?Va(e.stateNode):null,!0}function lr(){tr=er=null,nr=!1}function cr(e,t,n){ur(e,t,n,t.expirationTime)}function ur(e,t,n,s){t.child=null===e?Zi(t,null,n,s):Yi(t,e.child,n,s)}function dr(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.effectTag|=128)}function hr(e,t,n,s,a){dr(e,t);var i=0!=(64&t.effectTag);if(!n&&!i)return s&&oi(t,!1),fr(e,t);n=t.stateNode,Gt.current=t;var r=i?null:n.render();return t.effectTag|=1,i&&(ur(e,t,null,a),t.child=null),ur(e,t,r,a),t.memoizedState=n.state,t.memoizedProps=n.props,s&&oi(t,!0),t.child}function pr(e){var t=e.stateNode;t.pendingContext?ai(0,t.pendingContext,t.pendingContext!==t.context):t.context&&ai(0,t.context,!1),ji(e,t.containerInfo)}function mr(e,t,n,s){var a=e.child;for(null!==a&&(a.return=e);null!==a;){switch(a.tag){case 12:var i=0|a.stateNode;if(a.type===t&&0!=(i&n)){for(i=a;null!==i;){var r=i.alternate;if(0===i.expirationTime||i.expirationTime>s)i.expirationTime=s,null!==r&&(0===r.expirationTime||r.expirationTime>s)&&(r.expirationTime=s);else{if(null===r||!(0===r.expirationTime||r.expirationTime>s))break;r.expirationTime=s}i=i.return}i=null}else i=a.child;break;case 13:i=a.type===e.type?null:a.child;break;default:i=a.child}if(null!==i)i.return=a;else for(i=a;null!==i;){if(i===e){i=null;break}if(null!==(a=i.sibling)){a.return=i.return,i=a;break}i=i.return}a=i}}function fr(e,t){if(null!==e&&t.child!==e.child&&Z("153"),null!==t.child){var n=ci(e=t.child,e.pendingProps,e.expirationTime);for(t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=ci(e,e.pendingProps,e.expirationTime)).return=t;n.sibling=null}return t.child}function gr(e){e.effectTag|=4}var vr=void 0,br=void 0,yr=void 0;function wr(e,t){var n=t.pendingProps;switch(t.tag){case 1:return null;case 2:return ni(t),null;case 3:zi(),si();var s=t.stateNode;return s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),null!==e&&null!==e.child||(or(t),t.effectTag&=-3),vr(t),null;case 5:Wi(t),s=qi(Fi.current);var a=t.type;if(null!==e&&null!=t.stateNode){var i=e.memoizedProps,r=t.stateNode,o=qi(Oi.current);r=Ua(r,a,i,n,s),br(e,t,r,a,i,n,s,o),e.ref!==t.ref&&(t.effectTag|=128)}else{if(!n)return null===t.stateNode&&Z("166"),null;if(e=qi(Oi.current),or(t))n=t.stateNode,a=t.type,i=t.memoizedProps,n[Me]=t,n[Ne]=i,s=Aa(n,a,i,e,s),t.updateQueue=s,null!==s&&gr(t);else{(e=Ma(a,n,s,e))[Me]=t,e[Ne]=n;e:for(i=t.child;null!==i;){if(5===i.tag||6===i.tag)e.appendChild(i.stateNode);else if(4!==i.tag&&null!==i.child){i.child.return=i,i=i.child;continue}if(i===t)break;for(;null===i.sibling;){if(null===i.return||i.return===t)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}Pa(e,a,n,s),Fa(a,n)&&gr(t),t.stateNode=e}null!==t.ref&&(t.effectTag|=128)}return null;case 6:if(e&&null!=t.stateNode)yr(e,t,e.memoizedProps,n);else{if("string"!=typeof n)return null===t.stateNode&&Z("166"),null;s=qi(Fi.current),qi(Oi.current),or(t)?(s=t.stateNode,n=t.memoizedProps,s[Me]=t,Ia(s,n)&&gr(t)):((s=Na(n,s))[Me]=t,t.stateNode=s)}return null;case 14:case 16:case 10:case 11:case 15:return null;case 4:return zi(),vr(t),null;case 13:return Ii(t),null;case 12:return null;case 0:Z("167");default:Z("156")}}function Er(e,t){var n=t.source;null===t.stack&&null!==n&&ln(n),null!==n&&on(n),t=t.value,null!==e&&2===e.tag&&on(e);try{t&&t.suppressReactErrorLogging||console.error(t)}catch(e){e&&e.suppressReactErrorLogging||console.error(e)}}function Sr(e){var t=e.ref;if(null!==t)if("function"==typeof t)try{t(null)}catch(t){Xr(e,t)}else t.current=null}function Cr(e){switch(function(e){"function"==typeof fi&&fi(e)}(e),e.tag){case 2:Sr(e);var t=e.stateNode;if("function"==typeof t.componentWillUnmount)try{t.props=e.memoizedProps,t.state=e.memoizedState,t.componentWillUnmount()}catch(t){Xr(e,t)}break;case 5:Sr(e);break;case 4:kr(e)}}function Tr(e){return 5===e.tag||3===e.tag||4===e.tag}function _r(e){e:{for(var t=e.return;null!==t;){if(Tr(t)){var n=t;break e}t=t.return}Z("160"),n=void 0}var s=t=void 0;switch(n.tag){case 5:t=n.stateNode,s=!1;break;case 3:case 4:t=n.stateNode.containerInfo,s=!0;break;default:Z("161")}16&n.effectTag&&(ya(t,""),n.effectTag&=-17);e:t:for(n=e;;){for(;null===n.sibling;){if(null===n.return||Tr(n.return)){n=null;break e}n=n.return}for(n.sibling.return=n.return,n=n.sibling;5!==n.tag&&6!==n.tag;){if(2&n.effectTag)continue t;if(null===n.child||4===n.tag)continue t;n.child.return=n,n=n.child}if(!(2&n.effectTag)){n=n.stateNode;break e}}for(var a=e;;){if(5===a.tag||6===a.tag)if(n)if(s){var i=t,r=a.stateNode,o=n;8===i.nodeType?i.parentNode.insertBefore(r,o):i.insertBefore(r,o)}else t.insertBefore(a.stateNode,n);else s?(i=t,r=a.stateNode,8===i.nodeType?i.parentNode.insertBefore(r,i):i.appendChild(r)):t.appendChild(a.stateNode);else if(4!==a.tag&&null!==a.child){a.child.return=a,a=a.child;continue}if(a===e)break;for(;null===a.sibling;){if(null===a.return||a.return===e)return;a=a.return}a.sibling.return=a.return,a=a.sibling}}function kr(e){for(var t=e,n=!1,s=void 0,a=void 0;;){if(!n){n=t.return;e:for(;;){switch(null===n&&Z("160"),n.tag){case 5:s=n.stateNode,a=!1;break e;case 3:case 4:s=n.stateNode.containerInfo,a=!0;break e}n=n.return}n=!0}if(5===t.tag||6===t.tag){e:for(var i=t,r=i;;)if(Cr(r),null!==r.child&&4!==r.tag)r.child.return=r,r=r.child;else{if(r===i)break;for(;null===r.sibling;){if(null===r.return||r.return===i)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}a?(i=s,r=t.stateNode,8===i.nodeType?i.parentNode.removeChild(r):i.removeChild(r)):s.removeChild(t.stateNode)}else if(4===t.tag?s=t.stateNode.containerInfo:Cr(t),null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;4===(t=t.return).tag&&(n=!1)}t.sibling.return=t.return,t=t.sibling}}function xr(e,t){switch(t.tag){case 2:break;case 5:var n=t.stateNode;if(null!=n){var s=t.memoizedProps;e=null!==e?e.memoizedProps:s;var a=t.type,i=t.updateQueue;t.updateQueue=null,null!==i&&(n[Ne]=s,Da(n,i,a,e,s))}break;case 6:null===t.stateNode&&Z("162"),t.stateNode.nodeValue=t.memoizedProps;break;case 3:case 15:case 16:break;default:Z("163")}}function Mr(e,t,n){(n=wi(n)).tag=3,n.payload={element:null};var s=t.value;return n.callback=function(){Do(s),Er(e,t)},n}function Nr(e,t,n){(n=wi(n)).tag=3;var s=e.stateNode;return null!==s&&"function"==typeof s.componentDidCatch&&(n.callback=function(){null===Gr?Gr=new Set([this]):Gr.add(this);var n=t.value,s=t.stack;Er(e,t),this.componentDidCatch(n,{componentStack:null!==s?s:""})}),n}function Pr(e,t,n,s,a,i){n.effectTag|=512,n.firstEffect=n.lastEffect=null,s=Ni(s,n),e=t;do{switch(e.tag){case 3:return e.effectTag|=1024,void Ci(e,s=Mr(e,s,i),i);case 2:if(t=s,n=e.stateNode,0==(64&e.effectTag)&&null!==n&&"function"==typeof n.componentDidCatch&&(null===Gr||!Gr.has(n)))return e.effectTag|=1024,void Ci(e,s=Nr(e,t,i),i)}e=e.return}while(null!==e)}function Ur(e){switch(e.tag){case 2:ni(e);var t=e.effectTag;return 1024&t?(e.effectTag=-1025&t|64,e):null;case 3:return zi(),si(),1024&(t=e.effectTag)?(e.effectTag=-1025&t|64,e):null;case 5:return Wi(e),null;case 16:return 1024&(t=e.effectTag)?(e.effectTag=-1025&t|64,e):null;case 4:return zi(),null;case 13:return Ii(e),null;default:return null}}vr=function(){},br=function(e,t,n){(t.updateQueue=n)&&gr(t)},yr=function(e,t,n,s){n!==s&&gr(t)};var Dr=ja(),Ar=2,Ir=Dr,Rr=0,Or=0,Lr=!1,Fr=null,qr=null,jr=0,zr=-1,Wr=!1,Vr=null,Hr=!1,Br=!1,Gr=null;function Kr(){if(null!==Fr)for(var e=Fr.return;null!==e;){var t=e;switch(t.tag){case 2:ni(t);break;case 3:zi(),si();break;case 5:Wi(t);break;case 4:zi();break;case 13:Ii(t)}e=e.return}qr=null,jr=0,zr=-1,Wr=!1,Fr=null,Br=!1}function Qr(e){for(;;){var t=e.alternate,n=e.return,s=e.sibling;if(0==(512&e.effectTag)){t=wr(t,e);var a=e;if(1073741823===jr||1073741823!==a.expirationTime){var i=0;switch(a.tag){case 3:case 2:var r=a.updateQueue;null!==r&&(i=r.expirationTime)}for(r=a.child;null!==r;)0!==r.expirationTime&&(0===i||i>r.expirationTime)&&(i=r.expirationTime),r=r.sibling;a.expirationTime=i}if(null!==t)return t;if(null!==n&&0==(512&n.effectTag)&&(null===n.firstEffect&&(n.firstEffect=e.firstEffect),null!==e.lastEffect&&(null!==n.lastEffect&&(n.lastEffect.nextEffect=e.firstEffect),n.lastEffect=e.lastEffect),1n){switch(t.tag){case 3:pr(t);break;case 2:ri(t);break;case 4:ji(t,t.stateNode.containerInfo);break;case 13:Ai(t)}return null}switch(t.tag){case 0:null!==e&&Z("155");var s=t.type,a=t.pendingProps,i=Za(t);return s=s(a,i=ei(t,i)),t.effectTag|=1,"object"==typeof s&&null!==s&&"function"==typeof s.render&&void 0===s.$$typeof?(i=t.type,t.tag=2,t.memoizedState=null!==s.state&&void 0!==s.state?s.state:null,"function"==typeof(i=i.getDerivedStateFromProps)&&Vi(t,i,a),a=ri(t),s.updater=Hi,t.stateNode=s,s._reactInternalFiber=t,Ki(t,n),e=hr(e,t,!0,a,n)):(t.tag=1,cr(e,t,s),t.memoizedProps=a,e=t.child),e;case 1:return a=t.type,n=t.pendingProps,Xa.current||t.memoizedProps!==n?(a=a(n,s=ei(t,s=Za(t))),t.effectTag|=1,cr(e,t,a),t.memoizedProps=n,e=t.child):e=fr(e,t),e;case 2:if(a=ri(t),null===e)if(null===t.stateNode){var r=t.pendingProps,l=t.type;s=Za(t);var c=2===t.tag&&null!=t.type.contextTypes;r=new l(r,i=c?ei(t,s):o),t.memoizedState=null!==r.state&&void 0!==r.state?r.state:null,r.updater=Hi,t.stateNode=r,r._reactInternalFiber=t,c&&((c=t.stateNode).__reactInternalMemoizedUnmaskedChildContext=s,c.__reactInternalMemoizedMaskedChildContext=i),Ki(t,n),s=!0}else{l=t.type,s=t.stateNode,c=t.memoizedProps,i=t.pendingProps,s.props=c;var u=s.context;r=ei(t,r=Za(t));var d=l.getDerivedStateFromProps;(l="function"==typeof d||"function"==typeof s.getSnapshotBeforeUpdate)||"function"!=typeof s.UNSAFE_componentWillReceiveProps&&"function"!=typeof s.componentWillReceiveProps||(c!==i||u!==r)&&Gi(t,s,i,r),vi=!1;var h=t.memoizedState;u=s.state=h;var p=t.updateQueue;null!==p&&(ki(t,p,i,s,n),u=t.memoizedState),c!==i||h!==u||Xa.current||vi?("function"==typeof d&&(Vi(t,d,i),u=t.memoizedState),(c=vi||Bi(t,c,i,h,u,r))?(l||"function"!=typeof s.UNSAFE_componentWillMount&&"function"!=typeof s.componentWillMount||("function"==typeof s.componentWillMount&&s.componentWillMount(),"function"==typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount()),"function"==typeof s.componentDidMount&&(t.effectTag|=4)):("function"==typeof s.componentDidMount&&(t.effectTag|=4),t.memoizedProps=i,t.memoizedState=u),s.props=i,s.state=u,s.context=r,s=c):("function"==typeof s.componentDidMount&&(t.effectTag|=4),s=!1)}else l=t.type,s=t.stateNode,i=t.memoizedProps,c=t.pendingProps,s.props=i,u=s.context,r=ei(t,r=Za(t)),(l="function"==typeof(d=l.getDerivedStateFromProps)||"function"==typeof s.getSnapshotBeforeUpdate)||"function"!=typeof s.UNSAFE_componentWillReceiveProps&&"function"!=typeof s.componentWillReceiveProps||(i!==c||u!==r)&&Gi(t,s,c,r),vi=!1,u=t.memoizedState,h=s.state=u,null!==(p=t.updateQueue)&&(ki(t,p,c,s,n),h=t.memoizedState),i!==c||u!==h||Xa.current||vi?("function"==typeof d&&(Vi(t,d,c),h=t.memoizedState),(d=vi||Bi(t,i,c,u,h,r))?(l||"function"!=typeof s.UNSAFE_componentWillUpdate&&"function"!=typeof s.componentWillUpdate||("function"==typeof s.componentWillUpdate&&s.componentWillUpdate(c,h,r),"function"==typeof s.UNSAFE_componentWillUpdate&&s.UNSAFE_componentWillUpdate(c,h,r)),"function"==typeof s.componentDidUpdate&&(t.effectTag|=4),"function"==typeof s.getSnapshotBeforeUpdate&&(t.effectTag|=256)):("function"!=typeof s.componentDidUpdate||i===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),"function"!=typeof s.getSnapshotBeforeUpdate||i===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),t.memoizedProps=c,t.memoizedState=h),s.props=c,s.state=h,s.context=r,s=d):("function"!=typeof s.componentDidUpdate||i===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),"function"!=typeof s.getSnapshotBeforeUpdate||i===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),s=!1);return hr(e,t,s,a,n);case 3:return pr(t),null!==(a=t.updateQueue)?(s=null!==(s=t.memoizedState)?s.element:null,ki(t,a,t.pendingProps,null,n),(a=t.memoizedState.element)===s?(lr(),e=fr(e,t)):(s=t.stateNode,(s=(null===e||null===e.child)&&s.hydrate)&&(tr=Ha(t.stateNode.containerInfo),er=t,s=nr=!0),s?(t.effectTag|=2,t.child=Zi(t,null,a,n)):(lr(),cr(e,t,a)),e=t.child)):(lr(),e=fr(e,t)),e;case 5:return qi(Fi.current),(a=qi(Oi.current))!==(s=fa(a,t.type))&&($a(Li,t),$a(Oi,s)),null===e&&ir(t),a=t.type,c=t.memoizedProps,s=t.pendingProps,i=null!==e?e.memoizedProps:null,Xa.current||c!==s||((c=1&t.mode&&!!s.hidden)&&(t.expirationTime=1073741823),c&&1073741823===n)?(c=s.children,qa(a,s)?c=null:i&&qa(a,i)&&(t.effectTag|=16),dr(e,t),1073741823!==n&&1&t.mode&&s.hidden?(t.expirationTime=1073741823,t.memoizedProps=s,e=null):(cr(e,t,c),t.memoizedProps=s,e=t.child)):e=fr(e,t),e;case 6:return null===e&&ir(t),t.memoizedProps=t.pendingProps,null;case 16:return null;case 4:return ji(t,t.stateNode.containerInfo),a=t.pendingProps,Xa.current||t.memoizedProps!==a?(null===e?t.child=Yi(t,null,a,n):cr(e,t,a),t.memoizedProps=a,e=t.child):e=fr(e,t),e;case 14:return a=t.type.render,n=t.pendingProps,s=t.ref,Xa.current||t.memoizedProps!==n||s!==(null!==e?e.ref:null)?(cr(e,t,a=a(n,s)),t.memoizedProps=n,e=t.child):e=fr(e,t),e;case 10:return n=t.pendingProps,Xa.current||t.memoizedProps!==n?(cr(e,t,n),t.memoizedProps=n,e=t.child):e=fr(e,t),e;case 11:return n=t.pendingProps.children,Xa.current||null!==n&&t.memoizedProps!==n?(cr(e,t,n),t.memoizedProps=n,e=t.child):e=fr(e,t),e;case 15:return n=t.pendingProps,t.memoizedProps===n?e=fr(e,t):(cr(e,t,n.children),t.memoizedProps=n,e=t.child),e;case 13:return function(e,t,n){var s=t.type._context,a=t.pendingProps,i=t.memoizedProps,r=!0;if(Xa.current)r=!1;else if(i===a)return t.stateNode=0,Ai(t),fr(e,t);var o=a.value;if(t.memoizedProps=a,null===i)o=1073741823;else if(i.value===a.value){if(i.children===a.children&&r)return t.stateNode=0,Ai(t),fr(e,t);o=0}else{var l=i.value;if(l===o&&(0!==l||1/l==1/o)||l!=l&&o!=o){if(i.children===a.children&&r)return t.stateNode=0,Ai(t),fr(e,t);o=0}else if(o="function"==typeof s._calculateChangedBits?s._calculateChangedBits(l,o):1073741823,0==(o|=0)){if(i.children===a.children&&r)return t.stateNode=0,Ai(t),fr(e,t)}else mr(t,s,o,n)}return t.stateNode=o,Ai(t),cr(e,t,a.children),t.child}(e,t,n);case 12:e:if(s=t.type,i=t.pendingProps,c=t.memoizedProps,a=s._currentValue,r=s._changedBits,Xa.current||0!==r||c!==i){if(t.memoizedProps=i,null==(l=i.unstable_observedBits)&&(l=1073741823),t.stateNode=l,0!=(r&l))mr(t,s,r,n);else if(c===i){e=fr(e,t);break e}n=(n=i.children)(a),t.effectTag|=1,cr(e,t,n),e=t.child}else e=fr(e,t);return e;default:Z("156")}}(e.alternate,e,jr);return null===t&&(t=Qr(e)),Gt.current=null,t}function Jr(e,t,n){Lr&&Z("243"),Lr=!0,t===jr&&e===qr&&null!==Fr||(Kr(),jr=t,zr=-1,Fr=ci((qr=e).current,null,jr),e.pendingCommitExpirationTime=0);var s=!1;for(Wr=!n||jr<=Ar;;){try{if(n)for(;null!==Fr&&!Uo();)Fr=$r(Fr);else for(;null!==Fr;)Fr=$r(Fr)}catch(t){if(null===Fr)s=!0,Do(t);else{null===Fr&&Z("271");var a=(n=Fr).return;if(null===a){s=!0,Do(t);break}Pr(e,a,n,t,0,jr),Fr=Qr(n)}}break}if(Lr=!1,s)return null;if(null===Fr){if(Br)return e.pendingCommitExpirationTime=t,e.current.alternate;Wr&&Z("262"),0<=zr&&setTimeout(function(){var t=e.current.expirationTime;0!==t&&(0===e.remainingExpirationTime||e.remainingExpirationTimeco)&&(co=e),e}function Zr(e,t){for(;null!==e;){if((0===e.expirationTime||e.expirationTime>t)&&(e.expirationTime=t),null!==e.alternate&&(0===e.alternate.expirationTime||e.alternate.expirationTime>t)&&(e.alternate.expirationTime=t),null===e.return){if(3!==e.tag)break;var n=e.stateNode;!Lr&&0!==jr&&tyo&&Z("185")}e=e.return}}function eo(){return Ir=ja()-Dr,Ar=2+(Ir/10|0)}function to(e,t,n,s,a){var i=Or;Or=1;try{return e(t,n,s,a)}finally{Or=i}}var no=null,so=null,ao=0,io=void 0,ro=!1,oo=null,lo=0,co=0,uo=!1,ho=!1,po=null,mo=null,fo=!1,go=!1,vo=!1,bo=null,yo=1e3,wo=0,Eo=1;function So(e){if(0!==ao){if(e>ao)return;null!==io&&Wa(io)}var t=ja()-Dr;ao=e,io=za(_o,{timeout:10*(e-2)-t})}function Co(e,t){if(null===e.nextScheduledRoot)e.remainingExpirationTime=t,null===so?(no=so=e,e.nextScheduledRoot=e):(so=so.nextScheduledRoot=e).nextScheduledRoot=no;else{var n=e.remainingExpirationTime;(0===n||t=lo)&&(!uo||eo()>=lo);)eo(),No(oo,lo,!uo),To();else for(;null!==oo&&0!==lo&&(0===e||e>=lo);)No(oo,lo,!1),To();null!==mo&&(ao=0,io=null),0!==lo&&So(lo),mo=null,uo=!1,Mo()}function Mo(){if(wo=0,null!==bo){var e=bo;bo=null;for(var t=0;tw&&(E=w,w=x,x=E),E=Ms(_,x),S=Ms(_,w),E&&S&&(1!==k.rangeCount||k.anchorNode!==E.node||k.anchorOffset!==E.offset||k.focusNode!==S.node||k.focusOffset!==S.offset)&&((C=document.createRange()).setStart(E.node,E.offset),k.removeAllRanges(),x>w?(k.addRange(C),k.extend(S.node,S.offset)):(C.setEnd(S.node,S.offset),k.addRange(C))))),k=[];for(x=_;x=x.parentNode;)1===x.nodeType&&k.push({element:x,left:x.scrollLeft,top:x.scrollTop});for("function"==typeof _.focus&&_.focus(),_=0;_Eo)&&(uo=!0)}function Do(e){null===oo&&Z("246"),oo.remainingExpirationTime=0,ho||(ho=!0,po=e)}function Ao(e,t){var n=fo;fo=!0;try{return e(t)}finally{(fo=n)||ro||ko()}}function Io(e,t){if(fo&&!go){go=!0;try{return e(t)}finally{go=!1}}return e(t)}function Ro(e,t,n){if(vo)return e(t,n);fo||ro||0===co||(xo(co,!1,null),co=0);var s=vo,a=fo;fo=vo=!0;try{return e(t,n)}finally{vo=s,(fo=a)||ro||ko()}}function Oo(e,t,n,s,a){var i=t.current;if(n){var r;e:{for(2===Qn(n=n._reactInternalFiber)&&2===n.tag||Z("170"),r=n;3!==r.tag;){if(ti(r)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}(r=r.return)||Z("171")}r=r.stateNode.context}n=ti(n)?ii(n,r):r}else n=o;return null===t.context?t.context=n:t.pendingContext=n,t=a,(a=wi(s)).payload={element:e},null!==(t=void 0===t?null:t)&&(a.callback=t),Si(i,a,s),Zr(i,s),s}function Lo(e,t,n,s){var a=t.current;return Oo(e,t,n,a=Yr(eo(),a),s)}function Fo(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 5:default:return e.child.stateNode}}var qo=Ao,jo=Ro;function zo(e){this._expirationTime=function(){var e=2+25*(1+((eo()-2+500)/25|0));return e<=Rr&&(e=Rr+1),Rr=e}(),this._root=e,this._callbacks=this._next=null,this._hasChildren=this._didComplete=!1,this._children=null,this._defer=!0}function Wo(){this._callbacks=null,this._didCommit=!1,this._onCommit=this._onCommit.bind(this)}function Vo(e,t,n){this._internalRoot=function(e,t,n){return e={current:t=new li(3,null,null,t?3:0),containerInfo:e,pendingChildren:null,earliestPendingTime:0,latestPendingTime:0,earliestSuspendedTime:0,latestSuspendedTime:0,latestPingedTime:0,pendingCommitExpirationTime:0,finishedWork:null,context:null,pendingContext:null,hydrate:n,remainingExpirationTime:0,firstBatch:null,nextScheduledRoot:null},t.stateNode=e}(e,t,n)}function Ho(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function Bo(e,t,n,s,a){Ho(n)||Z("200");var i=n._reactRootContainer;if(i){if("function"==typeof a){var r=a;a=function(){var e=Fo(i._internalRoot);r.call(e)}}null!=e?i.legacy_renderSubtreeIntoContainer(e,t,a):i.render(t,a)}else{if(i=n._reactRootContainer=function(e,t){if(t||(t=!(!(t=e?9===e.nodeType?e.documentElement:e.firstChild:null)||1!==t.nodeType||!t.hasAttribute("data-reactroot"))),!t)for(var n;n=e.lastChild;)e.removeChild(n);return new Vo(e,!1,t)}(n,s),"function"==typeof a){var o=a;a=function(){var e=Fo(i._internalRoot);o.call(e)}}Io(function(){null!=e?i.legacy_renderSubtreeIntoContainer(e,t,a):i.render(t,a)})}return Fo(i._internalRoot)}function Go(e,t){var n=2"},close:function(){return""}},EM:{open:function(){return""},close:function(){return""}},DL:{open:function(){return""},close:function(){return""}},CO:{open:function(){return""},close:function(){return""}},BR:{open:function(){return""},close:function(){return" "}},LN:{open:function(e){return''},close:function(e){return""},props:function(e){return{href:e.url,target:"_blank"}}},MN:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},HT:{open:function(e){return''},close:function(e){return""},props:function(e){return{name:e.val}}},IM:{open:function(e){var t=a(e.val,e.mime),n=e.ref?e.ref:t,s=(e.name?'':"")+'';return console.log("open: "+s),s},close:function(e){return e.name?"":""},props:function(e){return{src:a(e.val,e.mime),title:e.name,"data-width":e.width,"data-height":e.height,"data-name":e.name,"data-size":.75*e.val.length|0,"data-mime":e.mime}}}},r=function(){};r.parse=function(e){if("string"!=typeof e)return null;var s=e.split(/\r?\n/),a=[],i={},r=[];s.map(function(e){var s,o,l=[];if(t.map(function(t){l=l.concat(function(e,t,n,s){for(var a=[],i=0,r=e.slice(0);r.length>0;){var o=t.exec(r);if(null==o)break;var l=o.index+o[0].lastIndexOf(o[1]);r=r.slice(l+1),i=(l+=i)+1;var c=n?n.exec(r):null;if(null==c)break;var u=c.index+c[0].indexOf(c[1]);r=r.slice(u+1),i=(u+=i)+1,a.push({text:e.slice(l+1,u),children:[],start:l,end:u,type:s})}return a}(e,t.start,t.end,t.name))}),0==l.length)o={txt:e};else{l.sort(function(e,t){return e.start-t.start}),l=function e(t){if(0==t.length)return[];for(var n=[t[0]],s=t[0],a=1;as.end?(n.push(t[a]),s=t[a]):t[a].endn&&i.push({text:t.slice(n,o.start)});var l={type:o.type},c=e(t,o.start+1,o.end-1,o.children);c.length>0?l.children=c:l.text=o.text,i.push(l),n=o.end+1}return na;return a=e.offset+e.len,t})}(o.txt)).length>0){var u=[];for(var d in s){var h=s[d],p=i[h.unique];p||(p=a.length,i[h.unique]=p,a.push({tp:h.type,data:h.data})),u.push({at:h.offset,len:h.len,key:p})}o.ent=u}r.push(o)});var o={txt:""};if(r.length>0){o.txt=r[0].txt,o.fmt=(r[0].fmt||[]).concat(r[0].ent||[]);for(var l=1;l0&&(o.ent=a)}return o},r.insertImage=function(e,t,n,s,a,i,r,o,l){return(e=e||{txt:" "}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:t,len:1,key:e.ent.length}),e.ent.push({tp:"IM",data:{mime:n,val:s,width:a,height:i,name:r,ref:l,size:0|o}}),e},r.attachFile=function(e,t,n,s,a,i){(e=e||{txt:""}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:-1,len:0,key:e.ent.length});let r={tp:"EX",data:{mime:t,val:n,name:s,ref:i,size:0|a}};return i instanceof Promise&&(r.data.ref=i.then(e=>{r.data.ref=e},e=>{})),e.ent.push(r),e},r.UNSAFE_toHTML=function(e){var t,n,s,{txt:a,fmt:r,ent:o}=e,l=[];if(r)for(var c in r){var u,d=r[c],h=d.tp;if(!h){var p=o[d.key];p&&(h=p.tp,u=p.data)}i[h]&&(l.push({idx:d.at+d.len,what:i[h].close(u)}),l.push({idx:d.at,what:i[h].open(u)}))}for(var c in l.sort(function(e,t){return t.idx-e.idx}),l)l[c].what&&(t=a,n=l[c].idx,s=l[c].what,a=t.slice(0,n)+s+t.slice(n));return a},r.format=function(e,t,n){var{txt:a,fmt:i,ent:r}=e;if(a=a||"",!i)return[a];var o=[].concat(i);return o.map(function(e){e.at=e.at||0,e.len=e.len||0}),o.sort(function(e,t){return e.at-t.at==0?t.len-e.len:e.at-t.at}),o=o.map(function(e){var t,n=e.tp;return n||(e.key=e.key||0,t=r[e.key].data,n=r[e.key].tp),{tp:n,data:t,at:e.at,len:e.len}}),function e(t,n,a,i,r,o){for(var l=[],c=0;c0)for(var t in e.ent)if("EX"==e.ent[t].tp)return!0;return!1},r.attachments=function(e,t,n){if(e.ent&&e.ent.length>0)for(var s in e.ent)"EX"==e.ent[s].tp&&t.call(n,e.ent[s].data,s)},r.getDownloadUrl=function(e){let t=null;return e.val?t=a(e.val,e.mime):"string"==typeof e.ref&&(t=e.ref),t},r.isUploading=function(e){return e.ref instanceof Promise},r.getPreviewUrl=function(e){return e.val?a(e.val,e.mime):null},r.getEntitySize=function(e){return e.size?e.size:e.val?.75*e.val.length|0:0},r.getEntityMimeType=function(e){return e.mime||"text/plain"},r.tagName=function(e){return s[e]?s[e].name:void 0},r.attrValue=function(e,t){if(t&&i[e])return i[e].props(t)},r.getContentType=function(){return"text/x-drafty"},e=r;const o="0";function l(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function c(e,t,n){if(null==t)return e;if("object"!=typeof t)return t||e;if(t instanceof Date)return t;if(t instanceof b)return new b(t);if(t instanceof Array)return t.length>0?t:e;for(var s in e||(e=t.constructor()),t)!t.hasOwnProperty(s)||!t[s]&&!1!==t[s]||n&&n[s]||"_generated"==s||(e[s]=c(e[s],t[s]));return e}function u(e,t,n,s){return e[t]=c(e[t],n,s),e[t]}function d(){var e=null;if("withCredentials"in new XMLHttpRequest)e=new XMLHttpRequest;else{if("undefined"==typeof XDomainRequest)throw new Error("browser not supported");e=new XDomainRequest}return e}function h(e,t){if("ts"===e&&"string"==typeof t&&t.length>=20&&t.length<=24){var n=new Date(t);if(n)return n}else if("acs"===e&&"object"==typeof t)return new b(t);return t}function p(e,t){return"string"==typeof t&&t.length>128?"<"+t.length+", bytes: "+t.substring(0,12)+"..."+t.substring(t.length-12)+">":function(e,t){if(t instanceof Date)t=function(e){if(e&&0!=e.getTime()){var t=e.getUTCMilliseconds();return e.getUTCFullYear()+"-"+n(e.getUTCMonth()+1)+"-"+n(e.getUTCDate())+"T"+n(e.getUTCHours())+":"+n(e.getUTCMinutes())+":"+n(e.getUTCSeconds())+(t?"."+n(t,3):"")+"Z"}function n(e,t){return"0".repeat((t=t||2)-(""+e).length)+e}}(t);else if(null==t||!1===t||Array.isArray(t)&&0==t.length||"object"==typeof t&&0===Object.keys(t).length)return;return t}(0,t)}function m(e,t,n){var s=null;return"http"!==t&&"https"!==t&&"ws"!==t&&"wss"!==t||(s=t+"://","/"!==(s+=e).charAt(s.length-1)&&(s+="/"),s+="v"+o+"/channels","http"!==t&&"https"!==t||(s+="/lp"),s+="?apikey="+n),s}var f=function(e,t,n,s,a){let i=e,r=s,o=t;var l=a;const c=2e3,u=10,p=.3;let f=null,g=0,v=!1,b=e=>{this.logger&&this.logger(e)};function y(e){var t=null;e.connect=function(n){return t&&1===t.readyState?Promise.resolve():(n&&(i=n),new Promise(function(n,s){var a=m(i,r?"wss":"ws",o);b("Connecting to: "+a);var d=new WebSocket(a);d.onopen=function(t){v=!1,e.onOpen&&e.onOpen(),n(),l&&(window.clearTimeout(f),f=null,g=0)},d.onclose=function(n){t=null,e.onDisconnect&&e.onDisconnect(null),!v&&l&&function(){clearTimeout(f);var e=c*(Math.pow(2,g)*(1+p*Math.random()));g=g>=u?g:g+1,f=setTimeout(()=>{b("Reconnecting, iter="+g+", timeout="+e),v||this.connect().catch(function(){})},e)}.call(e)},d.onerror=function(e){s(e)},d.onmessage=function(t){e.onMessage&&e.onMessage(t.data)},t=d}))},e.disconnect=function(){t&&(v=!0,t.close()),t=null},e.sendText=function(e){if(!t||t.readyState!=t.OPEN)throw new Error("Websocket is not connected");t.send(e)},e.isConnected=function(){return t&&1===t.readyState}}function w(e){var t=null,n=null,s=null;e.connect=function(s){return s&&(i=s),new Promise(function(s,a){var l=m(i,r?"https":"http",o);b("Connecting to: "+l),(n=function n(s,a,i){var r=d();return r.onreadystatechange=function(o){if(4==r.readyState)if(201==r.status){var l=JSON.parse(r.responseText,h);r.responseText,t=s+"&sid="+l.ctrl.params.sid,(r=n(t)).send(null),e.onOpen&&e.onOpen(),a&&a()}else 200==r.status?(e.onMessage&&e.onMessage(r.responseText),(r=n(t)).send(null)):(i&&i(r.responseText),e.onMessage&&e.onMessage(r.responseText),e.onDisconnect&&e.onDisconnect(new Error(r.status+" "+r.responseText)))},r.open("GET",s,!0),r}(l,s,a)).send(null)}).catch(function(){})},e.disconnect=function(){s&&(s.abort(),s=null),n&&(n.abort(),n=null),e.onDisconnect&&e.onDisconnect(null),t=null},e.sendText=function(e){var n,a;if(n=t,(a=d()).onreadystatechange=function(e){if(4==a.readyState&&a.status>=400)throw new Error("LP sender failed, "+a.status)},a.open("POST",n,!0),!(s=a)||1!=s.readyState)throw new Error("Long poller failed to connect");s.send(e)},e.isConnected=function(){return n&&!0}}"lp"===n?w(this):"ws"===n?y(this):"object"==typeof window&&window.WebSocket?y(this):w(this),this.onMessage=void 0,this.onDisconnect=void 0,this.onOpen=void 0,this.logger=void 0},g=function(e,t,n,s,a){this._appName=e||"Undefined",this._apiKey=n,this._browser="",this._platform="undefined","undefined"!=typeof navigator&&(this._browser=function(e){var t,n=(e=(e||"").replace(" (KHTML, like Gecko)","")).match(/(AppleWebKit\/[.\d]+)/i);if(n){for(var s=["chrome","safari","mobile","version"],a=e.substr(n.index+n[0].length).split(" "),i=[],r=0;r0?i[0][0]+"/"+i[0][1]:n[1]}else t=/trident/i.test(e)?(n=/(?:\brv[ :]+([.\d]+))|(?:\bMSIE ([.\d]+))/g.exec(e))?"MSIE/"+(n[1]||n[2]):"MSIE/?":/firefox/i.test(e)?(n=/Firefox\/([.\d]+)/g.exec(e))?"Firefox/"+n[1]:"Firefox/?":/presto/i.test(e)?(n=/Opera\/([.\d]+)/g.exec(e))?"Opera/"+n[1]:"Opera/?":(n=/([\w.]+)\/([.\d]+)/.exec(e))?n[1]+"/"+n[2]:(n=e.split(" "))[0];if((n=t.split("/")).length>1){var l=n[1].split(".");t=n[0]+"/"+l[0]+(l[1]?"."+l[1]:"")}return t}(navigator.userAgent),this._platform=navigator.platform),this._loggingEnabled=!1,this._trimLongStrings=!1,this._myUID=null,this._authenticated=!1,this._login=null,this._authToken=null,this._inPacketCount=0,this._messageId=Math.floor(65535*Math.random()+65535),this._serverInfo=null,this._pendingPromises={},this._connection=new f(t,n,s,a,!0),this.logger=(e=>{if(this._loggingEnabled){var t=new Date,n=("0"+t.getUTCHours()).slice(-2)+":"+("0"+t.getUTCMinutes()).slice(-2)+":"+("0"+t.getUTCSeconds()).slice(-2)+":"+("0"+t.getUTCMilliseconds()).slice(-3);console.log("["+n+"] "+e)}}),this._connection.logger=this.logger,this._cache={};let i=this.cachePut=((e,t,n)=>{this._cache[e+":"+t]=n}),r=this.cacheGet=((e,t)=>this._cache[e+":"+t]),o=this.cacheDel=((e,t)=>{delete this._cache[e+":"+t]}),l=this.cacheMap=((e,t)=>{for(var n in this._cache)if(e(this._cache[n],n,t))break});this.attachCacheToTopic=(e=>{e._tinode=this,e._cacheGetUser=(e=>{var t=r("user",e);if(t)return{user:e,public:c({},t)}}),e._cachePutUser=((e,t)=>i("user",e,c({},t.public))),e._cacheDelUser=(e=>o("user",e)),e._cachePutSelf=(()=>i("topic",e.name,e)),e._cacheDelSelf=(()=>o("topic",e.name))});let u=(e,t,n,s)=>{var a=this._pendingPromises[e];a&&(delete this._pendingPromises[e],t>=200&&t<400?a.resolve&&a.resolve(n):a.reject&&a.reject(new Error("Error: "+s+" ("+t+")")))},d=e=>{var t=null;return e&&(t=new Promise((t,n)=>{this._pendingPromises[e]={resolve:t,reject:n}})),t},m=this.getNextUniqueId=(()=>0!=this._messageId?""+this._messageId++:void 0),g=()=>this._appName+" ("+(this._browser?this._browser+"; ":"")+this._platform+"); tinodejs/0.15";this.initPacket=((e,t)=>{switch(e){case"hi":return{hi:{id:m(),ver:"0.15",ua:g()}};case"acc":return{acc:{id:m(),user:null,scheme:null,secret:null,login:!1,tags:null,desc:{},cred:{}}};case"login":return{login:{id:m(),scheme:null,secret:null}};case"sub":return{sub:{id:m(),topic:t,set:{},get:{}}};case"leave":return{leave:{id:m(),topic:t,unsub:!1}};case"pub":return{pub:{id:m(),topic:t,noecho:!1,head:null,content:{}}};case"get":return{get:{id:m(),topic:t,what:null,desc:{},sub:{},data:{}}};case"set":return{set:{id:m(),topic:t,desc:{},sub:{},tags:[]}};case"del":return{del:{id:m(),topic:t,what:null,delseq:null,user:null,hard:!1}};case"note":return{note:{topic:t,what:null,seq:void 0}};default:throw new Error("Unknown packet type requested: "+e)}}),this.send=((e,t)=>{let n;t&&(n=d(t)),e=function e(t){return Object.keys(t).forEach(function(n){"_"==n[0]?delete t[n]:t[n]?Array.isArray(t[n])&&0==t[n].length?delete t[n]:t[n]?"object"!=typeof t[n]||t[n]instanceof Date||(e(t[n]),0==Object.getOwnPropertyNames(t[n]).length&&delete t[n]):delete t[n]:delete t[n]}),t}(e);var s=JSON.stringify(e);return this.logger("out: "+(this._trimLongStrings?JSON.stringify(e,p):s)),this._connection.sendText(s),n}),this.loginSuccessful=(e=>{this._myUID=e.params.user,this._authenticated=e&&e.code>=200&&e.code<300,e.params&&e.params.token&&e.params.expires?this._authToken={token:e.params.token,expires:new Date(e.params.expires)}:this._authToken=null,this.onLogin&&this.onLogin(e.code,e.text)}),this._connection.onMessage=(e=>{if(e){this._inPacketCount++,this.onRawMessage&&this.onRawMessage(e);var t=JSON.parse(e,h);if(t)if(this.logger("in: "+(this._trimLongStrings?JSON.stringify(t,p):e)),this.onMessage&&this.onMessage(t),t.ctrl)this.onCtrlMessage&&this.onCtrlMessage(t.ctrl),t.ctrl.id&&u(t.ctrl.id,t.ctrl.code,t.ctrl,t.ctrl.text),t.ctrl.params&&"data"==t.ctrl.params.what&&(n=r("topic",t.ctrl.topic))&&n._allMessagesReceived(t.ctrl.params.count);else if(t.meta)(n=r("topic",t.meta.topic))&&n._routeMeta(t.meta),this.onMetaMessage&&this.onMetaMessage(t.meta);else if(t.data)(n=r("topic",t.data.topic))&&n._routeData(t.data),this.onDataMessage&&this.onDataMessage(t.data);else if(t.pres)(n=r("topic",t.pres.topic))&&n._routePres(t.pres),this.onPresMessage&&this.onPresMessage(t.pres);else if(t.info){var n;(n=r("topic",t.info.topic))&&n._routeInfo(t.info),this.onInfoMessage&&this.onInfoMessage(t.info)}else this.logger("ERROR: Unknown packet received.");else this.logger("in: "+e),this.logger("ERROR: failed to parse data")}}),this._connection.onOpen=(()=>{this.hello()}),this._connection.onDisconnect=(e=>{this._inPacketCount=0,this._serverInfo=null,this._authenticated=!1,l((e,t)=>{0===t.lastIndexOf("topic:",0)&&e._resetSub()}),this.onDisconnect&&this.onDisconnect(e)})};g.credential=function(e,t,n,s){return"object"==typeof e&&({val:t,params:n,resp:s,meth:e}=e),e&&(t||s)?[{meth:e,val:t,resp:s,params:n}]:null},g.topicType=function(e){return{me:"me",fnd:"fnd",grp:"grp",new:"grp",usr:"p2p"}["string"==typeof e?e.substring(0,3):"xxx"]},g.isNewGroupTopicName=function(e){return"string"==typeof e&&"new"==e.substring(0,3)},g.getVersion=function(){return"0.15"},g.MESSAGE_STATUS_NONE=0,g.MESSAGE_STATUS_QUEUED=1,g.MESSAGE_STATUS_SENDING=2,g.MESSAGE_STATUS_SENT=3,g.MESSAGE_STATUS_RECEIVED=4,g.MESSAGE_STATUS_READ=5,g.MESSAGE_STATUS_TO_ME=6,g.DEL_CHAR="\u2421",g.prototype={connect:function(e){return this._connection.connect(e)},disconnect:function(){this._connection&&this._connection.disconnect()},isConnected:function(){return this._connection&&this._connection.isConnected()},isAuthenticated:function(){return this._authenticated},account:function(e,t,n,s,a){var i=this.initPacket("acc");return i.acc.user=e,i.acc.scheme=t,i.acc.secret=n,i.acc.login=s,a&&(i.acc.desc.defacs=a.defacs,i.acc.desc.public=a.public,i.acc.desc.private=a.private,i.acc.tags=a.tags,i.acc.cred=a.cred),this.send(i,i.acc.id)},createAccount:function(e,t,n,s){var a=this.account("new",e,t,n,s);return n&&(a=a.then(e=>(this.loginSuccessful(e),e))),a},createAccountBasic:function(e,t,n){return e=e||"",t=t||"",this.createAccount("basic",l(e+":"+t),!0,n)},updateAccountBasic:function(e,t,n){return t=t||"",n=n||"",this.account(e,"basic",l(t+":"+n),!1,null)},hello:function(){var e=this.initPacket("hi");return this.send(e,e.hi.id).then(e=>(e.params&&(this._serverInfo=e.params),this.onConnect&&this.onConnect(),e)).catch(e=>{this.onDisconnect&&this.onDisconnect(e)})},login:function(e,t,n){var s=this.initPacket("login");return s.login.scheme=e,s.login.secret=t,s.login.cred=n,this.send(s,s.login.id).then(e=>(this.loginSuccessful(e),e))},loginBasic:function(e,t,n){return this.login("basic",l(e+":"+t),n).then(t=>(this._login=e,t))},loginToken:function(e,t){return this.login("token",e,t)},getAuthToken:function(){return this._authToken&&this._authToken.expires.getTime()>Date.now()?this._authToken:(this._authToken=null,null)},setAuthToken:function(e){this._authToken=e},subscribe:function(e,t,n){var s=this.initPacket("sub",e);return e||(e="new"),s.sub.get=t,n&&(n.sub&&(s.sub.set.sub=n.sub),g.isNewGroupTopicName(e)&&n.desc&&(s.sub.set.desc=n.desc),n.tags&&(s.sub.set.tags=n.tags)),this.send(s,s.sub.id)},leave:function(e,t){var n=this.initPacket("leave",e);return n.leave.unsub=t,this.send(n,n.leave.id)},createMessage:function(e,t,n){let s=this.initPacket("pub",e),a="string"==typeof t?Drafty.parse(t):t;return a&&!Drafty.isPlainText(a)&&(s.pub.head={mime:Drafty.getContentType()},t=a),s.pub.noecho=n,s.pub.content=t,s.pub},publish:function(e,t,n){return this.publishMessage(this.createMessage(e,t,n))},publishMessage:function(e){return(e=Object.assign({},e)).seq=void 0,e.from=void 0,e.ts=void 0,this.send({pub:e},e.id)},getMeta:function(e,t){var n=this.initPacket("get",e);return n.get=c(n.get,t),this.send(n,n.get.id)},setMeta:function(e,t){var n=this.initPacket("set",e),s=[];return t&&["desc","sub","tags"].map(function(e){t.hasOwnProperty(e)&&(s.push(e),n.set[e]=t[e])}),0==s.length?Promise.reject(new Error("Invalid {set} parameters")):this.send(n,n.set.id)},delMessages:function(e,t,n){var s=this.initPacket("del",e);return s.del.what="msg",s.del.delseq=t,s.del.hard=n,this.send(s,s.del.id)},delTopic:function(e){var t=this.initPacket("del",e);return t.del.what="topic",this.send(t,t.del.id).then(t=>(this.cacheDel("topic",e),this.ctrl))},delSubscription:function(e,t){var n=this.initPacket("del",e);return n.del.what="sub",n.del.user=t,this.send(n,n.del.id)},note:function(e,t,n){if(n<=0||n>=268435455)throw new Error("Invalid message id "+n);var s=this.initPacket("note",e);s.note.what=t,s.note.seq=n,this.send(s)},noteKeyPress:function(e){var t=this.initPacket("note",e);t.note.what="kp",this.send(t)},getTopic:function(e){var t=this.cacheGet("topic",e);return!t&&e&&(t="me"==e?new w:"fnd"==e?new E:new y(e),this.cachePut("topic",e,t),this.attachCacheToTopic(t)),t},newTopic:function(e){var t=new y("new",e);return this.attachCacheToTopic(t),t},newGroupTopicName:function(){return"new"+this.getNextUniqueId()},newTopicWith:function(e,t){var n=new y(e,t);return this.attachCacheToTopic(n),n},getMeTopic:function(){return this.getTopic("me")},getFndTopic:function(){return this.getTopic("fnd")},getLargeFileHelper:function(){return new S(this)},getCurrentUserID:function(){return this._myUID},getCurrentLogin:function(){return this._login},getServerInfo:function(){return this._serverInfo},enableLogging:function(e,t){this._loggingEnabled=e,this._trimLongStrings=t},isTopicOnline:function(e){var t=this.getMeTopic(),n=t&&t.getContact(e);return n&&n.online},wantAkn:function(e){this._messageId=e?Math.floor(16777215*Math.random()+16777215):0},onWebsocketOpen:void 0,onConnect:void 0,onDisconnect:void 0,onLogin:void 0,onCtrlMessage:void 0,onDataMessage:void 0,onPresMessage:void 0,onMessage:void 0,onRawMessage:void 0};var v=function(e){this.topic=e;var t=e._tinode.getMeTopic();this.contact=t&&t.getContact(e.name),this.what={}};v.prototype={_get_ims:function(){let e=this.contact&&this.contact.updated,t=this.topic._lastDescUpdate||0;return e>t?e:t},withData:function(e,t,n){return this.what.data={since:e,before:t,limit:n},this},withLaterData:function(e){return this.withData(this.topic._maxSeq>0?this.topic._maxSeq+1:void 0,void 0,e)},withEarlierData:function(e){return this.withData(void 0,this.topic._minSeq>0?this.topic._minSeq:void 0,e)},withDesc:function(e){return this.what.desc={ims:e},this},withLaterDesc:function(){return this.withDesc(this._get_ims())},withSub:function(e,t,n){var s={ims:e,limit:t};return"me"==this.topic.getType()?s.topic=n:s.user=n,this.what.sub=s,this},withOneSub:function(e,t){return this.withSub(e,void 0,t)},withLaterOneSub:function(e){return this.withOneSub(this.topic._lastSubsUpdate,e)},withLaterSub:function(e){return this.withSub("p2p"==this.topic.getType()?this._get_ims():this.topic._lastSubsUpdate,e)},withTags:function(){return this.what.tags=!0,this},withDel:function(e,t){return(e||t)&&(this.what.del={since:e,limit:t}),this},withLaterDel:function(e){return this.withDel(this.topic._maxSeq>0?this.topic._maxDel+1:void 0,e)},build:function(){var e={},t=[],n=this;return["data","sub","desc","tags","del"].map(function(s){n.what.hasOwnProperty(s)&&(t.push(s),Object.getOwnPropertyNames(n.what[s]).length>0&&(e[s]=n.what[s]))}),t.length>0?e.what=t.join(" "):e=void 0,e}};var b=function(e){e&&(this.given="number"==typeof e.given?e.given:b.decode(e.given),this.want="number"==typeof e.want?e.want:b.decode(e.want),this.mode=e.mode?"number"==typeof e.mode?e.mode:b.decode(e.mode):this.given&this.want)};b._NONE=0,b._JOIN=1,b._READ=2,b._WRITE=4,b._PRES=8,b._APPROVE=16,b._SHARE=32,b._DELETE=64,b._OWNER=128,b._BITMASK=b._JOIN|b._READ|b._WRITE|b._PRES|b._APPROVE|b._SHARE|b._DELETE|b._OWNER,b._INVALID=1048576,b.decode=function(e){if(!e)return null;if("number"==typeof e)return e&b._BITMASK;if("N"===e||"n"===e)return b._NONE;for(var t={J:b._JOIN,R:b._READ,W:b._WRITE,P:b._PRES,A:b._APPROVE,S:b._SHARE,D:b._DELETE,O:b._OWNER},n=b._NONE,s=0;s0)){l=!0;break}i=r-1}return l?r:s?-1:o<0?r+1:r}function s(e,t){var s=n(e,t,!1);return t.splice(s,0,e),t}return e=e||function(e,t){return e===t?0:e0)return n[0]},delRange:function(e,n){return t.splice(e,n-e)},size:function(){return t.length},reset:function(e){t=[]},forEach:function(e,n,s,a){n|=0,s=s||t.length;for(var i=n;i{if(e.code>=300)return e;if(this._subscribed=!0,this.acs=e.params&&e.params.acs?e.params.acs:this.acs,this._new){this._new=!1,this.name=e.topic,this.created=e.ts,this.updated=e.ts,this.touched=e.ts,this._cachePutSelf();var n=this._tinode.getMeTopic();n&&n._processMetaSub([{_generated:!0,topic:this.name,created:e.ts,updated:e.ts,touched:e.ts,acs:this.acs}]),t&&t.desc&&(t.desc._generated=!0,this._processMetaDesc(t.desc))}return e})},publish:function(e,t){return this.publishMessage(this.createMessage(e,t))},createMessage:function(e,t){return this._tinode.createMessage(this.name,e,t)},publishMessage:function(e){if(!this._subscribed)return Promise.reject(new Error("Cannot publish on inactive topic"));if(Drafty.hasAttachments(e.content)){let t=[];Drafty.attachments(e.content,e=>{t.push(e.ref)}),e.head.attachments=t}return e._sending=!0,this._tinode.publishMessage(e)},publishDraft:function(e,t){return t||this._subscribed?(e.seq=this._getQueuedSeqId(),e._generated=!0,e.ts=new Date,e.from=this._tinode.getCurrentUserID(),e.noecho=!0,this._messages.put(e),this.onData&&this.onData(e),(t||Promise.resolve()).then(()=>e._cancelled?{code:300,text:"cancelled"}:this.publishMessage(e).then(t=>(e._sending=!1,e.seq=t.params.seq,e.ts=t.ts,this._routeData(e),t)),t=>{e._sending=!1,this._messages.delAt(this._messages.find(e)),this.onData&&this.onData()})):Promise.reject(new Error("Cannot publish on inactive topic"))},leave:function(e){return this._subscribed||e?this._tinode.leave(this.name,e).then(t=>(this._resetSub(),e&&this._gone(),t)):Promise.reject(new Error("Cannot leave inactive topic"))},getMeta:function(e){return this._subscribed?this._tinode.getMeta(this.name,e):Promise.reject(new Error("Cannot query inactive topic"))},getMessagesPage:function(e,t){var n=this.startMetaQuery();t?n.withLaterData(e):n.withEarlierData(e);var s=this.getMeta(n.build());return t||(s=s.then(e=>{e&&e.params&&!e.params.count&&(this._noEarlierMsgs=!0)})),s},setMeta:function(e){return this._subscribed?(e.tags&&(e.tags=function(e){var t=[];if(Array.isArray(e)){for(var n=0,s=e.length;n1&&t.push(a)}t.sort().filter(function(e,t,n){return!t||e!=n[t-1]})}return 0==t.length&&t.push(g.DEL_CHAR),t}(e.tags)),this._tinode.setMeta(this.name,e).then(t=>t&&t.code>=300?t:(e.sub&&(t.params&&t.params.acs&&(e.sub.acs=t.params.acs,e.sub.updated=t.ts),e.sub.user||(e.sub.user=this._tinode.getCurrentUserID(),e.desc||(e.desc={})),e.sub._generated=!0,this._processMetaSub([e.sub])),e.desc&&(t.params&&t.params.acs&&(e.desc.acs=t.params.acs,e.desc.updated=t.ts),this._processMetaDesc(e.desc)),e.tags&&this._processMetaTags(e.tags),t))):Promise.reject(new Error("Cannot update inactive topic"))},invite:function(e,t){return this.setMeta({sub:{user:e,mode:t}})},delMessages:function(e,t){if(!this._subscribed)return Promise.reject(new Error("Cannot delete messages in inactive topic"));e.sort(function(e,t){return e.low=t.hi)});let n,s=e.reduce((e,t)=>(t.low<268435455&&(!t.hi||t.hi<268435455?e.push(t):e.push({low:t.low,hi:this._maxSeq+1})),e),[]);return(n=e.length>0?this._tinode.delMessages(this.name,s,t):Promise.resolve({params:{del:0}})).then(t=>(t.params.del>this._maxDel&&(this._maxDel=t.params.del),e.map(e=>{e.hi?this.flushMessageRange(e.low,e.hi):this.flushMessage(e.low)}),this.onData&&this.onData(),t))},delMessagesAll:function(e){return this.delMessages([{low:1,hi:this._maxSeq+1,_all:!0}],e)},delMessagesList:function(e,t){e.sort((e,t)=>e-t);var n=e.reduce((e,t)=>{if(0==e.length)e.push({low:t});else{let n=e[e.length-1];!n.hi&&t!=n.low+1||t>n.hi?e.push({low:t}):n.hi=n.hi?Math.max(n.hi,t+1):t+1}return e},[]);return this.delMessages(n,t)},delTopic:function(){var e=this;return this._tinode.delTopic(this.name).then(function(t){return e._resetSub(),e._gone(),t})},delSubscription:function(e){return this._subscribed?this._tinode.delSubscription(this.name,e).then(t=>(delete this._users[e],this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._users)),t)):Promise.reject(new Error("Cannot delete subscription in inactive topic"))},note:function(e,t){var n=this._users[this._tinode.getCurrentUserID()];n?((!n[e]||n[e]0)for(var a in this._users){var i=this._users[a];i.user!==s&&i[e]>=t&&n++}return n},msgReadCount:function(e){return this.msgReceiptCount("read",e)},msgRecvCount:function(e){return this.msgReceiptCount("recv",e)},msgHasMoreMessages:function(e){return e?this.seq>this._maxSeq:this._minSeq>1&&!this._noEarlierMsgs},isNewMessage:function(e){return this._maxSeq<=e},flushMessage:function(e){let t=this._messages.find({seq:e});return t>=0?this._messages.delAt(t):void 0},flushMessageRange:function(e,t){let n=this._messages.find({seq:e});return n>=0?this._messages.delRange(n,this._messages.find({seq:t},!0)):[]},cancelSend:function(e){let t=this._messages.find({seq:e});if(t>=0){let e=this._messages.getAt(t);if(1==this.msgStatus(e))return e._cancelled=!0,this._messages.delAt(t),!0}return!1},getType:function(){return g.topicType(this.name)},getAccessMode:function(){return this.acs},getDefaultAccess:function(){return this.defacs},startMetaQuery:function(){return new v(this)},msgStatus:function(e){var t=0;return e.from==this._tinode.getCurrentUserID()?e._sending?t=2:e.seq>=268435455?t=1:this.msgReadCount(e.seq)>0?t=5:this.msgRecvCount(e.seq)>0?t=4:e.seq>0&&(t=3):t=6,t},_routeData:function(e){e.content&&((!this.touched||this.touchedthis._maxSeq&&(this._maxSeq=e.seq),(e.seq0&&(this._lastSubsUpdate=e.ts,this._processMetaSub(e.sub)),e.del&&this._processDelMessages(e.del.clear,e.del.delseq),e.tags&&this._processMetaTags(e.tags),this.onMeta&&this.onMeta(e)},_routePres:function(e){var t;switch(e.what){case"del":this._processDelMessages(e.clear,e.delseq);break;case"on":case"off":(t=this._users[e.src])?t.online="on"==e.what:this._tinode.logger("Presence update for an unknown user",this.name,e.src);break;case"acs":let s="me"==e.src?this._tinode.getCurrentUserID():e.src;if(t=this._users[s])t.acs.updateAll(e.dacs),s==this._tinode.getCurrentUserID()&&this.acs.updateAll(e.dacs),t.acs&&t.acs.mode!=b._NONE||("p2p"==this.getType()&&this.leave(),this._processMetaSub([{user:s,deleted:new Date,_generated:!0}]));else{var n=(new b).updateAll(e.dacs);n&&n.mode!=b._NONE&&((t=this._cacheGetUser(s))?t.acs=n:(t={user:s,acs:n},this.getMeta(this.startMetaQuery().withOneSub(void 0,s).build())),t._generated=!0,t.updated=new Date,this._processMetaSub([t]))}break;default:this._tinode.logger("Ignored presence update",e.what)}this.onPres&&this.onPres(e)},_routeInfo:function(e){if("kp"!==e.what){var t=this._users[e.from];t&&(t[e.what]=e.seq)}this.onInfo&&this.onInfo(e)},_processMetaDesc:function(e,t){if(c(this,e),"string"==typeof this.created&&(this.created=new Date(this.created)),"string"==typeof this.updated&&(this.updated=new Date(this.updated)),"string"==typeof this.touched&&(this.touched=new Date(this.touched)),"me"!==this.name&&!t&&!e._generated){var n=this._tinode.getMeTopic();n&&n._processMetaSub([{_generated:!0,topic:this.name,updated:this.updated,touched:this.touched,acs:this.acs,public:this.public,private:this.private}])}this.onMetaDesc&&this.onMetaDesc(this)},_processMetaSub:function(e){var t=void 0;for(var n in e){var s=e[n];if(s.user){s.updated=new Date(s.updated),s.deleted=s.deleted?new Date(s.deleted):null;var a=null;s.deleted?(delete this._users[s.user],a=s):((a=this._users[s.user])||(a=this._cacheGetUser(s.user)),a=this._updateCachedUser(s.user,s,s._generated)),this.onMetaSub&&this.onMetaSub(a)}else s._generated||(t=s)}t&&this.onMetaDesc&&this.onMetaDesc(t),this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._users))},_processMetaTags:function(e){1==e.length&&e[0]==g.DEL_CHAR&&(e=[]),this._tags=e,this.onTagsUpdated&&this.onTagsUpdated(e)},_processDelMessages:function(e,t){this._maxDel=Math.max(e,this._maxDel),this.clear=Math.max(e,this.clear);var n=this,s=0;Array.isArray(t)&&t.map(function(e){if(e.hi)for(var t=e.low;t0&&this.onData&&this.onData()},_allMessagesReceived:function(e){this.onAllMessagesReceived&&this.onAllMessagesReceived(e)},_resetSub:function(){this._subscribed=!1},_gone:function(){var e=this._tinode.getMeTopic();e&&e._routePres({_generated:!0,what:"gone",topic:"me",src:this.name}),this.onDeleteTopic&&this.onDeleteTopic()},_updateCachedUser:function(e,t,n){var s=this._cacheGetUser(e);return s?s=c(s,t):(n&&this.getMeta(this.startMetaQuery().withLaterOneSub(e).build()),s=c({},t)),this._cachePutUser(e,s),u(this._users,e,s)},_getQueuedSeqId:function(){return this._queuedSeqId++}};var w=function(e){y.call(this,"me",e),this._contacts={},e&&(this.onContactUpdate=e.onContactUpdate)};w.prototype=Object.create(y.prototype,{_processMetaSub:{value:function(e){var t=0;for(var n in e){var s=e[n],a=s.topic;if("fnd"!=a&&"me"!=a){s.updated=new Date(s.updated),s.touched=s.touched?new Date(s.touched):null,s.deleted=s.deleted?new Date(s.deleted):null,s.seq=0|s.seq,s.recv=0|s.recv,s.read=0|s.read,s.unread=s.seq-s.read;var i=null;if(s.deleted)i=s,delete this._contacts[a];else if(s.seen&&s.seen.when&&(s.seen.when=new Date(s.seen.when)),i=u(this._contacts,a,s),"p2p"==g.topicType(a)&&this._cachePutUser(a,i),!s._generated){var r=this._tinode.getTopic(a);r&&r._processMetaDesc(s,!0)}t++,this.onMetaSub&&this.onMetaSub(i)}}t>0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},_routePres:{value:function(e){var t=this._contacts[e.src];if(t){switch(e.what){case"on":t.online=!0;break;case"off":t.online&&(t.online=!1,t.seen?t.seen.when=new Date:t.seen={when:new Date});break;case"msg":t.touched=new Date,t.seq=0|e.seq,t.unread=t.seq-t.read;break;case"upd":this.getMeta(this.startMetaQuery().withLaterOneSub(e.src).build());break;case"acs":t.acs?t.acs.updateAll(e.dacs):t.acs=(new b).updateAll(e.dacs);break;case"ua":t.seen={when:new Date,ua:e.ua};break;case"recv":t.recv=t.recv?Math.max(t.recv,e.seq):0|e.seq;break;case"read":t.read=t.read?Math.max(t.read,e.seq):0|e.seq,t.unread=t.seq-t.read;break;case"gone":delete this._contacts[e.src]}this.onContactUpdate&&this.onContactUpdate(e.what,t)}else if("acs"==e.what){var n=new b(e.dacs);if(!n||n.mode==b._INVALID)return void this._tinode.logger("Invalid access mode update",e.src,e.dacs);if(n.mode==b._NONE)return void this._tinode.logger("Removing non-existent subscription",e.src,e.dacs);this.getMeta(this.startMetaQuery().withOneSub(void 0,e.src).build()),this._contacts[e.src]={topic:e.src,online:!1,acs:n}}this.onPres&&this.onPres(e)},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'me' is not supported"))},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var s in this._contacts)n.call(t,this._contacts[s],s,this._contacts)},enumerable:!0,configurable:!0,writable:!0},setMsgReadRecv:{value:function(e,t,n,s){var a,i=this._contacts[e],r=!1;i&&(n|=0,"recv"===t?(a=i.recv,i.recv=i.recv?Math.max(i.recv,n):n,r=a!=i.recv):"read"===t?(a=i.read,i.read=i.read?Math.max(i.read,n):n,i.unread=i.seq-i.read,r=a!=i.read,i.recv0&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'fnd' is not supported"))},enumerable:!0,configurable:!0,writable:!1},setMeta:{value:function(e){var t=this;return Object.getPrototypeOf(E.prototype).setMeta.call(this,e).then(function(){Object.keys(t._contacts).length>0&&(t._contacts={},t.onSubsUpdated&&t.onSubsUpdated([]))})},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var s in this._contacts)n.call(t,this._contacts[s],s,this._contacts)},enumerable:!0,configurable:!0,writable:!0}}),E.prototype.constructor=E;var S=function(e){this._tinode=e,this._apiKey=e._apiKey,this._authToken=e.getAuthToken(),this._msgId=e.getNextUniqueId(),this.xhr=d(),this.toResolve=null,this.toReject=null,this.onProgress=null,this.onSuccess=null,this.onFailure=null};S.prototype={upload:function(e,t,n,s){if(!this._authToken)throw new Error("Must authenticate first");var a=this;this.xhr.open("POST","/v"+o+"/file/u/",!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token);var i=new Promise((e,t)=>{this.toResolve=e,this.toReject=t});this.onProgress=t,this.onSuccess=n,this.onFailure=s,this.xhr.upload.onprogress=function(e){e.lengthComputable&&a.onProgress&&a.onProgress(e.loaded/e.total)},this.xhr.onload=function(){var e;try{e=JSON.parse(this.response,h)}catch(e){a._tinode.logger("Invalid server response in LargeFileHelper",this.response)}this.status>=200&&this.status<300?(a.toResolve&&a.toResolve(e.ctrl.params.url),a.onSuccess&&a.onSuccess(e.ctrl)):this.status>=400?(a.toReject&&a.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")")),a.onFailure&&a.onFailure(e.ctrl)):a._tinode.logger("Unexpected server response status",this.status,this.response)},this.xhr.onerror=function(e){a.toReject&&a.toReject(new Error("failed")),a.onFailure&&a.onFailure(null)},this.xhr.onabort=function(e){a.toReject&&a.toReject(new Error("upload cancelled by user")),a.onFailure&&a.onFailure(null)};try{var r=new FormData;r.append("file",e),r.set("id",this._msgId),this.xhr.send(r)}catch(e){this.toReject&&this.toReject(e),this.onFailure&&this.onFailure(null)}return i},download:function(e,t,n,s){if(/^(?:(?:[a-z]+:)?\/\/)/i.test(e))throw new Error("The URL '"+e+"' must be relative, not absolute");if(!this._authToken)throw new Error("Must authenticate first");var a=this;this.xhr.open("GET",e,!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token),this.xhr.responseType="blob",this.onProgress=s,this.xhr.onprogress=function(e){a.onProgress&&a.onProgress(e.loaded)};var i=new Promise((e,t)=>{this.toResolve=e,this.toReject=t});this.xhr.onload=function(){if(200==this.status){var e=document.createElement("a");e.href=window.URL.createObjectURL(new Blob([this.response],{type:n})),e.style.display="none",e.setAttribute("download",t),document.body.appendChild(e),e.click(),document.body.removeChild(e),window.URL.revokeObjectURL(e.href),a.toResolve&&a.toResolve()}else if(this.status>=400&&a.toReject){var s=new FileReader;s.onload=function(){try{var e=JSON.parse(this.result,h);a.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")"))}catch(e){a._tinode.logger("Invalid server response in LargeFileHelper",this.result),a.toReject(e)}},s.readAsText(this.response)}},this.xhr.onerror=function(e){a.toReject&&a.toReject(new Error("failed"))},this.xhr.onabort=function(){a.toReject&&a.toReject(null)};try{this.xhr.send()}catch(e){this.toReject&&this.toReject(e)}return i},cancel:function(){this.xhr&&this.xhr.readyState<4&&this.xhr.abort()},getId:function(){return this._msgId}};var C=function(e,t){this.status=C.STATUS_NONE,this.topic=e,this.content=t};C.STATUS_NONE=0,C.STATUS_QUEUED=1,C.STATUS_SENDING=2,C.STATUS_SENT=3,C.STATUS_RECEIVED=4,C.STATUS_READ=5,C.STATUS_TO_ME=6,C.prototype={toJSON:function(){},fromJSON:function(e){}},C.prototype.constructor=C;var T={};return(T=g).Drafty=e,T})}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),Yo=Yo.exports,"function"==typeof require&&void 0===Yo)var Zo=Yo.Drafty;const el="TinodeWeb/0.15",tl={hosted:"api.tinode.co",local:"localhost:6060"},nl=tl.hosted,sl=new Audio("audio/msg.mp3"),al="AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K",il=3e3,rl=500,ol=1e3,ll=4,cl=640,ul=13,dl=128,hl=24,pl=195840,ml=1<<23,fl=768,gl=["image/jpeg","image/gif","image/png","image/svg","image/svg+xml"],vl=["jpg","gif","png","svg","svg"];function bl(e){var t=window.navigator.userLanguage||window.navigator.language,n=new Date;return e.getFullYear()==n.getFullYear()?e.getMonth()==n.getMonth()&&e.getDate()==n.getDate()?e.toLocaleTimeString(t,{hour12:!1,hour:"2-digit",minute:"2-digit"}):e.toLocaleDateString(t,{hour12:!1,month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):e.toLocaleDateString(t,{hour12:!1,year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function yl(e){if(!e||0==e)return"0 Bytes";var t=["Bytes","KB","MB","GB","TB","PB"],n=Math.min(0|Math.floor(Math.log2(e)/10),t.length-1),s=e/Math.pow(1024,n),a=n>0?s<3?2:s<30?1:0:0;return s.toFixed(a)+" "+t[n]}function wl(e){return e&&e.type&&e.data?"data:image/"+e.type+";base64,"+e.data:null}function El(e,t,n,s,a){if(!(e&&t&&n&&s))return null;a&&(n=s=Math.min(n,s));let i=Math.min(Math.min(e,n)/e,Math.min(t,s)/t),r={dstWidth:e*i|0,dstHeight:t*i|0};return a?(r.dstWidth=r.dstHeight=Math.min(r.dstWidth,r.dstHeight),r.srcWidth=r.srcHeight=Math.min(e,t),r.xoffset=(e-r.srcWidth)/2|0,r.yoffset=(t-r.srcWidth)/2|0):(r.xoffset=r.yoffset=0,r.srcWidth=e,r.srcHeight=t),r}function Sl(e,t){var n=gl.indexOf(t),s=vl[n],a=e.lastIndexOf(".");return a>=0&&(e=e.substring(0,a)),e+"."+s}function Cl(e){var t=/^data:(image\/[-+a-z0-9.]+);base64/.exec(e);return t&&t.length>1?t[1]:null}function Tl(e){return 3*Math.floor(e/4)}function _l(e,t,n,s,a,i){var r=new Image;r.crossOrigin="Anonymous",r.onerror=function(e){i("Image format unrecognized")},r.onload=function(){var r=El(this.width,this.height,t,n,s);if(r){var o=document.createElement("canvas");o.width=r.dstWidth,o.height=r.dstHeight;var l=o.getContext("2d");l.imageSmoothingEnabled=!0,l.drawImage(this,r.xoffset,r.yoffset,r.srcWidth,r.srcHeight,0,0,r.dstWidth,r.dstHeight);var c=this.width!=r.dstWidth||this.height!=r.dstHeight||gl.indexOf(e.type)<0?"image/jpeg":e.type,u=o.toDataURL(c);if(c=Cl(u.split(",")[0])){var d=.78;if(Tl(u.length)>pl&&(c="image/jpeg"),"image/jpeg"==c)for(;Tl(u.length)>pl&&d>.45;)u=o.toDataURL(c,d),d*=.84;Tl(u.length)>pl?i("The image size "+yl(Tl(u.length))+" exceeds the "+yl(pl)+" limit.","err"):(o=null,a(u.split(",")[1],c,r.dstWidth,r.dstHeight,Sl(e.name,c)))}else i("Unsupported image format")}else i("Invalid image")},r.src=URL.createObjectURL(e)}function kl(e,t,n){var s=new FileReader;s.addEventListener("load",function(){var a=s.result.split(","),i=Cl(a[0]);if(i){var r=new Image;r.crossOrigin="Anonymous",r.onload=function(){t(a[1],i,this.width,this.height,Sl(e.name,i))},r.onerror=function(e){n("Image format not recognized")},r.src=URL.createObjectURL(e)}else n("Failed to process image file")},!1),s.readAsDataURL(e)}function xl(e,t,n){var s=new FileReader;s.addEventListener("load",function(){t(e.type,s.result.split(",")[1],e.name)}),s.readAsDataURL(e)}function Ml(e){let t=e.split("?",2),n={},s=[];return t[0]&&(s=t[0].substr(1).split("/")),t[1]&&t[1].split("&").forEach(function(e){let t=e.split("=");t[0]&&(n[decodeURIComponent(t[0])]=decodeURIComponent(t[1]))}),{path:s,params:n}}function Nl(e){window.location.hash=e}function Pl(e,t){var n=e.join("/"),s=[];for(var a in t)t.hasOwnProperty(a)&&s.push(a+"="+t[a]);return s.length>0&&(n+="?"+s.join("&")),n}function Ul(e,t,n){var s=Ml(e);return s.params[t]=n,Pl(s.path,s.params)}function Dl(e,t){var n=Ml(e);return delete n.params[t],Pl(n.path,n.params)}function Al(e,t){var n=Ml(e);return n.path[0]=t,Pl(n.path,n.params)}function Il(e,t){var n=Ml(e);return n.path[1]=t,delete n.params.info,Pl(n.path,n.params)}function Rl(){return"object"==typeof window.location&&"https:"==window.location.protocol}function Ol(e,t){var n=null;if((e&&e.trim()||t)&&(n={},e&&(n.fn=e.trim()),t)){var s=t.indexOf(",");n.photo={data:t.substring(s+1),type:"jpg"}}return n}function Ll(e,t){if(e.length!=t.length)return!1;e.sort(),t.sort();for(var n=0,s=e.length;n{this.deleteMessages(!0,!1,e,t)}},messages_clear_hard:{title:"Clear for All",handler:(e,t)=>{this.deleteMessages(!0,!0,e,t)}},message_delete:{title:"Delete",handler:(e,t)=>{this.deleteMessages(!1,!1,e,t)}},message_delete_hard:{title:"Delete for All",handler:(e,t)=>{this.deleteMessages(!1,!0,e,t)}},topic_unmute:{title:"Unmute",handler:this.topicPermissionSetter.bind(this,"+P")},topic_mute:{title:"Mute",handler:this.topicPermissionSetter.bind(this,"-P")},topic_unblock:{title:"Unblock",handler:this.topicPermissionSetter.bind(this,"+J")},topic_block:{title:"Block",handler:this.topicPermissionSetter.bind(this,"-J")},topic_delete:{title:"Delete",handler:(e,t)=>{let n=this.props.tinode.getTopic(e.topicName);n?n.delTopic().catch(e=>{t&&t(e.message,"err")}):console.log("Topic not found: ",e.topicName)}},permissions:{title:"Edit permissions",handler:null},member_delete:{title:"Remove",handler:(e,t)=>{let n=this.props.tinode.getTopic(e.topicName);n&&e.user?n.delSubscription(e.user).catch(e=>{t&&t(e.message,"err")}):console.log("Topic or user not found: '"+e.topicName+"', '"+e.user+"'")}},member_mute:{title:"Mute",handler:this.topicPermissionSetter.bind(this,"-P")},member_unmute:{title:"Unmute",handler:this.topicPermissionSetter.bind(this,"+P")},member_block:{title:"Block",handler:this.topicPermissionSetter.bind(this,"-J")},member_unblock:{title:"Unblock",handler:this.topicPermissionSetter.bind(this,"+J")}}}componentDidMount(){document.addEventListener("mousedown",this.handlePageClick,!1),document.addEventListener("keyup",this.handleEscapeKey,!1)}componentWillUnmount(){document.removeEventListener("mousedown",this.handlePageClick,!1),document.removeEventListener("keyup",this.handleEscapeKey,!1)}handlePageClick(e){ReactDOM.findDOMNode(this).contains(e.target)||(e.preventDefault(),e.stopPropagation(),this.props.hide())}handleEscapeKey(e){27===e.keyCode&&this.props.hide()}handleClick(e){e.preventDefault(),e.stopPropagation(),this.props.hide();let t=this.props.items[e.currentTarget.dataset.id];"string"==typeof t&&(t=this.MenuItems[t]),t.handler(this.props.params,this.props.onError)}deleteMessages(e,t,n,s){var a=this.props.tinode.getTopic(n.topicName);if(a){if(a.cancelSend(n.seq))return new Promise.resolve;(e?a.delMessagesAll(t):a.delMessagesList([n.seq],t)).catch(e=>{s&&s(e.message,"err")})}else console.log("Topic not found: ",n.topicName)}topicPermissionSetter(e,t,n){var s=this.props.tinode.getTopic(t.topicName);if(s){var a,i;if(t.user){if(!(i=s.subscriber(t.user)))return void console.log("Subscriber not found",t.topicName+"["+t.user+"]");a=i.acs.updateGiven(e).getGiven()}else a=s.getAccessMode().updateWant(e).getWant();s.setMeta({sub:{user:t.user,mode:a}}).catch(e=>{n&&n(e.message,"err")})}else console.log("Topic not found",t.topicName)}render(){let e=0,t=[];this.props.items.map(n=>{"string"==typeof n&&(n=this.MenuItems[n]),n&&n.title&&t.push("-"==n.title?Y.createElement("li",{className:"separator",key:e}):Y.createElement("li",{onClick:this.handleClick,"data-id":e,key:e},n.title)),e++});var n=12*ul,s=ul*(.7+2.5*t.length),a={left:(this.props.bounds.right-this.props.clickAt.x20&&(e=e.substring(0,19)+"..."),this.state.active?Y.createElement("input",{type:this.props.type||"text",value:this.state.text,placeholder:this.props.placeholder,onChange:this.handeTextChange,onKeyDown:this.handleKeyDown,onBlur:this.handleEditingFinished,autoFocus:!0}):Y.createElement("span",{className:t,onClick:this.handleStartEditing},Y.createElement("span",{className:"content"},e))}}class Hl extends Y.PureComponent{constructor(e){super(e),this.state={hostName:e.serverAddress,changed:!1},this.handleHostNameChange=this.handleHostNameChange.bind(this),this.handleEditingFinished=this.handleEditingFinished.bind(this)}handleHostNameChange(e){this.setState({hostName:e.target.value,changed:!0})}handleEditingFinished(){this.state.changed&&(this.setState({changed:!1}),this.props.onServerAddressChange(this.state.hostName.trim()))}render(){var e=[];for(var t in tl){var n=tl[t];e.push(Y.createElement("option",{key:n,value:n}))}return Y.createElement("div",null,Y.createElement("label",{htmlFor:"host-name"},"Server address:"),Y.createElement("input",{type:"search",id:"host-name",placeholder:this.props.hostName,list:"known-hosts",value:this.state.hostName,onChange:this.handleHostNameChange,onBlur:this.handleEditingFinished,required:!0}),Y.createElement("datalist",{id:"known-hosts"},e))}}class Bl extends Y.PureComponent{constructor(e){super(e),this.handleChange=this.handleChange.bind(this)}handleChange(){this.props.onChange(this.props.name,!this.props.checked)}render(){return this.props.onChange?this.props.checked?Y.createElement("i",{className:"material-icons blue clickable",onClick:this.handleChange},"check_box"):Y.createElement("i",{className:"material-icons blue clickable",onClick:this.handleChange},"check_box_outline_blank"):this.props.checked?Y.createElement("i",{className:"material-icons"},"check_box"):Y.createElement("i",{className:"material-icons"},"check_box_outline_blank")}}class Gl extends Y.Component{constructor(e){super(e),this.state={mode:(e.mode||"").replace("N","")},this.handleChange=this.handleChange.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleCancel=this.handleCancel.bind(this)}handleChange(e){let t=this.state.mode;-1==t.indexOf(e)?t+=e:t=t.replace(e,""),this.setState({mode:t})}handleSubmit(){var e=(this.state.mode||"N").split("").sort().join("");e!==(this.props.mode||"N").split("").sort().join("")?this.props.onSubmit(e):this.props.onCancel()}handleCancel(){this.props.onCancel()}render(){const e={J:"Join (J)",R:"Read (R)",W:"Write (W)",P:"Get notified (P)",A:"Approve (A)",S:"Share (S)",D:"Delete (D)",O:"Owner (O)"};let t=this.props.skip||"",n=this.state.mode,s=(this.props.compare||"").replace("N",""),a=[];for(let i=0;i<"JRWPASDO".length;i++){let r="JRWPASDO".charAt(i);t.indexOf(r)>=0&&n.indexOf(r)<0||a.push(Y.createElement("tr",{key:r},Y.createElement("td",null,e[r]),Y.createElement("td",{className:"checkbox"},t.indexOf(r)<0?Y.createElement(Bl,{name:r,checked:n.indexOf(r)>=0,onChange:this.handleChange}):Y.createElement(Bl,{name:r,checked:n.indexOf(r)>=0})),this.props.compare?Y.createElement("td",{className:"checkbox"},Y.createElement(Bl,{name:r,checked:s.indexOf(r)>=0})):null))}return Y.createElement("div",{className:"panel-form-column"},this.props.userTitle?Y.createElement("ul",{className:"contact-box"},Y.createElement(oc,{item:this.props.item,title:this.props.userTitle,avatar:wl(this.props.userAvatar?this.props.userAvatar:null)})):null,Y.createElement("label",{className:"small"},"Permissions"),Y.createElement("table",{className:"permission-editor"},this.props.compare?Y.createElement("thead",null,Y.createElement("tr",null,Y.createElement("th",null),Y.createElement("th",null,this.props.modeTitle),Y.createElement("th",null,this.props.compareTitle))):null,Y.createElement("tbody",null,a)),Y.createElement("br",null),Y.createElement("div",{className:"dialog-buttons"},Y.createElement("button",{className:"blue",onClick:this.handleSubmit},"Ok"),Y.createElement("button",{className:"white",onClick:this.handleCancel},"Cancel")))}}class Kl extends Y.Component{constructor(e){super(e),this.state={placeholder:e.chips?"":e.prompt,sortedChips:Kl.sortChips(e.chips,e.required),chipIndex:Kl.indexChips(e.chips),input:"",focused:!1},this.handleTextInput=this.handleTextInput.bind(this),this.removeChipAt=this.removeChipAt.bind(this),this.handleChipCancel=this.handleChipCancel.bind(this),this.handleFocusGained=this.handleFocusGained.bind(this),this.handleFocusLost=this.handleFocusLost.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}UNSAFE_componentWillReceiveProps(e){this.setState({sortedChips:Kl.sortChips(e.chips,e.required),chipIndex:Kl.indexChips(e.chips)}),e.chips.length>this.props.chips.length&&this.setState({input:""})}static indexChips(e){var t={},n=0;return e.map(function(e){t[e.user]=n,n++}),t}static sortChips(e,t){var n=[],s=[];return e.map(function(e){e.user===t?n.push(e):s.push(e)}),n.concat(s)}handleTextInput(e){this.setState({input:e.target.value}),this.props.filterFunc&&this.props.filterFunc(e.target.value)}removeChipAt(e){var t=this.state.sortedChips[e];this.props.onChipRemoved(t.user,this.state.chipIndex[t.user])}handleChipCancel(e,t){this.removeChipAt(t)}handleFocusGained(){this.setState({focused:!0})}handleFocusLost(){this.setState({focused:!1}),this.props.onFocusLost&&this.props.onFocusLost(this.state.input)}handleKeyDown(e){if("Backspace"===e.key){if(0==this.state.input.length&&this.state.sortedChips.length>0){var t=this.state.sortedChips.length-1;this.state.sortedChips[t].user!==this.props.required&&this.removeChipAt(t)}}else"Enter"===e.key?this.props.onEnter&&this.props.onEnter(this.state.input):"Escape"===e.key&&this.props.onCancel&&this.props.onCancel()}render(){var e=[],t=0;this.state.sortedChips.map(n=>{e.push(Y.createElement(Ql,{onCancel:this.handleChipCancel,avatar:wl(n.public?n.public.photo:null),title:n.public?n.public.fn:void 0,noAvatar:this.props.avatarDisabled,topic:n.user,required:n.user===this.props.required,index:t,key:n.user})),t++});var n="chip-input"+(this.state.focused?" focused":"");return Y.createElement("div",{className:n},e,Y.createElement("input",{type:"text",placeholder:this.state.placeholder,onChange:this.handleTextInput,onFocus:this.handleFocusGained,onBlur:this.handleFocusLost,onKeyDown:this.handleKeyDown,value:this.state.input,autoFocus:!0}))}}class Ql extends Y.PureComponent{constructor(e){super(e),this.handleCancel=this.handleCancel.bind(this)}handleCancel(){this.props.onCancel(this.props.topic,this.props.index)}render(){var e=this.props.title||this.props.topic;return Y.createElement("div",{className:"chip"},this.props.noAvatar?Y.createElement("span",{className:"spacer"}):Y.createElement("div",{className:"avatar-box"},Y.createElement(Wl,{avatar:this.props.avatar||!0,topic:this.props.topic,title:this.props.title})),Y.createElement("span",null,e),this.props.onCancel&&!this.props.required?Y.createElement("a",{href:"javascript:;",onClick:this.handleCancel},"\xd7"):Y.createElement("span",{className:"spacer"}))}}class $l extends Y.Component{constructor(e){super(e),this.state={onlineSubs:e.subscribers||[]}}static getDerivedStateFromProps(e,t){return{onlineSubs:e.subscribers?e.subscribers:[]}}render(){var e=[];return this.state.onlineSubs.map(t=>{e.push(Y.createElement("div",{className:"avatar-box"},Y.createElement(Wl,{topic:t.user,avatar:wl(t.public?t.public.photo:null)||!0,title:t.public?t.public.fn:null,key:t.user})))}),Y.createElement("div",{id:"topic-users"},e)}}class Jl extends Y.Component{constructor(e){super(e),this.state={login:e.login,password:"",hostName:e.serverAddress,saveToken:localStorage.getObject("keep-logged-in")},this.handleLoginChange=this.handleLoginChange.bind(this),this.handlePasswordChange=this.handlePasswordChange.bind(this),this.handleServerAddressChange=this.handleServerAddressChange.bind(this),this.handleToggleSaveToken=this.handleToggleSaveToken.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}handleLoginChange(e){this.setState({login:e.target.value})}handlePasswordChange(e){this.setState({password:e.target.value})}handleServerAddressChange(e){this.setState({hostName:e}),this.props.onServerAddressChange(e)}handleToggleSaveToken(){localStorage.setObject("keep-logged-in",!this.state.saveToken),this.setState({saveToken:!this.state.saveToken})}handleSubmit(e){e.preventDefault(),this.props.onLogin(this.state.login.trim(),this.state.password.trim())}render(){var e="blue";return this.props.disabled&&(e+=" disabled"),Y.createElement("form",{id:"login-form",onSubmit:this.handleSubmit},Y.createElement("input",{type:"text",id:"inputLogin",placeholder:"Login (alice, bob, carol, dave, frank)",autoComplete:"username",value:this.state.login,onChange:this.handleLoginChange,required:!0,autoFocus:!0}),Y.createElement("input",{type:"password",id:"inputPassword",placeholder:"Password (alice123, bob123, ...)",autoComplete:"current-password",value:this.state.password,onChange:this.handlePasswordChange,required:!0}),Y.createElement("div",{className:"panel-form-row"},Y.createElement(Hl,{serverAddress:this.props.serverAddress,onServerAddressChange:this.handleServerAddressChange})),Y.createElement("div",{className:"panel-form-row"},Y.createElement(Bl,{id:"save-token",name:"save-token",checked:this.state.saveToken,onChange:this.handleToggleSaveToken}),Y.createElement("label",{htmlFor:"save-token"},"\xa0Keep me logged in")),Y.createElement("div",{className:"dialog-buttons"},Y.createElement("button",{className:e,type:"submit"},"Sign in")))}}class Xl extends Y.PureComponent{constructor(e){super(e),this.state={login:"",password:"",password2:"",email:"",fn:"",imageDataUrl:null,errorCleared:!1,saveToken:localStorage.getObject("keep-logged-in")},this.handleLoginChange=this.handleLoginChange.bind(this),this.handlePasswordChange=this.handlePasswordChange.bind(this),this.handlePassword2Change=this.handlePassword2Change.bind(this),this.handleEmailChange=this.handleEmailChange.bind(this),this.handleFnChange=this.handleFnChange.bind(this),this.handleImageChanged=this.handleImageChanged.bind(this),this.handleToggleSaveToken=this.handleToggleSaveToken.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}handleLoginChange(e){this.setState({login:e.target.value})}handlePasswordChange(e){this.setState({password:e.target.value})}handlePassword2Change(e){this.setState({password2:e.target.value})}handleEmailChange(e){this.setState({email:e.target.value})}handleFnChange(e){this.setState({fn:e.target.value})}handleImageChanged(e){this.setState({imageDataUrl:e})}handleToggleSaveToken(){localStorage.setObject("keep-logged-in",!this.state.saveToken),this.setState({saveToken:!this.state.saveToken})}handleSubmit(e){e.preventDefault(),this.state.password.trim()!=this.state.password2.trim()?this.props.onError("Passwords don't match","warn"):(this.setState({errorCleared:!1}),this.props.onCreateAccount(this.state.login.trim(),this.state.password.trim(),Ol(this.state.fn,this.state.imageDataUrl),{meth:"email",val:this.state.email}))}render(){var e="blue";return this.props.disabled&&(e+=" disabled"),Y.createElement("form",{className:"panel-form-column",onSubmit:this.handleSubmit},Y.createElement("div",{className:"panel-form-row"},Y.createElement("div",{className:"panel-form-column"},Y.createElement("input",{type:"text",placeholder:"Login",autoComplete:"user-name",value:this.state.login,onChange:this.handleLoginChange,required:!0,autoFocus:!0}),Y.createElement("input",{type:"password",placeholder:"Password",autoComplete:"new-password",value:this.state.password,onChange:this.handlePasswordChange,required:!0}),Y.createElement("input",{type:"password",placeholder:"Repeat password",autoComplete:"new-password",value:this.state.password2,onChange:this.handlePassword2Change,required:!0})),Y.createElement(Yl,{onImageChanged:this.handleImageChanged,onError:this.props.onError})),Y.createElement("div",{className:"panel-form-row"},Y.createElement("input",{type:"email",placeholder:"Email, e.g john.doe@example.com",autoComplete:"email",value:this.state.email,onChange:this.handleEmailChange,required:!0})),Y.createElement("div",{className:"panel-form-row"},Y.createElement("input",{type:"text",placeholder:"Full name, e.g. John Doe",autoComplete:"name",value:this.state.fn,onChange:this.handleFnChange,required:!0})),Y.createElement("div",{className:"panel-form-row"},Y.createElement(Bl,{id:"save-token",name:"save-token",checked:this.state.saveToken,onChange:this.handleToggleSaveToken}),Y.createElement("label",{htmlFor:"save-token"},"\xa0Keep me logged in")),Y.createElement("div",{className:"dialog-buttons"},Y.createElement("button",{className:e,type:"submit"},"Sign up")))}}class Yl extends Y.Component{constructor(e){super(e),this.state={dataUrl:e.avatar},this.handleFileUpload=this.handleFileUpload.bind(this)}static getDerivedStateFromProps(e,t){return t.dataUrl!=e.avatar?{dataUrl:e.avatar}:null}handleFileUpload(e){_l(e.target.files[0],dl,dl,!0,(e,t)=>{var n=wl({data:e,type:t});this.setState({dataUrl:n}),this.props.onImageChanged(n)},e=>{this.props.onError(e,"err")}),e.target.value=""}render(){var e="file-input-avatar-"+(Math.random()+"").substr(2);return Y.createElement("div",{className:"avatar-upload"},this.state.dataUrl?Y.createElement("img",{src:this.state.dataUrl,className:"preview"}):this.props.readOnly&&this.props.uid?Y.createElement("div",{className:"avatar-box"},Y.createElement(Wl,{avatar:!0,topic:this.props.uid,title:this.props.title})):Y.createElement("div",{className:"blank"},"128\xd7128"),this.props.readOnly?null:Y.createElement("input",{type:"file",id:e,className:"inputfile hidden",accept:"image/*",onChange:this.handleFileUpload}),this.props.readOnly?null:Y.createElement("label",{htmlFor:e,className:"round"},Y.createElement("i",{className:"material-icons"},"file_upload")))}}class Zl extends Y.PureComponent{constructor(e){super(e),this.state={transport:e.transport||"def",messageSounds:e.messageSounds,desktopAlerts:e.desktopAlerts&&e.desktopAlertsEnabled},this.handleSubmit=this.handleSubmit.bind(this),this.handleCheckboxClick=this.handleCheckboxClick.bind(this),this.handleTransportSelected=this.handleTransportSelected.bind(this)}handleSubmit(e){e.preventDefault(),this.props.onUpdate({transport:this.state.transport,messageSounds:this.state.messageSounds,desktopAlerts:this.state.desktopAlerts})}handleCheckboxClick(e,t){"sound"==e?this.setState({messageSounds:t}):"alert"==e&&this.setState({desktopAlerts:t})}handleTransportSelected(e){this.setState({transport:e.currentTarget.value})}render(){var e={def:"default",ws:"websocket",lp:"long polling"},t=[],n=this;return["def","ws","lp"].map(function(s){var a="transport-"+s,i=e[s];t.push(Y.createElement("li",{key:s},Y.createElement("input",{type:"radio",id:a,name:"transport-select",value:s,checked:n.state.transport===s,onChange:n.handleTransportSelected}),Y.createElement("label",{htmlFor:a},i)))}),Y.createElement("form",{id:"settings-form",onSubmit:this.handleSubmit},Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",{htmlFor:"message-sound"},"Message sound:"),Y.createElement(Bl,{name:"sound",id:"message-sound",checked:this.state.messageSounds,onChange:this.handleCheckboxClick})),Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",{htmlFor:"desktop-alerts"},"Notification alerts",this.props.desktopAlertsEnabled?null:" (requires HTTPS)",":"),Y.createElement(Bl,{name:"alert",id:"desktop-alerts",checked:this.state.desktopAlerts,onChange:this.props.desktopAlertsEnabled?this.handleCheckboxClick:null})),Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",{className:"small"},"Wire transport:")),Y.createElement("div",{className:"panel-form-row"},Y.createElement("ul",{className:"quoted"},t)),Y.createElement("div",{className:"dialog-buttons"},Y.createElement("button",{type:"submit",className:"blue"},"Update")))}}class ec extends Y.PureComponent{render(){return Y.createElement("div",{id:"side-caption-panel",className:"caption-panel"},Y.createElement("div",{id:"self-avatar",className:"avatar-box"},Y.createElement(Wl,{avatar:this.props.avatar,topic:this.props.myUserId,title:this.props.title})),Y.createElement("div",{id:"sidepanel-title",className:"panel-title"},this.props.title),"login"===this.props.state?Y.createElement(tc,{onSignUp:this.props.onSignUp,onSettings:this.props.onSettings}):"contacts"===this.props.state?Y.createElement(nc,{onNewTopic:this.props.onNewTopic,onSettings:this.props.onSettings}):null,this.props.onCancel?Y.createElement(ql,{onCancel:this.props.onCancel}):null)}}class tc extends Y.PureComponent{render(){return Y.createElement("div",null,Y.createElement("a",{href:"javascript:;",onClick:this.props.onSignUp},Y.createElement("i",{className:"material-icons"},"person_add")),"\xa0",Y.createElement("a",{href:"javascript:;",onClick:this.props.onSettings},Y.createElement("i",{className:"material-icons"},"settings")))}}class nc extends Y.PureComponent{render(){return Y.createElement("div",null,Y.createElement("a",{href:"javascript:;",onClick:this.props.onNewTopic},Y.createElement("i",{className:"material-icons"},"chat")),"\xa0",Y.createElement("a",{href:"javascript:;",onClick:this.props.onSettings},Y.createElement("i",{className:"material-icons"},"settings")))}}class sc extends Y.Component{constructor(e){super(e),this.handleLoginRequested=this.handleLoginRequested.bind(this)}handleLoginRequested(e,t){this.props.onLoginRequest(e,t)}render(){var e=null,t=!1,n=void 0,s=this.props.state||(this.props.myUserId?"contacts":"login");switch(s){case"login":e="Sign In";break;case"register":e="Create Account",n=this.props.onCancel;break;case"settings":e="Settings",n=this.props.onCancel;break;case"edit":e="Edit Account",n=this.props.onCancel;break;case"contacts":e=this.props.title,t=!this.props.avatar||this.props.avatar;break;case"newtpk":e="Start New Chat",n=this.props.onCancel;break;case"cred":e="Confirm Credentials",n=this.props.onCancel}return Y.createElement("div",{id:"sidepanel",className:this.props.hideSelf?"nodisplay":null},Y.createElement(ec,{state:s,title:e,avatar:t,myUserId:this.props.myUserId,onSignUp:this.props.onSignUp,onSettings:this.props.onSettings,onNewTopic:this.props.onNewTopic,onCancel:n}),Y.createElement(ac,{level:this.props.errorLevel,text:this.props.errorText,onClearError:this.props.onError}),"login"===s?Y.createElement(Jl,{login:this.props.login,disabled:this.props.loginDisabled,serverAddress:this.props.serverAddress,onLogin:this.handleLoginRequested,onServerAddressChange:this.props.onGlobalSettings}):"register"===s?Y.createElement(Xl,{onCreateAccount:this.props.onCreateAccount,onCancel:this.props.onCancel,onError:this.props.onError}):"settings"===s?Y.createElement(Zl,{transport:this.props.transport,messageSounds:this.props.messageSounds,desktopAlerts:this.props.desktopAlerts,desktopAlertsEnabled:this.props.desktopAlertsEnabled,onCancel:this.props.onCancel,onUpdate:this.props.onGlobalSettings}):"edit"===s?Y.createElement(ic,{tinode:this.props.tinode,myUserId:this.props.myUserId,login:this.props.login,onSubmit:this.props.onUpdateAccount,onUpdateTags:this.props.onUpdateAccountTags,onLogout:this.props.onLogout,onCancel:this.props.onCancel,onError:this.props.onError}):"contacts"===s?Y.createElement(cc,{tinode:this.props.tinode,myUserId:this.props.myUserId,connected:this.props.connected,topicSelected:this.props.topicSelected,chatList:this.props.chatList,showContextMenu:this.props.showContextMenu,messageSounds:this.props.messageSounds,onTopicSelected:this.props.onTopicSelected}):"newtpk"===s?Y.createElement(hc,{contactsSearchQuery:this.props.contactsSearchQuery,searchResults:this.props.searchResults,onInitFind:this.props.onInitFind,onSearchContacts:this.props.onSearchContacts,onCreateTopic:this.props.onCreateTopic,onError:this.props.onError}):"cred"===s?Y.createElement(gc,{credCode:this.props.credCode,credMethod:this.props.credMethod,onSubmit:this.props.onValidateCredentials,onCancel:this.props.onCancel,onError:this.props.onError}):null)}}class ac extends Y.PureComponent{constructor(e){super(e),this.state={show:!1},this.hide=this.hide.bind(this)}static getDerivedStateFromProps(e,t){return{show:!!e.level}}hide(){this.setState({show:!1}),this.props.onClearError&&this.props.onClearError()}render(){var e="err"==this.props.level?"error":"warning";return Y.createElement("div",{className:this.state.show?"err"==this.props.level?"alert-box error":"alert-box warning":"alert-box"},Y.createElement("div",{className:"icon"},Y.createElement("i",{className:"material-icons"},e)),this.props.text,Y.createElement("div",{className:"cancel"},Y.createElement(ql,{onCancel:this.hide})))}}class ic extends Y.Component{constructor(e){super(e);let t=this.props.tinode.getMeTopic(),n=t.getDefaultAccess(),s=this.props.tinode.getFndTopic();this.state={fullName:t.public?t.public.fn:void 0,avatar:wl(t.public?t.public.photo:null),auth:n.auth,anon:n.anon,tags:s.tags(),previousOnTags:s.onTagsUpdated},this.tnNewTags=this.tnNewTags.bind(this),this.handleFullNameUpdate=this.handleFullNameUpdate.bind(this),this.handlePasswordUpdate=this.handlePasswordUpdate.bind(this),this.handleImageChanged=this.handleImageChanged.bind(this),this.handleTagsUpdated=this.handleTagsUpdated.bind(this)}componentDidMount(){let e=this.props.tinode.getFndTopic();e.onTagsUpdated=this.tnNewTags,e.isSubscribed()||e.subscribe(e.startMetaQuery().withLaterDesc().withTags().build()).catch(e=>{this.props.onError(e.message,"err")})}componentWillUnmount(){this.props.tinode.getFndTopic().onTagsUpdated=this.state.previousOnTags}tnNewTags(e){this.setState({tags:e})}handleFullNameUpdate(e){this.setState({fullName:e}),this.props.onSubmit(null,Ol(e,this.state.avatar))}handlePasswordUpdate(e){this.setState({password:e}),this.props.onSubmit(e,null)}handleImageChanged(e){this.setState({avatar:e}),this.props.onSubmit(null,Ol(this.state.fullName,e))}handleTagsUpdated(e){Ll(this.state.tags.slice(0),e.slice(0))||this.props.onUpdateTags(e)}render(){var e=[];return this.state.tags.map(function(t){e.push(Y.createElement("span",{className:"badge",key:e.length},t))}),0==e.length&&(e=Y.createElement("i",null,"No tags defined. Add some.")),Y.createElement("div",{id:"edit-account",className:"panel-form"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("div",{className:"panel-form-column"},Y.createElement("div",null,Y.createElement("label",{className:"small"},"Your name")),Y.createElement("div",null,Y.createElement(Vl,{placeholder:"Full name, e.g. John Doe",text:this.state.fullName,onFinished:this.handleFullNameUpdate})),Y.createElement("div",null,Y.createElement("label",{className:"small"},"Password")),Y.createElement("div",null,Y.createElement(Vl,{placeholder:"Unchanged",type:"password",onFinished:this.handlePasswordUpdate}))),Y.createElement(Yl,{avatar:this.state.avatar,uid:this.props.myUserId,title:this.state.fullName,onImageChanged:this.handleImageChanged,onError:this.props.onError})),Y.createElement("div",{className:"hr"}),Y.createElement("div",{className:"panel-form-column"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",null,"Login:"),Y.createElement("tt",null,this.props.login)),Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",null,"Address:"),Y.createElement("tt",null,this.props.myUserId)),Y.createElement("div",null,Y.createElement("label",{className:"small"},"Default access mode:")),Y.createElement("div",{className:"quoted"},Y.createElement("div",null,"Auth: ",Y.createElement("tt",null,this.state.auth)),Y.createElement("div",null,"Anon: ",Y.createElement("tt",null,this.state.anon)))),Y.createElement("div",{className:"hr"}),Y.createElement(rc,{title:"Tags (user discovery)",activated:!1,tags:this.state.tags,onSubmit:this.handleTagsUpdated}),Y.createElement("div",{className:"hr"}),Y.createElement("div",{className:"panel-form-column"},Y.createElement("a",{href:"javascript:;",className:"red flat-button",onClick:this.props.onLogout},Y.createElement("i",{className:"material-icons"},"exit_to_app")," Logout")))}}class rc extends Y.Component{constructor(e){super(e),this.state={tags:this.props.tags,tagInput:"",activated:this.props.activated,noTagsMessage:"Add some tags"},this.handleShowTagManager=this.handleShowTagManager.bind(this),this.handleTagInput=this.handleTagInput.bind(this),this.handleAddTag=this.handleAddTag.bind(this),this.handleRemoveTag=this.handleRemoveTag.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleCancel=this.handleCancel.bind(this)}static getDerivedStateFromProps(e,t){return Ll(e.tags,t.tags)||t.activated?null:{tags:e.tags}}handleShowTagManager(){this.setState({activated:!0})}handleTagInput(e){if(this.setState({tagInput:e}),e.length>0){var t=e[e.length-1];if(","==t||" "==t||";"==t){var n=e.substr(0,e.length-1).trim();n.length>=ll&&this.handleAddTag(n)}}}handleAddTag(e){if((e=e.trim()).length>0){let t=this.state.tags.slice(0);t.push(e),this.setState({tags:t,tagInput:""}),this.props.onTagsChanged&&this.props.onTagsChanged(t)}}handleRemoveTag(e,t){var n=this.state.tags.slice(0);n.splice(t,1),this.setState({tags:n}),this.props.onTagsChanged&&this.props.onTagsChanged(n)}handleSubmit(){let e=this.state.tags.slice(0),t=this.state.tagInput.trim();t.length>0&&(e.push(t),this.props.onTagsChanged&&this.props.onTagsChanged(e)),this.props.onSubmit(e),this.setState({activated:!1,tagInput:"",tags:this.props.tags})}handleCancel(){this.setState({activated:!1,tagInput:"",tags:this.props.tags}),this.props.onCancel&&this.props.onCancel()}render(){var e=[];return this.state.activated?this.state.tags.map(function(t){e.push({user:t})}):(this.state.tags.map(function(t){e.push(Y.createElement("span",{className:"badge",key:e.length},t))}),0==e.length&&(e=Y.createElement("i",null,"No tags defined. Add some."))),Y.createElement("div",{className:"panel-form-column"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",{className:"small"},this.props.title)),this.state.activated?Y.createElement("div",null,Y.createElement(Kl,{chips:e,avatarDisabled:!0,prompt:this.state.noTagsMessage,onEnter:this.handleAddTag,onFocusLost:this.handleAddTag,onCancel:this.handleCancel,onChipRemoved:this.handleRemoveTag,filterFunc:this.handleTagInput}),this.props.onSubmit||this.props.onCancel?Y.createElement("div",{id:"tag-manager-buttons",className:"panel-form-row"},Y.createElement("button",{className:"blue",onClick:this.handleSubmit},"OK"),Y.createElement("button",{className:"white",onClick:this.handleCancel},"Cancel")):null):Y.createElement("div",null,Y.createElement("a",{href:"javascript:;",className:"flat-button",onClick:this.handleShowTagManager},Y.createElement("i",{className:"material-icons"},"edit")," Manage tags"),Y.createElement("span",null,e)))}}class oc extends Y.Component{constructor(e){super(e),this.handleClick=this.handleClick.bind(this),this.handleContextClick=this.handleContextClick.bind(this)}handleClick(e){e.preventDefault(),e.stopPropagation(),this.props.onSelected&&this.props.onSelected(this.props.item,this.props.index,this.props.now,this.props.acs)}handleContextClick(e){e.preventDefault(),e.stopPropagation(),this.props.showContextMenu({topicName:this.props.item,y:e.pageY,x:e.pageX})}render(){var e=this.props.title;e?e.length>30&&(e=e.substring(0,28)+"..."):e=Y.createElement("i",null,"unknown");var t=this.props.now?"online":"offline",n=!this.props.avatar||this.props.avatar,s=[];if(this.props.badges&&this.props.badges.length>0){var a=0;this.props.badges.map(function(e){var t="badge"+(e.color?" "+e.color:"");s.push(Y.createElement("span",{className:t,key:a},e.name)),a++})}return this.props.showMode&&this.props.acs&&s.push(Y.createElement("span",{className:"badge",key:"mode"},this.props.acs.getMode())),Y.createElement("li",{className:!this.props.showCheckmark&&this.props.selected?"selected":null,onClick:this.handleClick},Y.createElement("div",{className:"avatar-box"},Y.createElement(Wl,{avatar:n,title:this.props.title,topic:this.props.item}),this.props.showOnline?Y.createElement("span",{className:t}):this.props.showCheckmark&&this.props.selected?Y.createElement("i",{className:"checkmark material-icons"},"check_circle"):null),Y.createElement("div",{className:"text-box"},Y.createElement("div",null,Y.createElement("span",{className:"contact-title"},e),this.props.unread>0?Y.createElement(lc,{count:this.props.unread}):null),this.props.comment?Y.createElement("div",{className:"contact-comment"},this.props.comment):null,Y.createElement("span",null,s)),this.props.showContextMenu?Y.createElement("span",{className:"menuTrigger"},Y.createElement("a",{href:"javascript:;",onClick:this.handleContextClick},Y.createElement("i",{className:"material-icons"},"expand_more"))):null)}}class lc extends Y.PureComponent{render(){var e=null;if(this.props.count>0){var t=this.props.count>9?"9+":this.props.count;e=Y.createElement("span",{className:"unread"},t)}return e}}class cc extends Y.Component{constructor(e){super(e),this.state=cc.getDerivedStateFromProps(e,{})}static getDerivedStateFromProps(e,t){let n=[],s=0;return e.chatList.map(e=>{s+=e.unread>0?1:0,n.push(e)}),n.sort(function(e,t){return t.touched-e.touched}),function(e){var t=document.getElementById("shortcut-icon");if(t){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("link");s.type="image/png",s.id="shortcut-icon",s.rel="shortcut icon",s.href="img/logo32x32"+(e>0?"a":"")+".png",n.removeChild(t),n.appendChild(s)}document.title=(e>0?"("+e+") ":"")+"Tinode"}(s),{contactList:n}}render(){return Y.createElement(uc,{connected:this.props.connected,contacts:this.state.contactList,emptyListMessage:Y.createElement("span",null,"You have no chats",Y.createElement("br",null),"\xaf\\_(\u30c4)_/\xaf"),topicSelected:this.props.topicSelected,myUserId:this.props.myUserId,showOnline:!0,showUnread:!0,onTopicSelected:this.props.onTopicSelected,showContextMenu:this.props.showContextMenu})}}class uc extends Y.Component{render(){var e=[],t=Array.isArray(this.props.topicSelected);return this.props.contacts&&this.props.contacts.length>0&&this.props.contacts.map(n=>{var s=n.topic?n.topic:n.user;if(this.props.filterFunc&&this.props.filter){var a=[s];if(n.private&&n.private.comment&&a.push((""+n.private.comment).toLowerCase()),n.public&&n.public.fn&&a.push((""+n.public.fn).toLowerCase()),!this.props.filterFunc(this.props.filter,a))return}var i=t?this.props.topicSelected.indexOf(s)>-1:this.props.topicSelected===s,r=[];this.props.showMode&&(s===this.props.myUserId&&r.push({name:"you",color:"green"}),n.acs&&n.acs.isOwner()&&r.push({name:"owner"}));var o=Array.isArray(n.private)?n.private.join(", "):n.private?n.private.comment:null;e.push(Y.createElement(oc,{title:n.public?n.public.fn:null,avatar:wl(n.public?n.public.photo:null),comment:o,unread:this.props.showUnread?n.unread:0,now:n.online&&this.props.connected,acs:n.acs,showMode:this.props.showMode,badges:r,showCheckmark:t,selected:i,showOnline:this.props.showOnline,onSelected:this.props.onTopicSelected,showContextMenu:this.props.showContextMenu,item:s,index:e.length,key:s}))},this),Y.createElement("div",{className:this.props.noScroll?null:"scrollable-panel"},e.length>0?Y.createElement("ul",{className:"contact-box"},e):Y.createElement("div",{className:"center-medium-text"},this.props.emptyListMessage))}}class dc extends Y.Component{constructor(e){super(e),this.state={members:e.members,index:dc.indexMembers(e.members),contactFilter:"",noContactsMessage:"You have no contacts :-(",selectedContacts:dc.selectedContacts(e.members)},this.handleContactSelected=this.handleContactSelected.bind(this),this.handleMemberRemoved=this.handleMemberRemoved.bind(this),this.handleContactFilter=this.handleContactFilter.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleCancel=this.handleCancel.bind(this)}static indexMembers(e){var t={};return e.map(function(e){t[e.user]={delta:0,present:!0}}),t}static selectedContacts(e){var t=[];return e.map(function(e){t.push(e.user)}),t}handleContactSelected(e,t){var n=this.state.index[e];if(n){if(n.present)return;n.delta+=1,n.present=!0}else n={delta:1,present:!0};var s=this.state.members.slice();s.push(this.props.contacts[t]);var a=dc.selectedContacts(s),i=this.state.index;i[e]=n,this.setState({members:s,index:i,selectedContacts:a})}handleMemberRemoved(e,t){var n=this.state.index[e];if(n&&n.present){n.present=!1,n.delta-=1;var s=this.state.members.slice();s.splice(t,1);var a=dc.selectedContacts(s),i=this.state.index;i[e]=n,this.setState({members:s,index:i,selectedContacts:a})}}handleContactFilter(e){var t=e?"No contacts match '"+e+"'":"You have no contacts :-(";this.setState({contactFilter:e,noContactsMessage:t})}static doContactFiltering(e,t){if(e){for(var n=0;n=0)return!0;return!1}return!0}handleSubmit(){var e=this,t=[],n=[],s=[];Object.keys(this.state.index).map(function(a){e.state.index[a].present&&t.push(a),e.state.index[a].delta>0?n.push(a):e.state.index[a].delta<0&&s.push(a)}),this.props.onSubmit(t,n,s)}handleCancel(){this.props.onCancel()}render(){return Y.createElement("div",{id:"group-manager"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",{className:"small"},"Group members")),Y.createElement("div",{className:"panel-form-row"},Y.createElement(Kl,{chips:this.state.members,required:this.props.requiredMember,prompt:"add members",filterFunc:this.handleContactFilter,onChipRemoved:this.handleMemberRemoved})),Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",{className:"small"},"All contacts")),Y.createElement(uc,{contacts:this.props.contacts,myUserId:this.props.myUserId,topicSelected:this.state.selectedContacts,filter:this.state.contactFilter,filterFunc:dc.doContactFiltering,emptyListMessage:this.state.noContactsMessage,showOnline:!1,showUnread:!1,onTopicSelected:this.handleContactSelected}),Y.createElement("div",{id:"group-manager-buttons",className:"panel-form-row"},Y.createElement("button",{className:"blue",onClick:this.handleSubmit},"OK"),Y.createElement("button",{className:"white",onClick:this.handleCancel},"Cancel")))}}class hc extends Y.Component{constructor(e){super(e),this.state={tabSelected:"p2p",searchQuery:e.contactsSearchQuery,contactList:e.searchResults},this.handleTabClick=this.handleTabClick.bind(this),this.handleContactSelected=this.handleContactSelected.bind(this),this.handleNewGroupSubmit=this.handleNewGroupSubmit.bind(this),this.handleGroupByID=this.handleGroupByID.bind(this)}componentDidMount(){this.props.onInitFind()}static getDerivedStateFromProps(e,t){return{searchQuery:e.contactsSearchQuery,contactList:e.searchResults}}handleTabClick(e){e.preventDefault(),Nl(Ul(window.location.hash,"tab",e.currentTarget.dataset.id)),this.setState({tabSelected:e.currentTarget.dataset.id})}handleContactSelected(e){"p2p"===this.state.tabSelected&&(Nl(Dl(window.location.hash,"tab")),this.props.onCreateTopic(e,void 0))}handleNewGroupSubmit(e,t,n,s){Nl(Dl(window.location.hash,"tab")),this.props.onCreateTopic(void 0,Ol(e,t),n,s)}handleGroupByID(e){Nl(Dl(window.location.hash,"tab")),this.props.onCreateTopic(e)}render(){return Y.createElement("div",{className:"flex-column"},Y.createElement("ul",{className:"tabbar"},Y.createElement("li",{className:"p2p"===this.state.tabSelected?"active":null},Y.createElement("a",{href:"javascript:;","data-id":"p2p",onClick:this.handleTabClick},"find")),Y.createElement("li",{className:"grp"===this.state.tabSelected?"active":null},Y.createElement("a",{href:"javascript:;","data-id":"grp",onClick:this.handleTabClick},"new group")),Y.createElement("li",{className:"byid"===this.state.tabSelected?"active":null},Y.createElement("a",{href:"javascript:;","data-id":"byid",onClick:this.handleTabClick},"by id"))),"grp"===this.state.tabSelected?Y.createElement(pc,{onSubmit:this.handleNewGroupSubmit}):"byid"===this.state.tabSelected?Y.createElement(fc,{onSubmit:this.handleGroupByID,onError:this.props.onError}):Y.createElement("div",{className:"flex-column"},Y.createElement(mc,{type:"p2p",searchQuery:this.state.searchQuery,onSearchContacts:this.props.onSearchContacts}),Y.createElement(uc,{contacts:this.state.contactList,myUserId:this.props.myUserId,emptyListMessage:"Use search to find contacts",topicSelected:this.state.selectedContact,showOnline:!1,showUnread:!1,showContextMenu:!1,onTopicSelected:this.handleContactSelected})))}}class pc extends Y.PureComponent{constructor(e){super(e),this.state={fn:"",private:"",imageDataUrl:null,tags:[]},this.handleFnChange=this.handleFnChange.bind(this),this.handlePrivateChange=this.handlePrivateChange.bind(this),this.handleImageChanged=this.handleImageChanged.bind(this),this.handleTagsChanged=this.handleTagsChanged.bind(this),this.handleTagsChanged=this.handleTagsChanged.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}handleFnChange(e){this.setState({fn:e.target.value})}handlePrivateChange(e){this.setState({private:e.target.value})}handleImageChanged(e){this.setState({imageDataUrl:e})}handleTagsChanged(e){this.setState({tags:e})}handleSubmit(e){e.preventDefault(),this.state.fn&&this.state.fn.trim()&&this.props.onSubmit(this.state.fn.trim(),this.state.imageDataUrl,this.state.private.trim(),this.state.tags)}render(){var e="blue";return this.props.disabled&&(e+=" disabled"),Y.createElement("form",{className:"panel-form",onSubmit:this.handleSubmit},Y.createElement("div",{className:"panel-form-row"},Y.createElement("div",{className:"panel-form-column"},Y.createElement("label",{className:"small",htmlFor:"new-topic-fn"},"Group name"),Y.createElement("input",{type:"text",id:"new-topic-fn",placeholder:"Freeform name of the group",value:this.state.fn,onChange:this.handleFnChange,autoFocus:!0,required:!0}),Y.createElement("br",null),Y.createElement("label",{className:"small",htmlFor:"new-topic-priv"},"Private comment"),Y.createElement("input",{type:"text",id:"new-topic-priv",placeholder:"Visible to you only",value:this.state.private,onChange:this.handlePrivateChange})),Y.createElement(Yl,{onError:this.props.onError,onImageChanged:this.handleImageChanged})),Y.createElement(rc,{tags:this.state.tags,activated:!0,onTagsChanged:this.handleTagsChanged,title:"Optional tags (search and discovery)"}),Y.createElement("div",{className:"dialog-buttons"},Y.createElement("button",{className:e},"Create")))}}class mc extends Y.Component{constructor(e){super(e),this.state={edited:!1,search:e.searchQuery},this.handleSearchChange=this.handleSearchChange.bind(this),this.handleSearch=this.handleSearch.bind(this),this.handleClear=this.handleClear.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}componentWillUnmount(){this.state.search&&(this.setState({search:""}),this.props.onSearchContacts(Yo.DEL_CHAR))}handleSearchChange(e){this.setState({search:e.target.value})}handleSearch(e){e.preventDefault();var t=this.state.search.trim();t.length>0?(this.setState({edited:!0}),this.props.onSearchContacts(t)):this.props.searchQuery&&this.props.onSearchContacts(Yo.DEL_CHAR)}handleClear(){(this.state.edited||this.state.search)&&this.props.onSearchContacts(Yo.DEL_CHAR),this.setState({search:"",edited:!1})}handleKeyDown(e){"Enter"===e.key?this.handleSearch(e):"Escape"===e.key&&this.handleClear()}render(){return Y.createElement("div",{className:"panel-form"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("i",{className:"material-icons search"},"search"),Y.createElement("input",{className:"search",type:"text",placeholder:"List like email:alice@example.com, tel:17025550003...",value:this.state.search,onChange:this.handleSearchChange,onKeyDown:this.handleKeyDown,required:!0,autoFocus:!0}),Y.createElement("a",{href:"javascript:;",onClick:this.handleClear},Y.createElement("i",{className:"material-icons"},"close"))))}}class fc extends Y.PureComponent{constructor(e){super(e),this.state={groupId:""},this.handleChange=this.handleChange.bind(this),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}handleChange(e){this.setState({groupId:e.target.value})}handleKeyPress(e){"Enter"===e.key&&this.handleSubmit(e)}handleSubmit(e){if(e.preventDefault(),this.state.groupId){var t=this.state.groupId.trim();t.length>3&&("usr"==t.substr(0,3)||"grp"==t.substr(0,3))?this.props.onSubmit(t):this.props.onError("Invalid ID","err")}}render(){return Y.createElement("div",{className:"panel-form"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("input",{type:"text",placeholder:"Group or User ID",value:this.state.groupId,onChange:this.handleChange,onKeyPress:this.handleKeyPress,required:!0})),Y.createElement("div",{className:"dialog-buttons"},Y.createElement("button",{className:"blue",onClick:this.handleSubmit},"Subscribe")))}}class gc extends Y.PureComponent{constructor(e){super(e),this.state={code:e.credCode},this.handleChange=this.handleChange.bind(this),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}static getDerivedStateFromProps(e,t){return{code:e.credCode}}handleChange(e){this.setState({code:e.target.value})}handleKeyPress(e){"Enter"===e.key&&this.handleSubmit(e)}handleSubmit(e){e.preventDefault(),this.state.code&&this.state.code.trim()&&this.props.onSubmit(this.props.credMethod,this.state.code.trim())}render(){var e={email:"email",tel:"phone"}[this.props.credMethod]||this.props.credMethod;return Y.createElement("div",{className:"panel-form"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",{className:"small",htmlFor:"enter-confirmation-code"},"Enter confirmation code sent to you by ",e,":")),Y.createElement("div",{className:"panel-form-row"},Y.createElement("input",{type:"text",id:"enter-confirmation-code",placeholder:"Numbers only",value:this.state.code,onChange:this.handleChange,onKeyPress:this.handleKeyPress,required:!0})),Y.createElement("div",{className:"dialog-buttons"},Y.createElement("button",{className:"blue",onClick:this.handleSubmit},"Confirm")))}}class vc extends Y.Component{constructor(e){super(e),this.state={topic:null,owner:!1,admin:!1,sharer:!1,muted:!1,address:null,groupTopic:void 0,fullName:void 0,avatar:null,private:null,selectedContact:null,access:null,modeGiven:null,modeWant:null,modeGiven2:null,modeWant2:null,auth:null,anon:null,contactList:[],tags:[],showMemberPanel:!1,showPermissionEditorFor:void 0,moreInfoExpanded:!1,previousMetaDesc:void 0,previousSubsUpdated:void 0,previousTagsUpdated:void 0},this.resetSubs=this.resetSubs.bind(this),this.resetDesc=this.resetDesc.bind(this),this.onMetaDesc=this.onMetaDesc.bind(this),this.onSubsUpdated=this.onSubsUpdated.bind(this),this.onTagsUpdated=this.onTagsUpdated.bind(this),this.handleFullNameUpdate=this.handleFullNameUpdate.bind(this),this.handlePrivateUpdate=this.handlePrivateUpdate.bind(this),this.handleImageChanged=this.handleImageChanged.bind(this),this.handleMuted=this.handleMuted.bind(this),this.handlePermissionsChanged=this.handlePermissionsChanged.bind(this),this.handleLaunchPermissionsEditor=this.handleLaunchPermissionsEditor.bind(this),this.handleHidePermissionsEditor=this.handleHidePermissionsEditor.bind(this),this.handleShowAddMembers=this.handleShowAddMembers.bind(this),this.handleHideAddMembers=this.handleHideAddMembers.bind(this),this.handleMemberUpdateRequest=this.handleMemberUpdateRequest.bind(this),this.handleLeave=this.handleLeave.bind(this),this.handleMemberSelected=this.handleMemberSelected.bind(this),this.handleMoreInfo=this.handleMoreInfo.bind(this),this.handleTagsUpdated=this.handleTagsUpdated.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this)}UNSAFE_componentWillReceiveProps(e){var t=this.props.tinode.getTopic(e.topic);t&&(this.onMetaDesc!=t.onMetaDesc&&(this.previousMetaDesc=t.onMetaDesc,t.onMetaDesc=this.onMetaDesc,this.previousSubsUpdated=t.onSubsUpdated,t.onSubsUpdated=this.onSubsUpdated,"grp"==t.getType()?(this.previousTagsUpdated=t.onTagsUpdated,t.onTagsUpdated=this.onTagsUpdated):this.previousTagsUpdated=void 0),this.state.topic!=e.topic&&(this.setState({topic:e.topic}),this.resetDesc(t,e),this.resetSubs(t,e)))}componentWillUnmount(){var e=this.props.tinode.getTopic(this.props.topic);e&&(this.setState({topic:null}),e.onMetaDesc=this.previousMetaDesc,e.onSubsUpdated=this.previousSubsUpdated,e.onTagsUpdated=this.previousTagsUpdated)}resetSubs(e,t){var n={contactList:[]};if("p2p"==e.getType()){var s=e.subscriber(t.topic);s&&(n.modeGiven2=s.acs.getGiven(),n.modeWant2=s.acs.getWant())}else e.subscribers(function(e){n.contactList.push(e)},this);this.setState(n)}resetDesc(e,t){var n=e.getDefaultAccess()||{},s=e.getAccessMode();this.setState({owner:s&&s.isOwner(),admin:s&&s.isAdmin(),sharer:s&&(s.isAdmin()||s.isSharer()),muted:s&&s.isMuted(),fullName:e.public?e.public.fn:void 0,avatar:wl(e.public?e.public.photo:null),private:e.private?e.private.comment:null,address:e.name,groupTopic:"grp"==e.getType(),showMemberPanel:!1,access:s?s.getMode():void 0,modeGiven:s?s.getGiven():void 0,modeWant:s?s.getWant():void 0,auth:n.auth,anon:n.anon}),"grp"===e.getType()&&s&&s.isOwner()&&e.getMeta(e.startMetaQuery().withTags().build())}onMetaDesc(e){var t=this.props.tinode.getTopic(this.props.topic);t&&(this.resetDesc(t,this.props),this.previousMetaDesc&&this.previousMetaDesc!=this.onMetaDesc&&this.previousMetaDesc(e))}onSubsUpdated(){var e=this.props.tinode.getTopic(this.props.topic);e&&(this.resetSubs(e,this.props),this.previousSubsUpdated&&this.previousSubsUpdated!=this.onSubsUpdated&&this.previousSubsUpdated())}onTagsUpdated(e){this.setState({tags:e}),this.previousTagsUpdated&&this.previousTagsUpdated!=this.onTagsUpdated&&this.previousTagsUpdated()}handleFullNameUpdate(e){this.state.fullName!==e&&(this.setState({fullName:e}),this.props.onTopicDescUpdate(this.props.topic,Ol(e,this.state.avatar),null))}handlePrivateUpdate(e){this.state.priv!==e&&(this.setState({private:e}),this.props.onTopicDescUpdate(this.props.topic,null,e))}handleImageChanged(e){this.setState({avatar:e}),this.props.onTopicDescUpdate(this.props.topic,Ol(this.state.fullName,e),null)}handleMuted(e,t){this.setState({muted:t}),this.props.onChangePermissions(this.props.topic,t?"-P":"+P")}handlePermissionsChanged(e){switch(this.state.showPermissionEditorFor){case"auth":this.props.onTopicDescUpdate(this.props.topic,null,null,{auth:e});break;case"anon":this.props.onTopicDescUpdate(this.props.topic,null,null,{anon:e});break;case"mode":case"want":this.props.onChangePermissions(this.props.topic,e);break;case"given":this.props.onChangePermissions(this.props.topic,e,this.props.topic);break;case"user":this.props.onChangePermissions(this.props.topic,e,this.state.userPermissionsEdited)}this.setState({showPermissionEditorFor:void 0})}handleLaunchPermissionsEditor(e,t){var n,s,a,i,r,o,l;switch(e){case"mode":n=this.state.access;break;case"want":n=this.state.modeWant,s=this.state.modeGiven,a=this.state.groupTopic?"O":"ASDO",i="Requested",r="Granted";break;case"given":n=this.state.modeGiven2,s=this.state.modeWant2,a=this.state.groupTopic?this.state.owner?"":"O":"ASDO",i="Granted",r="Requested";break;case"auth":n=this.state.auth,a="O";break;case"anon":n=this.state.anon,a="O";break;case"user":var c=this.props.tinode.getTopic(this.props.topic);if(!c)return;var u=c.subscriber(t);if(!u||!u.acs)return;n=u.acs.getGiven(),s=u.acs.getWant(),a=this.state.owner?"":"O",i="Granted",r="Requested",u.public&&(o=u.public.fn,l=u.public.photo);break;default:console.log("Unknown permission editing mode '"+e+"'")}this.setState({showPermissionEditorFor:e,userPermissionsEdited:t,userPermissionsTitle:o,userPermissionsAvatar:l,editedPermissions:n,immutablePermissions:s,editedPermissionsTitle:i,immutablePermissionsTitle:r,editedPermissionsSkipped:a})}handleHidePermissionsEditor(){this.setState({showPermissionEditorFor:void 0})}handleShowAddMembers(){this.props.onInitFind(),this.setState({showMemberPanel:!0})}handleHideAddMembers(){this.setState({showMemberPanel:!1})}handleMemberUpdateRequest(e,t,n){this.props.onMemberUpdateRequest(this.props.topic,t,n),this.setState({showMemberPanel:!1})}handleLeave(){this.props.onLeaveTopic(this.props.topic)}handleMemberSelected(e){this.setState({selectedContact:e})}handleMoreInfo(e){this.setState({moreInfoExpanded:e})}handleTagsUpdated(e){Ll(this.state.tags.slice(0),e.slice(0))||this.props.onTopicTagsUpdate(this.props.topic,e)}handleContextMenu(e){var t=this,n=this.props.tinode.getTopic(this.props.topic);if(n){var s=n.subscriber(e.topicName);if(s&&s.acs){var a=[{title:"Edit permissions",handler:function(){t.handleLaunchPermissionsEditor("user",e.topicName)}},"member_delete",s.acs.isMuted()?"member_unmute":"member_mute",s.acs.isJoiner()?"member_block":"member_unblock"];this.props.showContextMenu({topicName:this.props.topic,x:e.x,y:e.y,user:e.topicName},a)}}}render(){return Y.createElement("div",{id:"info-view"},Y.createElement("div",{className:"caption-panel",id:"info-caption-panel"},Y.createElement("div",{className:"panel-title",id:"info-title"},"Info"),Y.createElement("div",null,Y.createElement(ql,{onCancel:this.props.onCancel}))),this.props.displayMobile?Y.createElement(ac,{level:this.props.errorLevel,text:this.props.errorText,onClearError:this.props.onError}):null,this.state.showMemberPanel?Y.createElement(dc,{members:this.state.contactList,requiredMember:this.props.myUserId,myUserId:this.props.myUserId,contacts:this.props.searchableContacts,onCancel:this.handleHideAddMembers,onSubmit:this.handleMemberUpdateRequest}):this.state.showPermissionEditorFor?Y.createElement(Gl,{mode:this.state.editedPermissions,compare:this.state.immutablePermissions,skip:this.state.editedPermissionsSkipped,modeTitle:this.state.editedPermissionsTitle,compareTitle:this.state.immutablePermissionsTitle,userTitle:this.state.userPermissionsTitle,item:this.state.userPermissionsEdited,userAvatar:this.state.userPermissionsAvatar,skip:this.state.editedPermissionsSkipped,onSubmit:this.handlePermissionsChanged,onCancel:this.handleHidePermissionsEditor}):Y.createElement("div",{id:"info-view-content",className:"scrollable-panel"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("div",{className:"panel-form-column"},Y.createElement("div",null,Y.createElement("label",{className:"small"},"Name")),Y.createElement("div",null,Y.createElement(Vl,{placeholder:"Group name",readOnly:!this.state.owner,text:this.state.fullName,onFinished:this.handleFullNameUpdate})),Y.createElement("div",null,Y.createElement("label",{className:"small"},"Private comment")),Y.createElement("div",null,Y.createElement(Vl,{placeholder:"Visible to you only",text:this.state.private,onFinished:this.handlePrivateUpdate}))),Y.createElement(Yl,{avatar:this.state.avatar,readOnly:!this.state.owner,uid:this.props.topic,title:this.state.fullName,onImageChanged:this.handleImageChanged,onError:this.props.onError})),Y.createElement("div",{className:"hr"}),Y.createElement("div",{className:"panel-form-column"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",null,"Muted:"),Y.createElement(Bl,{name:"P",checked:this.state.muted,onChange:this.handleMuted})),Y.createElement(zl,{title:"More",open:this.state.moreInfoExpanded,onToggle:this.handleMoreInfo}),this.state.moreInfoExpanded?Y.createElement("div",{className:"panel-form-column"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",null,"Address:"),Y.createElement("tt",null,this.state.address)),this.state.groupTopic?Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",null,"Your permissions:"),Y.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"want")},this.state.access)):Y.createElement("div",null,Y.createElement("div",null,Y.createElement("label",{className:"small"},"Permissions:")),Y.createElement("div",{className:"quoted"},Y.createElement("div",null,"Yours: \xa0",Y.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"want")},this.state.access)),Y.createElement("div",null,this.state.fullName,"\u2032s: \xa0",Y.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"given")},this.state.modeGiven2)))),this.state.sharer&&(this.state.auth||this.state.anon)?Y.createElement("div",null,Y.createElement("div",null,Y.createElement("label",{className:"small"},"Default access mode:")),Y.createElement("div",{className:"quoted"},Y.createElement("div",null,"Auth: ",this.state.admin?Y.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"auth")},this.state.auth):Y.createElement("tt",null,this.state.auth)),Y.createElement("div",null,"Anon: ",this.state.admin?Y.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"anon")},this.state.anon):Y.createElement("tt",null,this.state.anon)))):null):null),Y.createElement("div",{className:"hr"}),this.state.owner?Y.createElement(rc,{title:"Tags",tags:this.state.tags,activated:!1,onSubmit:this.handleTagsUpdated}):null,this.state.owner?Y.createElement("div",{className:"hr"}):null,this.state.groupTopic?Y.createElement("div",{className:"panel-form-column"},Y.createElement("div",{className:"panel-form-row"},Y.createElement("label",{className:"small"},"Group members:")),Y.createElement("div",{className:"panel-form-row"},this.state.sharer?Y.createElement("a",{href:"javascript:;",className:"flat-button",onClick:this.handleShowAddMembers},Y.createElement("i",{className:"material-icons"},"person_add")," Add members"):null,this.state.owner?null:Y.createElement("a",{href:"javascript:;",className:"red flat-button",onClick:this.handleLeave},Y.createElement("i",{className:"material-icons"},"exit_to_app")," Leave")),Y.createElement(uc,{contacts:this.state.contactList,myUserId:this.props.myUserId,emptyListMessage:"No members",topicSelected:this.state.selectedContact,showOnline:!1,showUnread:!1,showMode:!0,noScroll:!0,onTopicSelected:this.handleMemberSelected,showContextMenu:!!this.state.admin&&this.handleContextMenu})):Y.createElement("div",{className:"panel-form-row"},Y.createElement("a",{href:"javascript:;",className:"red flat-button",onClick:this.handleLeave},Y.createElement("i",{className:"material-icons"},"exit_to_app")," Leave"))))}}class bc extends Y.Component{constructor(e){super(e),this.state={progress:0},e.uploader&&(e.uploader.onProgress=this.handleProgress.bind(this)),this.handlePreviewImage=this.handlePreviewImage.bind(this),this.handleContextClick=this.handleContextClick.bind(this),this.handleCancelUpload=this.handleCancelUpload.bind(this)}handlePreviewImage(e){e.preventDefault(),this.props.onImagePreview({url:e.target.src,filename:e.target.title,width:e.target.dataset.width,height:e.target.dataset.height,size:e.target.dataset.size,type:e.target.dataset.mime})}handleContextClick(e){e.preventDefault(),e.stopPropagation(),this.props.showContextMenu({seq:this.props.seq,y:e.pageY,x:e.pageX})}handleProgress(e){this.setState({progress:e})}handleCancelUpload(){this.props.uploader.cancel()}render(){var e=0,t=this.props.sequence+" "+(this.props.response?"left":"right"),n="single"==this.props.sequence||"last"==this.props.sequence?"bubble tip":"bubble",s=this.props.userAvatar||!0,a=this.props.userFrom&&this.props.response&&("single"==this.props.sequence||"last"==this.props.sequence),i=this.props.content,r=[];return this.props.mimeType==Zo.getContentType()?(Zo.attachments(i,function(e,t){r.push(Y.createElement(Ec,{tinode:this.props.tinode,downloadUrl:Zo.getDownloadUrl(e),filename:e.name,uploader:Zo.isUploading(e),mimetype:e.mime,size:Zo.getEntitySize(e),progress:this.state.progress,onCancelUpload:this.handleCancelUpload,onError:this.props.onError,key:t}))},this),i=Y.createElement("span",null,Zo.format(i,function(t,n,s){e+=1;var a=Zo.tagName(t);if(a){var i=Zo.attrValue(t,n)||{};if(i.key=e,"IM"==t){var r=El(n.width,n.height,Math.min(this.props.viewportWidth-4*ul,36*ul),24*ul,!1);i.className="inline-image",i.style=r?{width:r.dstWidth+"px",height:r.dstHeight+"px"}:null,i.onClick=this.handlePreviewImage}return Y.createElement(a,i,s)}return s},this))):"string"!=typeof i&&(i=Y.createElement("span",null,Y.createElement("i",{className:"material-icons"},"error_outline")," ",Y.createElement("i",null,"invalid content"))),Y.createElement("li",{className:t},this.props.userFrom&&this.props.response?Y.createElement("div",{className:"avatar-box"},a?Y.createElement(Wl,{topic:this.props.userFrom,title:this.props.userName,avatar:s}):null):null,Y.createElement("div",null,Y.createElement("div",{className:n},Y.createElement("div",{className:"message-content"},i,r,Y.createElement(yc,{timestamp:this.props.timestamp,received:this.props.received})),Y.createElement("span",{className:"menuTrigger"},Y.createElement("a",{href:"javascript:;",onClick:this.handleContextClick},Y.createElement("i",{className:"material-icons"},"expand_more")))),a?Y.createElement("div",{className:"author"},this.props.userName):null))}}class yc extends Y.PureComponent{render(){var e=this.props.received<=Yo.MESSAGE_STATUS_SENDING?"sending ...":bl(this.props.timestamp),t=null;return this.props.received<=Yo.MESSAGE_STATUS_SENDING?t=Y.createElement("i",{className:"material-icons small"},"access_time"):this.props.received==Yo.MESSAGE_STATUS_SENT?t=Y.createElement("i",{className:"material-icons small"},"done"):this.props.received==Yo.MESSAGE_STATUS_RECEIVED?t=Y.createElement("i",{className:"material-icons small"},"done_all"):this.props.received==Yo.MESSAGE_STATUS_READ&&(t=Y.createElement("i",{className:"material-icons small blue"},"done_all")),Y.createElement("span",{className:"timestamp"},e,"\xa0",t)}}class wc extends Y.PureComponent{render(){return Y.createElement("div",{className:"uploader"},Y.createElement("div",null,Y.createElement("span",{style:{width:100*this.props.progress+"%"}})),this.props.progress<.999?Y.createElement("a",{href:"javascript:;",onClick:this.props.onCancel},Y.createElement("i",{className:"material-icons"},"close")," cancel"):Y.createElement("span",null,"finishing..."))}}class Ec extends Y.Component{constructor(e){super(e),this.state={downloader:null,progress:0},this.downloadFile=this.downloadFile.bind(this),this.handleCancel=this.handleCancel.bind(this)}downloadFile(e,t,n){var s=this.props.tinode.getLargeFileHelper();this.setState({downloader:s}),s.download(e,t,n,e=>{this.setState({progress:e/this.props.size})}).then(()=>{this.setState({downloader:null,progress:0})}).catch(e=>{e&&this.props.onError("Error downloading file: "+e.message,"err"),this.setState({downloader:null,progress:0})})}handleCancel(){this.props.uploader?this.props.onCancelUpload():this.state.downloader&&this.state.downloader.cancel()}render(){let e=this.props.filename||"file_attachment";e.length>36&&(e=e.substr(0,16)+"..."+e.substr(-16));let t,n,s=this.props.size>0?Y.createElement("span",{className:"small gray"},"(",yl(this.props.size),")"):null;return this.props.uploader||this.state.downloader||/^(?:(?:[a-z]+:)?\/\/)/i.test(this.props.downloadUrl)?(t=this.props.downloadUrl,n=null):(t="javascript:;",n=(e=>{this.downloadFile(this.props.downloadUrl,this.props.filename,this.props.mimetype)})),Y.createElement("div",{className:"attachment"},Y.createElement("div",null,Y.createElement("i",{className:"material-icons big gray"},"insert_drive_file")),Y.createElement("div",{className:"flex-column"},Y.createElement("div",null,e," ",s),this.props.uploader||this.state.downloader?Y.createElement(wc,{progress:this.props.uploader?this.props.progress:this.state.progress,onCancel:this.handleCancel}):Y.createElement("div",null,Y.createElement("a",{href:t,download:this.props.filename,onClick:n},Y.createElement("i",{className:"material-icons"},"file_download")," save"))))}}const Sc="Not found";class Cc extends Y.Component{constructor(e){super(e),this.state={messages:[],onlineSubs:[],topic:"",title:"",avatar:null,scrollPosition:0,readOnly:!e.acs||!e.acs.isWriter(),writeOnly:!e.acs||!e.acs.isReader(),typingIndicator:!1,imagePreview:null},this.propsChange=this.propsChange.bind(this),this.leave=this.leave.bind(this),this.handleScrollReference=this.handleScrollReference.bind(this),this.fetchMoreMessages=this.fetchMoreMessages.bind(this),this.handleDescChange=this.handleDescChange.bind(this),this.handleSubsUpdated=this.handleSubsUpdated.bind(this),this.handleNewMessage=this.handleNewMessage.bind(this),this.handleAllMessagesReceived=this.handleAllMessagesReceived.bind(this),this.handleInfoReceipt=this.handleInfoReceipt.bind(this),this.handleImagePreview=this.handleImagePreview.bind(this),this.handleCloseImagePreview=this.handleCloseImagePreview.bind(this),this.handleContextClick=this.handleContextClick.bind(this),this.handleShowContextMenuMessage=this.handleShowContextMenuMessage.bind(this),this.handleBackNavigation=this.handleBackNavigation.bind(this)}componentDidUpdate(e,t){!this.messagesScroller||t.title==this.state.title&&t.messages.length==this.state.messages.length||(this.messagesScroller.scrollTop=this.messagesScroller.scrollHeight-this.state.scrollPosition)}componentDidMount(){this.propsChange(this.props),this.messagesScroller&&this.messagesScroller.addEventListener("scroll",this.fetchMoreMessages)}componentWillUnmount(){this.leave(),this.messagesScroller&&this.messagesScroller.removeEventListener("scroll",this.fetchMoreMessages)}UNSAFE_componentWillReceiveProps(e){this.propsChange(e)}propsChange(e){if(!e||!e.topic)return this.setState({messages:[],onlineSubs:[],topic:null}),void this.leave();if(!e.connected)return void this.setState({onlineSubs:[]});let t=this.props.tinode.getTopic(e.topic);if(!t)return;let n=Yo.isNewGroupTopicName(e.topic),s=!this.props.connected&&e.connected;if(e.topic!=this.state.topic){let n=[],a=[];t.onData=this.handleNewMessage,t.onAllMessagesReceived=this.handleAllMessagesReceived,t.onInfo=this.handleInfoReceipt,t.onMetaDesc=this.handleDescChange,t.onSubsUpdated=this.handleSubsUpdated,t.onPres=this.handleSubsUpdated,this.leave(),this.handleDescChange(t),t.subscribers(e=>{e.online&&e.user!=this.props.myUserId&&a.push(e)}),t.messages(function(e){e.deleted||(n=n.concat(e))}),this.setState({messages:n,onlineSubs:a,topic:e.topic,imagePreview:null,scrollPosition:0}),s=!0,this.props.readTimerHandler(null)}if(this.setState({readOnly:!e.acs||!e.acs.isWriter(),writeOnly:!e.acs||!e.acs.isReader()}),!t.isSubscribed()&&s){let s=t.startMetaQuery().withLaterDesc().withLaterSub().withLaterData(hl).withLaterDel(),a=n?e.newGroupTopicParams:void 0;this.setState({fetchingMessages:!0}),t.subscribe(s.build(),a).then(t=>{this.setState({topic:t.topic}),this.props.onNewTopicCreated(e.topic,t.topic)}).catch(e=>{this.props.onError(e.message,"err"),this.setState({title:Sc,avatar:null,readOnly:!0,writeOnly:!0,fetchingMessages:!1})})}}leave(){if(this.state.topic){let e=this.props.tinode.getTopic(this.state.topic);e&&e.isSubscribed()&&e.leave(!1).then(t=>{this.setState({fetchingMessages:!1}),e.onData=void 0,e.onAllMessagesReceived=void 0,e.onInfo=void 0,e.onMetaDesc=void 0,e.onSubsUpdated=void 0,e.onPres=void 0}).catch(e=>{console.log(e)})}}handleScrollReference(e){e&&(e.addEventListener("scroll",this.fetchMoreMessages),this.messagesScroller=e)}fetchMoreMessages(e){if(e.target.scrollTop<=0){let t={scrollPosition:e.target.scrollHeight-e.target.scrollTop};this.setState((e,n)=>{if(!e.fetchingMessages){var s=this.props.tinode.getTopic(this.state.topic);s&&s.isSubscribed()&&s.msgHasMoreMessages()&&(t.fetchingMessages=!0,s.getMessagesPage(hl).catch(e=>{this.setState({fetchingMessages:!1}),this.props.onError(e.message,"err")}))}return t})}}handleDescChange(e){e.public?this.setState({title:e.public.fn,avatar:wl(e.public.photo)}):this.setState({title:Sc,avatar:null}),e.acs&&this.setState({readOnly:!e.acs.isWriter(),writeOnly:!e.acs.isReader()})}handleSubsUpdated(){if(this.state.topic){var e=[];this.props.tinode.getTopic(this.state.topic).subscribers(t=>{t.online&&t.user!=this.props.myUserId&&e.push(t)}),this.setState({onlineSubs:e})}}handleNewMessage(e){var t=this.props.tinode.getTopic(this.state.topic),n={messages:[]};t.messages(function(e){e.deleted||(n.messages=n.messages.concat(e))}),e&&!e.deleted&&(t.isNewMessage(e.seq)&&(n.scrollPosition=0),t.msgStatus(e)>=Yo.MESSAGE_STATUS_SENT&&this.props.readTimerHandler(()=>{t.noteRead(e.seq)}),this.props.onData(e)),this.setState(n)}handleAllMessagesReceived(e){this.setState({fetchingMessages:!1})}handleInfoReceipt(e){switch(e.what){case"kp":clearTimeout(this.keyPressTimer);var t=this;this.keyPressTimer=setTimeout(function(){t.setState({typingIndicator:!1})},il+1e3),this.state.typingIndicator||this.setState({typingIndicator:!0});break;case"read":case"recv":this.forceUpdate();break;default:console.log("Other change in topic: ",e.what)}}handleImagePreview(e){this.setState({imagePreview:e})}handleCloseImagePreview(){this.setState({imagePreview:null})}handleContextClick(e){e.preventDefault(),e.stopPropagation(),this.props.showContextMenu({topicName:this.state.topic,y:e.pageY,x:e.pageX})}handleShowContextMenuMessage(e){e.topicName=this.state.topic;var t=["message_delete"],n=this.props.tinode.getTopic(e.topicName);if(n){var s=n.getAccessMode();s&&s.isDeleter()&&t.push("message_delete_hard")}this.props.showContextMenu(e,t)}handleBackNavigation(){this.props.onHideMessagesView()}render(){var e=null;if(this.state.topic){for(var t=[],n=this.props.tinode.getTopic(this.state.topic),s="grp"==n.getType(),a=null,i=0;ipl||gl.indexOf(o.type)<0?_l(o,fl,fl,!1,t,s):kl(o,t,s):xl(o,n),!0}}return!1}(e,(e,t,n,s,a)=>{this.props.sendMessage(Zo.insertImage(null,0,t,e,n,s,a))},(e,t,n)=>{this.props.sendMessage(Zo.attachFile(null,e,t,n))},this.props.onError)&&e.preventDefault()}handleAttachImage(e){if(e.target.files&&e.target.files.length>0){let t=e.target.files[0];t.size>pl||gl.indexOf(t.type)<0?_l(t,fl,fl,!1,(e,t,n,s,a)=>{this.props.sendMessage(Zo.insertImage(null,0,t,e,n,s,a))},e=>{this.props.onError(e,"err")}):kl(t,(e,t,n,s,a)=>{this.props.sendMessage(Zo.insertImage(null,0,t,e,n,s,a))},e=>{this.props.onError(e,"err")})}e.target.value=""}handleAttachFile(e){if(e.target.files&&e.target.files.length>0){var t=e.target.files[0];if(t.size>ml)this.props.onError("The file size "+yl(t.size)+" exceeds the "+yl(ml)+" limit.","err");else if(t.size>pl){let e=this.props.tinode.getLargeFileHelper();if(!e)return void this.props.onError("Cannot initiate file upload.");let n=e.upload(t),s=Zo.attachFile(null,t.type,null,t.name,t.size,n);this.props.sendMessage(s,n,e)}else xl(t,(e,t,n)=>{this.props.sendMessage(Zo.attachFile(null,e,t,n))},this.props.onError)}e.target.value=""}handleSend(){this.state.message.trim()&&(this.props.sendMessage(this.state.message.trim()),this.setState({message:""}))}handleKeyPress(e){"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),e.stopPropagation(),this.handleSend()))}handleMessageTyping(e){var t={message:e.target.value},n=(new Date).getTime();if(n-this.state.keypressTimestamp>il){var s=this.props.tinode.getTopic(this.props.topic);s.isSubscribed()&&s.noteKeyPress(),t.keypressTimestamp=n}this.setState(t)}render(){var e=this.props.disabled?"Messaging disabled":"New message",t=this;return Y.createElement("div",{id:"send-message-panel"},this.props.disabled?Y.createElement("i",{className:"material-icons disabled"},"photo"):Y.createElement("a",{href:"javascript:;",onClick:function(e){t.attachImage.click()},title:"Add image"},Y.createElement("i",{className:"material-icons secondary"},"photo")),this.props.disabled?Y.createElement("i",{className:"material-icons disabled"},"attach_file"):Y.createElement("a",{href:"javascript:;",onClick:function(e){t.attachFile.click()},title:"Attach file"},Y.createElement("i",{className:"material-icons secondary"},"attach_file")),Y.createElement("textarea",{id:"sendMessage",placeholder:e,disabled:this.props.disabled,value:this.state.message,onChange:this.handleMessageTyping,onKeyPress:this.handleKeyPress,ref:function(e){t.pasteFile=e},autoFocus:!0}),this.props.disabled?Y.createElement("i",{className:"material-icons disabled"},"send"):Y.createElement("a",{href:"javascript:;",onClick:this.handleSend,title:"Send"},Y.createElement("i",{className:"material-icons"},"send")),Y.createElement("input",{type:"file",ref:function(e){t.attachFile=e},onChange:this.handleAttachFile,style:{display:"none"}}),Y.createElement("input",{type:"file",ref:function(e){t.attachImage=e},accept:"image/*",onChange:this.handleAttachImage,style:{display:"none"}}))}}class _c extends Y.PureComponent{render(){var e=Yo.getVersion()+" build "+document.lastModified;return Y.createElement("div",{id:"dummy-view",className:this.props.hideSelf?"nodisplay":null},Y.createElement("div",null,Y.createElement("a",{href:"https://github.com/tinode/chat/"},Y.createElement("img",{id:"logo",alt:"logo",src:"img/logo.svg"}),Y.createElement("h2",null,"Tinode Demo Chat")),Y.createElement("p",null,"Client: ",e),Y.createElement("p",null,"Server: ",this.props.serverVersion," (",this.props.serverAddress,")")))}}class kc extends Y.PureComponent{constructor(e){super(e),this.state={}}componentDidMount(){this.setState({width:this.container.clientWidth,height:this.container.clientHeight})}render(){if(!this.props.content)return null;var e=this,t=El(this.props.content.width,this.props.content.height,this.state.width,this.state.height,!1),n=t?{width:t.dstWidth+"px",height:t.dstHeight+"px"}:this.props.content.width>this.props.content.height?{width:"100%"}:{height:"100%"};n.maxWidth="100%",n.maxHeight="100%";var s=this.props.content.filename,a=this.props.content.width/ul|0;return s.length>a&&(s=s.slice(0,a-2)+"..."+s.slice(2-a)),Y.createElement("div",{id:"image-preview",onClick:this.props.onClose},Y.createElement("div",{id:"image-preview-caption-panel"},Y.createElement("a",{href:"javascript:;",download:this.props.content.filename},Y.createElement("i",{className:"material-icons"},"file_download")," download"),Y.createElement("a",{href:"javascript:;",onClick:this.props.onClose},Y.createElement("i",{className:"material-icons gray"},"close"))),Y.createElement("div",{id:"image-preview-container",ref:function(t){e.container=t}},Y.createElement("img",{src:this.props.content.url,style:n})),Y.createElement("div",{id:"image-preview-footer"},Y.createElement("div",null,Y.createElement("div",null,Y.createElement("b",null,"File name"),":"),Y.createElement("div",null,Y.createElement("span",{title:this.props.content.filename},s))),Y.createElement("div",null,Y.createElement("div",null,Y.createElement("b",null,"Content type"),":"),Y.createElement("div",null,this.props.content.type)),Y.createElement("div",null,Y.createElement("div",null,Y.createElement("b",null,"Size"),":"),Y.createElement("div",null,this.props.content.width," \xd7 ",this.props.content.height," px; ",yl(this.props.content.size)))))}}class xc extends Y.Component{constructor(e){super(e),this.state=this.getBlankState(),this.handleResize=this.handleResize.bind(this),this.handleHashRoute=this.handleHashRoute.bind(this),this.handleOnline=this.handleOnline.bind(this),this.handleAppVisibility=this.handleAppVisibility.bind(this),this.handleReadTimer=this.handleReadTimer.bind(this),this.handleVisibilityEvent=this.handleVisibilityEvent.bind(this),this.handleError=this.handleError.bind(this),this.handleLoginRequest=this.handleLoginRequest.bind(this),this.handleConnected=this.handleConnected.bind(this),this.doLogin=this.doLogin.bind(this),this.handleCredentialsRequest=this.handleCredentialsRequest.bind(this),this.handleLoginSuccessful=this.handleLoginSuccessful.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.tnMeMetaDesc=this.tnMeMetaDesc.bind(this),this.tnMeContactUpdate=this.tnMeContactUpdate.bind(this),this.tnMeSubsUpdated=this.tnMeSubsUpdated.bind(this),this.resetContactList=this.resetContactList.bind(this),this.tnData=this.tnData.bind(this),this.tnInitFind=this.tnInitFind.bind(this),this.tnFndSubsUpdated=this.tnFndSubsUpdated.bind(this),this.handleSearchContacts=this.handleSearchContacts.bind(this),this.handleTopicSelected=this.handleTopicSelected.bind(this),this.handleHideMessagesView=this.handleHideMessagesView.bind(this),this.handleSendMessage=this.handleSendMessage.bind(this),this.handleNewAccount=this.handleNewAccount.bind(this),this.handleNewAccountRequest=this.handleNewAccountRequest.bind(this),this.handleUpdateAccountRequest=this.handleUpdateAccountRequest.bind(this),this.handleUpdateAccountTagsRequest=this.handleUpdateAccountTagsRequest.bind(this),this.handleSettings=this.handleSettings.bind(this),this.handleGlobalSettings=this.handleGlobalSettings.bind(this),this.handleSidepanelCancel=this.handleSidepanelCancel.bind(this),this.handleNewTopic=this.handleNewTopic.bind(this),this.handleNewTopicRequest=this.handleNewTopicRequest.bind(this),this.handleNewTopicCreated=this.handleNewTopicCreated.bind(this),this.handleTopicUpdateRequest=this.handleTopicUpdateRequest.bind(this),this.handleChangePermissions=this.handleChangePermissions.bind(this),this.handleTagsUpdated=this.handleTagsUpdated.bind(this),this.handleLogout=this.handleLogout.bind(this),this.handleLeaveUnsubRequest=this.handleLeaveUnsubRequest.bind(this),this.handleDialogCancel=this.handleDialogCancel.bind(this),this.handleShowContextMenu=this.handleShowContextMenu.bind(this),this.defaultTopicContextMenu=this.defaultTopicContextMenu.bind(this),this.handleHideContextMenu=this.handleHideContextMenu.bind(this),this.handleShowInfoView=this.handleShowInfoView.bind(this),this.handleHideInfoView=this.handleHideInfoView.bind(this),this.handleMemberUpdateRequest=this.handleMemberUpdateRequest.bind(this),this.handleValidateCredentialsRequest=this.handleValidateCredentialsRequest.bind(this)}getBlankState(){let e=localStorage.getObject("settings")||{};return{tinode:null,connected:!1,transport:e.transport||null,serverAddress:e.serverAddress||function(){let e=nl;return"object"==typeof window.location&&("file:"==window.location.protocol||"localhost"==window.location.hostname?e=tl.local:window.location.hostname&&(e=window.location.hostname+(window.location.port?":"+window.location.port:""))),e}(),serverVersion:"no connection",messageSounds:!e.messageSoundsOff,desktopAlerts:e.desktopAlerts,desktopAlertsEnabled:Rl(),errorText:"",errorLevel:null,sidePanelSelected:"login",sidePanelTitle:null,sidePanelAvatar:null,dialogSelected:null,contextMenuVisible:!1,login:"",password:"",myUserId:null,liveConnection:navigator.onLine,topicSelected:"",topicSelectedOnline:!1,topicSelectedAcs:null,newGroupTopicParams:null,loginDisabled:!1,displayMobile:window.innerWidth<=cl,showInfoPanel:!1,mobilePanel:"sidepanel",contextMenuVisible:!1,contextMenuBounds:null,contextMenuClickAt:null,contextMenuParams:null,contextMenuItems:[],contactsSearchQuery:"",chatList:[],searchResults:[],searchableContacts:[],credMethod:void 0,credCode:void 0}}componentDidMount(){window.addEventListener("resize",this.handleResize),window.addEventListener("online",e=>{this.handleOnline(!0)}),window.addEventListener("offline",e=>{this.handleOnline(!1)}),window.addEventListener("hashchange",this.handleHashRoute),document.addEventListener("visibilitychange",this.handleVisibilityEvent),this.setState({viewportWidth:document.documentElement.clientWidth});let e=xc.tnSetup(this.state.serverAddress,this.state.transport);var t;if(this.setState({tinode:e}),e.enableLogging(!0,!0),e.onConnect=this.handleConnected,e.onDisconnect=this.handleDisconnect,localStorage.getObject("keep-logged-in")&&(t=localStorage.getObject("auth-token")),t){t.expires=new Date(t.expires),e.setAuthToken(t),e.connect().catch(e=>{this.handleError(e.message,"err")});var n=Ml(window.location.hash);delete n.params.info,delete n.params.tab,n.path[0]="",Nl(Pl(n.path,n.params))}else Nl("");this.readTimer=null,this.readTimerCallback=null,this.handleHashRoute()}componentWillUnmount(){window.removeEventListener("resize",this.handleResize),window.removeEventListener("hashchange",this.handleHashRoute),document.removeEventListener("visibilitychange",this.handleVisibilityEvent)}static tnSetup(e,t){return new Yo(el,e,al,t,Rl())}handleResize(){var e=document.documentElement.clientWidth<=cl;this.setState({viewportWidth:document.documentElement.clientWidth}),this.state.displayMobile!=e&&this.setState({displayMobile:e})}handleHashRoute(){var e=Ml(window.location.hash);e.path&&e.path.length>0?(["register","settings","edit","cred","newtpk","contacts",""].includes(e.path[0])?this.setState({sidePanelSelected:e.path[0]}):console.log("Unknown sidepanel view",e.path[0]),e.path.length>1&&e.path[1]!=this.state.topicSelected&&this.setState({topicSelected:Yo.topicType(e.path[1])?e.path[1]:null})):this.setState({sidePanelSelected:""}),e.params.method&&this.setState({credMethod:e.params.method}),e.params.code&&this.setState({credCode:e.params.code}),this.setState({showInfoPanel:e.params.info,newTopicTabSelected:e.params.tab})}handleOnline(e){e?this.handleError("",null):this.handleError("No connection","warn"),this.setState({liveConnection:e})}handleAppVisibility(e,t){clearTimeout(this.readTimer),this.readTimerCallback=t,this.readTimer=e&&t?setTimeout(t,ol):null}handleReadTimer(e){this.handleAppVisibility(!document.hidden,e)}handleVisibilityEvent(){this.handleAppVisibility(!document.hidden,this.readTimerCallback)}handleError(e,t){this.setState({errorText:e,errorLevel:t})}handleLoginRequest(e,t){this.setState({loginDisabled:!0,login:e,password:t}),this.handleError("",null),this.state.tinode.isConnected()?this.doLogin(e,t,{meth:this.state.credMethod,resp:this.state.credCode}):this.state.tinode.connect().catch(e=>{this.setState({loginDisabled:!1}),this.handleError(e.message,"err")})}handleConnected(){var e=this.state.tinode.getServerInfo();this.setState({serverVersion:e.ver+" "+(e.build?e.build:"none")+"; "}),this.doLogin(this.state.login,this.state.password,{meth:this.state.credMethod,resp:this.state.credCode})}doLogin(e,t,n){if(this.state.tinode.isAuthenticated())return void Nl("");n=Yo.credential(n);let s=null,a=this.state.tinode.getAuthToken();e&&t?(this.setState({password:null}),s=this.state.tinode.loginBasic(e,t,n)):a&&(s=this.state.tinode.loginToken(a.token,n)),s?s.then(e=>{e.code>=300&&"validate credentials"===e.text?(n&&this.handleError("Code does not match","warn"),this.handleCredentialsRequest(e.params)):this.handleLoginSuccessful()}).catch(e=>{this.setState({loginDisabled:!1,credMethod:void 0,credCode:void 0}),this.handleError(e.message,"err"),localStorage.removeItem("auth-token"),Nl("")}):(Nl(""),this.setState({loginDisabled:!1}))}handleCredentialsRequest(e){var t=Ml(window.location.hash);t.path[0]="cred",t.params.method=e.cred[0],Nl(Pl(t.path,t.params))}handleLoginSuccessful(){this.handleError("",null),localStorage.getObject("keep-logged-in")&&localStorage.setObject("auth-token",this.state.tinode.getAuthToken());var e=this.state.tinode.getMeTopic();e.onMetaDesc=this.tnMeMetaDesc,e.onContactUpdate=this.tnMeContactUpdate,e.onSubsUpdated=this.tnMeSubsUpdated,this.setState({connected:!0,credMethod:void 0,credCode:void 0,myUserId:this.state.tinode.getCurrentUserID()}),e.subscribe(e.startMetaQuery().withLaterSub().withDesc().build()).catch(e=>{localStorage.removeItem("auth-token"),this.handleError(e.message,"err"),Nl("")}),Nl(Al(window.location.hash,"contacts"))}handleDisconnect(e){this.setState({connected:!1,topicSelectedOnline:!1,dialogSelected:null,errorText:e&&e.message?e.message:"Disconnected",errorLevel:e&&e.message?"err":"warn",loginDisabled:!1,contextMenuVisible:!1,serverVersion:"no connection"})}tnMeMetaDesc(e){e&&e.public&&this.setState({sidePanelTitle:e.public.fn,sidePanelAvatar:wl(e.public.photo)})}tnMeContactUpdate(e,t){"on"==e||"off"==e?(this.resetContactList(),this.state.topicSelected==t.topic&&this.setState({topicSelectedOnline:"on"===e})):"read"==e?this.resetContactList():"msg"==e?this.state.topicSelected!=t.topic?(this.state.messageSounds&&sl.play(),this.resetContactList()):document.hidden&&this.state.messageSounds&&sl.play():"recv"==e||("gone"==e||"unsub"==e?(this.state.topicSelected==t.topic&&this.handleTopicSelected(null),this.resetContactList()):"acs"==e?this.state.topicSelected==t.topic&&this.setState({topicSelectedAcs:t.acs}):"del"==e||console.log("Unsupported (yet) presence update:"+e+" in: "+t.topic))}tnMeSubsUpdated(e){this.resetContactList()}static prepareSearchableContacts(e,t){let n={};for(const s of e)"p2p"==Yo.topicType(s.topic)&&(n[s.topic]={user:s.topic,updated:s.updated,public:s.public,private:s.private,acs:s.acs});for(const s of t)n[s.user]||(n[s.user]=s);return Object.values(n)}resetContactList(){let e={chatList:[]};this.state.tinode.getMeTopic().contacts(t=>{e.chatList.push(t),this.state.topicSelected==t.topic&&(e.topicSelectedOnline=t.online,e.topicSelectedAcs=t.acs)}),e.searchableContacts=xc.prepareSearchableContacts(e.chatList,this.state.searchResults),this.setState(e)}tnData(e){let t=this.state.tinode.getTopic(e.topic);t.msgStatus(e)>Yo.MESSAGE_STATUS_SENDING&&(clearTimeout(this.receivedTimer),this.receivedTimer=setTimeout(()=>{this.receivedTimer=void 0,t.noteRecv(e.seq)},rl))}tnInitFind(){let e=this.state.tinode.getFndTopic();e.isSubscribed()?(this.setState({contactsSearchQuery:""}),this.tnFndSubsUpdated()):(e.onSubsUpdated=this.tnFndSubsUpdated,e.subscribe(e.startMetaQuery().withSub().withTags().build()).catch(e=>{this.handleError(e.message,"err")}))}tnFndSubsUpdated(){let e=[];this.state.tinode.getFndTopic().contacts(t=>{e.push(t)}),this.setState({searchResults:e,searchableContacts:xc.prepareSearchableContacts(this.state.chatList,e)})}handleSearchContacts(e){var t=this.state.tinode.getFndTopic();this.setState({contactsSearchQuery:e==Yo.DEL_CHAR?"":e}),t.setMeta({desc:{public:e}}).then(e=>t.getMeta(t.startMetaQuery().withSub().build())).catch(e=>{this.handleError(e.message,"err")})}handleTopicSelected(e,t,n,s){e?(this.setState({errorText:"",errorLevel:null,mobilePanel:"topic-view",topicSelectedOnline:n,topicSelectedAcs:s,showInfoPanel:!1}),this.state.topicSelected!=e&&Nl(Il("",e))):(this.setState({errorText:"",errorLevel:null,mobilePanel:"sidepanel",topicSelectedOnline:!1,topicSelectedAcs:null,showInfoPanel:!1}),this.state.topicSelected&&Nl(Il("",null)))}handleHideMessagesView(){this.setState({mobilePanel:"sidepanel"}),Nl(Il(window.location.hash,null))}handleSendMessage(e,t,n){let s=this.state.tinode.getTopic(this.state.topicSelected);(e=s.createMessage(e,!1))._uploader=n,s.isSubscribed()||(t||(t=Promise.resolve()),t=t.then(()=>s.subscribe())),t&&(t=t.catch(e=>{this.handleError(e.message,"err")})),s.publishDraft(e,t).catch(e=>{this.handleError(e.message,"err")})}handleNewAccount(){Nl(Al(window.location.hash,"register"))}handleNewAccountRequest(e,t,n,s,a){this.state.tinode.connect(this.state.serverAddress).then(()=>this.state.tinode.createAccountBasic(e,t,{public:n,tags:a,cred:Yo.credential(s)})).then(e=>{e.code>=300&&"validate credentials"===e.text?this.handleCredentialsRequest(e.params):this.handleLoginSuccessful(this)}).catch(e=>{this.handleError(e.message,"err")})}handleUpdateAccountRequest(e,t,n){(t||n)&&this.state.tinode.getMeTopic().setMeta({desc:{public:t,private:n}}).catch(e=>{this.handleError(e.message,"err")}),e&&this.state.tinode.updateAccountBasic(null,this.state.tinode.getCurrentLogin(),e).catch(e=>{this.handleError(e.message,"err")})}handleUpdateAccountTagsRequest(e){this.state.tinode.getFndTopic().setMeta({tags:e}).catch(e=>{this.handleError(e.message,"err")})}handleSettings(){Nl(Al(window.location.hash,this.state.myUserId?"edit":"settings"))}handleGlobalSettings(e){let t=e.serverAddress||this.state.serverAddress,n=e.transport||this.state.transport,s="boolean"==typeof e.messageSounds?e.messageSounds:this.state.messageSounds,a=e.desktopAlerts||this.state.desktopAlerts;this.setState({serverAddress:t,transport:n,messageSounds:s,desktopAlerts:a,tinode:xc.tnSetup(t,n)}),localStorage.setObject({serverAddress:t,messageSoundsOff:!s,transport:this.state.transport,desktopAlerts:a}),Nl(Al(window.location.hash,""))}handleSidepanelCancel(){var e=Ml(window.location.hash);e.path[0]=this.state.myUserId?"contacts":"",e.params&&(delete e.params.code,delete e.params.method,delete e.params.tab),Nl(Pl(e.path,e.params)),this.setState({errorText:"",errorLevel:null})}handleNewTopic(){Nl(Al(window.location.hash,"newtpk"))}handleNewTopicRequest(e,t,n,s){var a=e||this.state.tinode.newGroupTopicName();e?this.handleTopicSelected(a):this.setState({newGroupTopicParams:{desc:{public:t,private:n},tags:s}},()=>{this.handleTopicSelected(a)})}handleNewTopicCreated(e,t){console.log("handleNewTopicCreated",e,t),this.state.topicSelected==e&&e!=t&&this.setState({topicSelected:t},()=>{Nl(Il("",t))})}handleTopicUpdateRequest(e,t,n,s){var a=this.state.tinode.getTopic(e);if(a){var i={};t&&(i.public=t),n&&(i.private={comment:n}),s&&(i.defacs=s),a.setMeta({desc:i}).catch(e=>{this.handleError(e.message,"err")})}}handleChangePermissions(e,t,n){var s=this.state.tinode.getTopic(e);if(s){var a=s.getAccessMode();n?(a.updateGiven(t),t=a.getGiven()):(a.updateWant(t),t=a.getWant()),s.setMeta({sub:{user:n,mode:t}}).catch(e=>{this.handleError(e.message,"err")})}}handleTagsUpdated(e,t){var n=this.state.tinode.getTopic(e);n&&n.setMeta({tags:t}).catch(e=>{this.handleError(e.message,"err")})}handleLogout(){localStorage.removeItem("auth-token"),this.setState(this.getBlankState()),this.setState({tinode:xc.tnSetup(this.state.serverAddress,this.state.transport)}),Nl("")}handleLeaveUnsubRequest(e){var t=this.state.tinode.getTopic(e);t&&t.leave(!0).then(e=>{Nl(Il(window.location.hash,""))}).catch(e=>{this.handleError(e.message,"err")})}handleDialogCancel(){this.setState({dialogSelected:null})}handleShowContextMenu(e,t){this.setState({contextMenuVisible:!0,contextMenuClickAt:{x:e.x,y:e.y},contextMenuParams:e,contextMenuItems:t||this.defaultTopicContextMenu(e.topicName),contextMenuBounds:ReactDOM.findDOMNode(this).getBoundingClientRect()})}defaultTopicContextMenu(e){var t=!1,n=!1,s=!1,a=!1,i=this.state.tinode.getTopic(e);if(i&&i.isSubscribed()){s=!0;var r=i.getAccessMode();t=r&&r.isMuted(),n=r&&!r.isJoiner(),a=r&&r.isDeleter()}return[s?{title:"Info",handler:this.handleShowInfoView}:null,s?"messages_clear":null,s&&a?"messages_clear_hard":null,s?t?"topic_unmute":"topic_mute":null,s?n?"topic_unblock":"topic_block":null,"topic_delete"]}handleHideContextMenu(){this.setState({contextMenuVisible:!1,contextMenuClickAt:null,contextMenuParams:null,contextMenuBounds:null})}handleShowInfoView(){Nl(Ul(window.location.hash,"info",!0)),this.setState({showInfoPanel:!0})}handleHideInfoView(){Nl(Dl(window.location.hash,"info")),this.setState({showInfoPanel:!1})}handleMemberUpdateRequest(e,t,n){if(e){var s=this.state.tinode.getTopic(e);s&&(t&&t.length>0&&t.map(e=>{s.invite(e,null).catch(e=>{this.handleError(e.message,"err")})}),n&&n.length>0&&n.map(e=>{s.delSubscription(e).catch(e=>{this.handleError(e.message,"err")})}))}}handleValidateCredentialsRequest(e,t){this.setState({credMethod:e,credCode:t}),this.doLogin(null,null,{meth:e,resp:t})}render(){return Y.createElement("div",{id:"app-container"},this.state.contextMenuVisible?Y.createElement(Fl,{tinode:this.state.tinode,bounds:this.state.contextMenuBounds,clickAt:this.state.contextMenuClickAt,params:this.state.contextMenuParams,items:this.state.contextMenuItems,hide:this.handleHideContextMenu,onAction:this.handleContextMenuAction,onError:this.handleError}):null,Y.createElement(sc,{tinode:this.state.tinode,connected:this.state.connected,displayMobile:this.state.displayMobile,hideSelf:this.state.displayMobile&&"sidepanel"!==this.state.mobilePanel,state:this.state.sidePanelSelected,title:this.state.sidePanelTitle,avatar:this.state.sidePanelAvatar,login:this.state.login,myUserId:this.state.myUserId,loginDisabled:this.state.loginDisabled,errorText:this.state.errorText,errorLevel:this.state.errorLevel,topicSelected:this.state.topicSelected,chatList:this.state.chatList,credMethod:this.state.credMethod,credCode:this.state.credCode,transport:this.state.transport,messageSounds:this.state.messageSounds,desktopAlerts:this.state.desktopAlerts,desktopAlertsEnabled:this.state.desktopAlertsEnabled,serverAddress:this.state.serverAddress,onGlobalSettings:this.handleGlobalSettings,onSignUp:this.handleNewAccount,onSettings:this.handleSettings,onLoginRequest:this.handleLoginRequest,onCreateAccount:this.handleNewAccountRequest,onUpdateAccount:this.handleUpdateAccountRequest,onUpdateAccountTags:this.handleUpdateAccountTagsRequest,onTopicSelected:this.handleTopicSelected,onCreateTopic:this.handleNewTopicRequest,onNewTopic:this.handleNewTopic,onLogout:this.handleLogout,onCancel:this.handleSidepanelCancel,onError:this.handleError,onValidateCredentials:this.handleValidateCredentialsRequest,onInitFind:this.tnInitFind,contactsSearchQuery:this.state.contactsSearchQuery,searchResults:this.state.searchResults,onSearchContacts:this.handleSearchContacts,showContextMenu:this.handleShowContextMenu}),Y.createElement(Cc,{tinode:this.state.tinode,connected:this.state.connected,online:this.state.topicSelectedOnline,acs:this.state.topicSelectedAcs,displayMobile:this.state.displayMobile,viewportWidth:this.state.viewportWidth,hideSelf:this.state.displayMobile&&("topic-view"!==this.state.mobilePanel||this.state.showInfoPanel),topic:this.state.topicSelected,myUserId:this.state.myUserId,serverVersion:this.state.serverVersion,serverAddress:this.state.serverAddress,errorText:this.state.errorText,errorLevel:this.state.errorLevel,newGroupTopicParams:this.state.newGroupTopicParams,onHideMessagesView:this.handleHideMessagesView,onData:this.tnData,onError:this.handleError,onNewTopicCreated:this.handleNewTopicCreated,readTimerHandler:this.handleReadTimer,showContextMenu:this.handleShowContextMenu,sendMessage:this.handleSendMessage}),this.state.showInfoPanel?Y.createElement(vc,{tinode:this.state.tinode,connected:this.state.connected,displayMobile:this.state.displayMobile,topic:this.state.topicSelected,searchableContacts:this.state.searchableContacts,myUserId:this.state.myUserId,errorText:this.state.errorText,errorLevel:this.state.errorLevel,onTopicDescUpdate:this.handleTopicUpdateRequest,onCancel:this.handleHideInfoView,onChangePermissions:this.handleChangePermissions,onMemberUpdateRequest:this.handleMemberUpdateRequest,onLeaveTopic:this.handleLeaveUnsubRequest,onAddMember:this.handleManageGroupMembers,onTopicTagsUpdate:this.handleTagsUpdated,onInitFind:this.tnInitFind,onError:this.handleError,showContextMenu:this.handleShowContextMenu}):null)}}var Mc=xc;Xo.render(Y.createElement(Mc,null),document.getElementById("mountPoint"))});
\ No newline at end of file
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Webapp=e()}}(function(){return function(){return function e(t,n,r){function a(o,s){if(!n[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){return a(t[o][1][e]||e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o2?n-2:0),a=2;a1?t-1:0),r=1;r-1||n(!1,"EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.",e),!T[r]){t.extractEvents||n(!1,"EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.",e),T[r]=t;var a=t.eventTypes;for(var i in a)S(a[i],t,i)||n(!1,"EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.",i,e)}}}function S(e,t,r){x.hasOwnProperty(r)&&n(!1,"EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.",r),x[r]=e;var a=e.phasedRegistrationNames;if(a){for(var i in a){if(a.hasOwnProperty(i))k(a[i],t,r)}return!0}return!!e.registrationName&&(k(e.registrationName,t,r),!0)}function k(e,t,r){_[e]&&n(!1,"EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.",e),_[e]=t,P[e]=t.eventTypes[r].dependencies;var a=e.toLowerCase();N[a]=e,"onDoubleClick"===e&&(N.ondblclick=e)}var T=[],x={},_={},P={},N={};function M(e){w&&n(!1,"EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."),w=Array.prototype.slice.call(e),C()}function R(e){var t=!1;for(var r in e)if(e.hasOwnProperty(r)){var a=e[r];E.hasOwnProperty(r)&&E[r]===a||(E[r]&&n(!1,"EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.",r),E[r]=a,t=!0)}t&&C()}var U=Object.freeze({plugins:T,eventNameDispatchConfigs:x,registrationNameModules:_,registrationNameDependencies:P,possibleRegistrationNames:N,injectEventPluginOrder:M,injectEventPluginsByName:R}),D=null,I=null,A=null,O=function(e){D=e.getFiberCurrentPropsFromNode,I=e.getInstanceFromNode,(A=e.getNodeFromInstance)&&I||a(!1,"EventPluginUtils.injection.injectComponentTree(...): Injected module is missing getNodeFromInstance or getInstanceFromNode.")},F=void 0;function L(e,t,n,r){var a=e.type||"unknown-event";e.currentTarget=A(r),b.invokeGuardedCallbackAndCatchFirstError(a,n,void 0,e),e.currentTarget=null}function j(e,t){return null==t&&n(!1,"accumulateInto(...): Accumulated items must not be null or undefined."),null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}function z(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}F=function(e){var t=e._dispatchListeners,n=e._dispatchInstances,r=Array.isArray(t),i=r?t.length:t?1:0,o=Array.isArray(n),s=o?n.length:n?1:0;(o!==r||s!==i)&&a(!1,"EventPluginUtils: Invalid `event`.")};var W=null,q=function(e,t){e&&(!function(e,t){var n=e._dispatchListeners,r=e._dispatchInstances;if(F(e),Array.isArray(n))for(var a=0;a0;)t(r[a],"captured",n);for(a=0;a0;)e=we(e),n--;for(;a-n>0;)t=we(t),a--;for(var o=n;o--;){if(e===t||e===t.alternate)return e;e=we(e),t=we(t)}return null}(e,t):null,o=[];e&&e!==i;){var s=e.alternate;if(null!==s&&s===i)break;o.push(e),e=we(e)}for(var l=[];t&&t!==i;){var c=t.alternate;if(null!==c&&c===i)break;l.push(t),t=we(t)}for(var u=0;u0;)n(l[d],"captured",a)}function Se(e,t,n){e||a(!1,"Dispatching inst must not be null");var r=function(e,t,n){return G(e,t.dispatchConfig.phasedRegistrationNames[n])}(e,n,t);r&&(n._dispatchListeners=j(n._dispatchListeners,r),n._dispatchInstances=j(n._dispatchInstances,e))}function ke(e){e&&e.dispatchConfig.phasedRegistrationNames&&Ee(e._targetInst,Se,e)}function Te(e){if(e&&e.dispatchConfig.phasedRegistrationNames){var t=e._targetInst;Ee(t?we(t):null,Se,e)}}function xe(e,t,n){if(e&&n&&n.dispatchConfig.registrationName){var r=G(e,n.dispatchConfig.registrationName);r&&(n._dispatchListeners=j(n._dispatchListeners,r),n._dispatchInstances=j(n._dispatchInstances,e))}}function _e(e){e&&e.dispatchConfig.registrationName&&xe(e._targetInst,0,e)}function Pe(e){z(e,ke)}function Ne(e,t,n,r){Ce(n,r,xe,e,t)}var Me=Object.freeze({accumulateTwoPhaseDispatches:Pe,accumulateTwoPhaseDispatchesSkipTarget:function(e){z(e,Te)},accumulateEnterLeaveDispatches:Ne,accumulateDirectDispatches:function(e){z(e,_e)}});function Re(e){return e}function Ue(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n["ms"+e]="MS"+t,n["O"+e]="o"+t.toLowerCase(),n}var De={animationend:Ue("Animation","AnimationEnd"),animationiteration:Ue("Animation","AnimationIteration"),animationstart:Ue("Animation","AnimationStart"),transitionend:Ue("Transition","TransitionEnd")},Ie={},Ae={};function Oe(e){if(Ie[e])return Ie[e];if(!De[e])return e;var t=De[e];for(var n in t)if(t.hasOwnProperty(n)&&n in Ae)return Ie[e]=t[n];return e}i.canUseDOM&&(Ae=document.createElement("div").style,"AnimationEvent"in window||(delete De.animationend.animation,delete De.animationiteration.animation,delete De.animationstart.animation),"TransitionEvent"in window||delete De.transitionend.transition);var Fe=Re("abort"),Le=Re(Oe("animationend")),je=Re(Oe("animationiteration")),ze=Re(Oe("animationstart")),We=Re("blur"),qe=Re("canplay"),Ve=Re("canplaythrough"),Be=Re("cancel"),He=Re("change"),Ge=Re("click"),Ke=Re("close"),$e=Re("compositionend"),Qe=Re("compositionstart"),Ye=Re("compositionupdate"),Xe=Re("contextmenu"),Je=Re("copy"),Ze=Re("cut"),et=Re("dblclick"),tt=Re("drag"),nt=Re("dragend"),rt=Re("dragenter"),at=Re("dragexit"),it=Re("dragleave"),ot=Re("dragover"),st=Re("dragstart"),lt=Re("drop"),ct=Re("durationchange"),ut=Re("emptied"),dt=Re("encrypted"),pt=Re("ended"),ht=Re("error"),ft=Re("focus"),mt=Re("gotpointercapture"),gt=Re("input"),vt=Re("invalid"),bt=Re("keydown"),yt=Re("keypress"),wt=Re("keyup"),Et=Re("load"),Ct=Re("loadstart"),St=Re("loadeddata"),kt=Re("loadedmetadata"),Tt=Re("lostpointercapture"),xt=Re("mousedown"),_t=Re("mousemove"),Pt=Re("mouseout"),Nt=Re("mouseover"),Mt=Re("mouseup"),Rt=Re("paste"),Ut=Re("pause"),Dt=Re("play"),It=Re("playing"),At=Re("pointercancel"),Ot=Re("pointerdown"),Ft=Re("pointermove"),Lt=Re("pointerout"),jt=Re("pointerover"),zt=Re("pointerup"),Wt=Re("progress"),qt=Re("ratechange"),Vt=Re("reset"),Bt=Re("scroll"),Ht=Re("seeked"),Gt=Re("seeking"),Kt=Re("selectionchange"),$t=Re("stalled"),Qt=Re("submit"),Yt=Re("suspend"),Xt=Re("textInput"),Jt=Re("timeupdate"),Zt=Re("toggle"),en=Re("touchcancel"),tn=Re("touchend"),nn=Re("touchmove"),rn=Re("touchstart"),an=Re(Oe("transitionend")),on=Re("volumechange"),sn=Re("waiting"),ln=Re("wheel"),cn=[Fe,qe,Ve,ct,ut,dt,pt,ht,St,kt,Ct,Ut,Dt,It,Wt,qt,Ht,Gt,$t,Yt,Jt,on,sn];function un(e){return function(e){return e}(e)}var dn=null;function pn(){return!dn&&i.canUseDOM&&(dn="textContent"in document.documentElement?"textContent":"innerText"),dn}var hn={_root:null,_startText:null,_fallbackText:null};function fn(){if(hn._fallbackText)return hn._fallbackText;var e=void 0,t=hn._startText,n=t.length,r=void 0,a=mn(),i=a.length;for(e=0;e1?1-r:void 0;return hn._fallbackText=a.slice(e,s),hn._fallbackText}function mn(){return"value"in hn._root?hn._root.value:hn._root[pn()]}var gn=!1,vn=10,bn=["dispatchConfig","_targetInst","nativeEvent","isDefaultPrevented","isPropagationStopped","_dispatchListeners","_dispatchInstances"],yn={type:null,target:null,currentTarget:s.thatReturnsNull,eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null};function wn(e,t,n,r){delete this.nativeEvent,delete this.preventDefault,delete this.stopPropagation,this.dispatchConfig=e,this._targetInst=t,this.nativeEvent=n;var a=this.constructor.Interface;for(var i in a)if(a.hasOwnProperty(i)){delete this[i];var o=a[i];o?this[i]=o(n):"target"===i?this.target=r:this[i]=n[i]}var l=null!=n.defaultPrevented?n.defaultPrevented:!1===n.returnValue;return this.isDefaultPrevented=l?s.thatReturnsTrue:s.thatReturnsFalse,this.isPropagationStopped=s.thatReturnsFalse,this}function En(e,t){var n="function"==typeof t;return{configurable:!0,set:function(e){return r(n?"setting the method":"setting the property","This is effectively a no-op"),e},get:function(){return r(n?"accessing the method":"accessing the property",n?"This is a no-op function":"This is set to null"),t}};function r(t,n){a(!1,"This synthetic event is reused for performance reasons. If you're seeing this, you're %s `%s` on a released/nullified synthetic event. %s. If you must keep the original synthetic event around, use event.persist(). See https://fb.me/react-event-pooling for more information.",t,e,n)}}function Cn(e,t,n,r){if(this.eventPool.length){var a=this.eventPool.pop();return this.call(a,e,t,n,r),a}return new this(e,t,n,r)}function Sn(e){e instanceof this||n(!1,"Trying to release an event instance into a pool of a different type."),e.destructor(),this.eventPool.length8&&Rn<=11),In=32,An=String.fromCharCode(In),On={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:[$e,yt,Xt,Rt]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:[We,$e,bt,yt,wt,xt]},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:[We,Qe,bt,yt,wt,xt]},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:[We,Ye,bt,yt,wt,xt]}},Fn=!1;function Ln(e,t){switch(e){case wt:return-1!==Pn.indexOf(t.keyCode);case bt:return t.keyCode!==Nn;case yt:case xt:case We:return!0;default:return!1}}function jn(e){var t=e.detail;return"object"==typeof t&&"data"in t?t.data:null}var zn=!1;function Wn(e,t,n,r){var a=void 0,i=void 0;if(Mn?a=function(e){switch(e){case Qe:return On.compositionStart;case $e:return On.compositionEnd;case Ye:return On.compositionUpdate}}(e):zn?Ln(e,n)&&(a=On.compositionEnd):function(e,t){return e===bt&&t.keyCode===Nn}(e,n)&&(a=On.compositionStart),!a)return null;Dn&&(zn||a!==On.compositionStart?a===On.compositionEnd&&zn&&(i=fn()):zn=function(e){return hn._root=e,hn._startText=mn(),!0}(r));var o=xn.getPooled(a,t,n,r);if(i)o.data=i;else{var s=jn(n);null!==s&&(o.data=s)}return Pe(o),o}function qn(e,t){if(zn){if(e===$e||!Mn&&Ln(e,t)){var n=fn();return hn._root=null,hn._startText=null,hn._fallbackText=null,zn=!1,n}return null}switch(e){case Rt:return null;case yt:if(!function(e){return(e.ctrlKey||e.altKey||e.metaKey)&&!(e.ctrlKey&&e.altKey)}(t)){if(t.char&&t.char.length>1)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case $e:return Dn?null:t.data;default:return null}}function Vn(e,t,n,r){var a=void 0;if(!(a=Un?function(e,t){switch(e){case $e:return jn(t);case yt:return t.which!==In?null:(Fn=!0,An);case Xt:var n=t.data;return n===An&&Fn?null:n;default:return null}}(e,n):qn(e,n)))return null;var i=_n.getPooled(On.beforeInput,t,n,r);return i.data=a,Pe(i),i}var Bn={eventTypes:On,extractEvents:function(e,t,n,r){var a=Wn(e,t,n,r),i=Vn(e,t,n,r);return null===a?i:null===i?a:[a,i]}},Hn=null,Gn=null,Kn=null;function $n(e){var t=I(e);if(t){Hn&&"function"==typeof Hn.restoreControlledState||n(!1,"Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue.");var r=D(t.stateNode);Hn.restoreControlledState(t.stateNode,t.type,r)}}var Qn={injectFiberControlledHostComponent:function(e){Hn=e}};function Yn(e){Gn?Kn?Kn.push(e):Kn=[e]:Gn=e}function Xn(){return null!==Gn||null!==Kn}function Jn(){if(Gn){var e=Gn,t=Kn;if(Gn=null,Kn=null,$n(e),t)for(var n=0;n2&&("o"===e[0]||"O"===e[0])&&("n"===e[1]||"N"===e[1]))}function ra(e,t,n,r){if(null!==n&&n.type===qr)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":if(r)return!1;if(null!==n)return!n.acceptsBooleans;var a=e.toLowerCase().slice(0,5);return"data-"!==a&&"aria-"!==a;default:return!1}}function aa(e,t,n,r){if(null===t||void 0===t)return!0;if(ra(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case Br:return!t;case Hr:return!1===t;case Gr:return isNaN(t);case Kr:return isNaN(t)||t<1}return!1}function ia(e){return sa.hasOwnProperty(e)?sa[e]:null}function oa(e,t,n,r,a){this.acceptsBooleans=t===Vr||t===Br||t===Hr,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t}var sa={};["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"].forEach(function(e){sa[e]=new oa(e,qr,!1,e,null)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0],n=e[1];sa[t]=new oa(t,1,!1,n,null)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){sa[e]=new oa(e,Vr,!1,e.toLowerCase(),null)}),["autoReverse","externalResourcesRequired","preserveAlpha"].forEach(function(e){sa[e]=new oa(e,Vr,!1,e,null)}),["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach(function(e){sa[e]=new oa(e,Br,!1,e.toLowerCase(),null)}),["checked","multiple","muted","selected"].forEach(function(e){sa[e]=new oa(e,Br,!0,e.toLowerCase(),null)}),["capture","download"].forEach(function(e){sa[e]=new oa(e,Hr,!1,e.toLowerCase(),null)}),["cols","rows","size","span"].forEach(function(e){sa[e]=new oa(e,Kr,!1,e.toLowerCase(),null)}),["rowSpan","start"].forEach(function(e){sa[e]=new oa(e,Gr,!1,e.toLowerCase(),null)});var la=/[\-\:]([a-z])/g,ca=function(e){return e[1].toUpperCase()};function ua(e,t,n,r){if(r.mustUseProperty)return e[r.propertyName];var a=r.attributeName,i=null;if(r.type===Hr){if(e.hasAttribute(a)){var o=e.getAttribute(a);return""===o||(aa(t,n,r,!1)?o:o===""+n?n:o)}}else if(e.hasAttribute(a)){if(aa(t,n,r,!1))return e.getAttribute(a);if(r.type===Br)return n;i=e.getAttribute(a)}return aa(t,n,r,!1)?null===i?n:i:i===""+n?n:i}function da(e,t,n){if(ta(t)){if(!e.hasAttribute(t))return void 0===n?void 0:null;var r=e.getAttribute(t);return r===""+n?n:r}}function pa(e,t,n,r){var a=ia(t);if(!na(t,a,r))if(aa(t,n,a,r)&&(n=null),r||null===a){if(ta(t)){var i=t;null===n?e.removeAttribute(i):e.setAttribute(i,""+n)}}else if(a.mustUseProperty){var o=a.propertyName;if(null===n){var s=a.type;e[o]=s!==Br&&""}else e[o]=n}else{var l=a.attributeName,c=a.attributeNamespace;if(null===n)e.removeAttribute(l);else{var u=a.type,d=void 0;d=u===Br||u===Hr&&!0===n?"":""+n,c?e.setAttributeNS(c,l,d):e.setAttribute(l,d)}}}["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach(function(e){var t=e.replace(la,ca);sa[t]=new oa(t,1,!1,e,null)}),["xlink:actuate","xlink:arcrole","xlink:href","xlink:role","xlink:show","xlink:title","xlink:type"].forEach(function(e){var t=e.replace(la,ca);sa[t]=new oa(t,1,!1,e,"http://www.w3.org/1999/xlink")}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(la,ca);sa[t]=new oa(t,1,!1,e,"http://www.w3.org/XML/1998/namespace")}),sa.tabIndex=new oa("tabIndex",1,!1,"tabindex",null);var ha={checkPropTypes:null},fa={button:!0,checkbox:!0,image:!0,hidden:!0,radio:!0,reset:!0,submit:!0},ma={value:function(e,t,n){return!e[t]||fa[e.type]||e.onChange||e.readOnly||e.disabled?null:new Error("You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.")},checked:function(e,t,n){return!e[t]||e.onChange||e.readOnly||e.disabled?null:new Error("You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`.")}};ha.checkPropTypes=function(e,t,n){l(ma,t,"prop",e,n)};var ga=Wr.getCurrentFiberOwnerName,va=Wr.getCurrentFiberStackAddendum,ba=!1,ya=!1,wa=!1,Ea=!1;function Ca(e){return"checkbox"===e.type||"radio"===e.type?null!=e.checked:null!=e.value}function Sa(e,t){var n=e,r=t.checked;return o({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=r?r:n._wrapperState.initialChecked})}function ka(e,t){ha.checkPropTypes("input",t,va),void 0===t.checked||void 0===t.defaultChecked||ya||(a(!1,"%s contains an input of type %s with both checked and defaultChecked props. Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://fb.me/react-controlled-components",ga()||"A component",t.type),ya=!0),void 0===t.value||void 0===t.defaultValue||ba||(a(!1,"%s contains an input of type %s with both value and defaultValue props. Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://fb.me/react-controlled-components",ga()||"A component",t.type),ba=!0);var n=e,r=null==t.defaultValue?"":t.defaultValue;n._wrapperState={initialChecked:null!=t.checked?t.checked:t.defaultChecked,initialValue:Ma(null!=t.value?t.value:r),controlled:Ca(t)}}function Ta(e,t){var n=e,r=t.checked;null!=r&&pa(n,"checked",r,!1)}function xa(e,t){var n=e,r=Ca(t);n._wrapperState.controlled||!r||Ea||(a(!1,"A component is changing an uncontrolled input of type %s to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s",t.type,va()),Ea=!0),!n._wrapperState.controlled||r||wa||(a(!1,"A component is changing a controlled input of type %s to be uncontrolled. Input elements should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s",t.type,va()),wa=!0),Ta(e,t);var i=Ma(t.value);null!=i&&("number"===t.type?(0===i&&""===n.value||n.value!=i)&&(n.value=""+i):n.value!==""+i&&(n.value=""+i)),t.hasOwnProperty("value")?Na(n,t.type,i):t.hasOwnProperty("defaultValue")&&Na(n,t.type,Ma(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(n.defaultChecked=!!t.defaultChecked)}function _a(e,t,n){var r=e;if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var a=""+r._wrapperState.initialValue,i=r.value;n||a!==i&&(r.value=a),r.defaultValue=a}var o=r.name;""!==o&&(r.name=""),r.defaultChecked=!r.defaultChecked,r.defaultChecked=!r.defaultChecked,""!==o&&(r.name=o)}function Pa(e,t){var r=e;xa(r,t),function(e,t){var r=t.name;if("radio"===t.type&&null!=r){for(var a=e;a.parentNode;)a=a.parentNode;for(var i=a.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),o=0;o9));var Ha={eventTypes:Ra,_isInputEventSupported:La,extractEvents:function(e,t,n,r){var a,i,o,s,l=t?ge(t):window,c=void 0,u=void 0;if("select"===(i=(a=l).nodeName&&a.nodeName.toLowerCase())||"input"===i&&"file"===a.type?c=Fa:sr(l)?La?c=Ba:(c=qa,u=Wa):function(e){var t=e.nodeName;return t&&"input"===t.toLowerCase()&&("checkbox"===e.type||"radio"===e.type)}(l)&&(c=Va),c){var d=c(e,t);if(d)return Ua(d,n,r)}u&&u(e,l,t),e===We&&(s=(o=l)._wrapperState)&&s.controlled&&"number"===o.type&&Na(o,"number",o.value)}},Ga=Tn.extend({view:null,detail:null}),Ka={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $a(e){var t=this.nativeEvent;if(t.getModifierState)return t.getModifierState(e);var n=Ka[e];return!!n&&!!t[n]}function Qa(e){return $a}var Ya=Ga.extend({screenX:null,screenY:null,clientX:null,clientY:null,pageX:null,pageY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:Qa,button:null,buttons:null,relatedTarget:function(e){return e.relatedTarget||(e.fromElement===e.srcElement?e.toElement:e.fromElement)}}),Xa=Ya.extend({pointerId:null,width:null,height:null,pressure:null,tiltX:null,tiltY:null,pointerType:null,isPrimary:null}),Ja={mouseEnter:{registrationName:"onMouseEnter",dependencies:[Pt,Nt]},mouseLeave:{registrationName:"onMouseLeave",dependencies:[Pt,Nt]},pointerEnter:{registrationName:"onPointerEnter",dependencies:[Lt,jt]},pointerLeave:{registrationName:"onPointerLeave",dependencies:[Lt,jt]}},Za={eventTypes:Ja,extractEvents:function(e,t,n,r){var a=e===Nt||e===jt,i=e===Pt||e===Lt;if(a&&(n.relatedTarget||n.fromElement))return null;if(!i&&!a)return null;var o=void 0;if(r.window===r)o=r;else{var s=r.ownerDocument;o=s?s.defaultView||s.parentWindow:window}var l=void 0,c=void 0;if(i){l=t;var u=n.relatedTarget||n.toElement;c=u?fe(u):null}else l=null,c=t;if(l===c)return null;var d=void 0,p=void 0,h=void 0,f=void 0;e===Pt||e===Nt?(d=Ya,p=Ja.mouseLeave,h=Ja.mouseEnter,f="mouse"):e!==Lt&&e!==jt||(d=Xa,p=Ja.pointerLeave,h=Ja.pointerEnter,f="pointer");var m=null==l?o:ge(l),g=null==c?o:ge(c),v=d.getPooled(p,l,n,r);v.type=f+"leave",v.target=m,v.relatedTarget=g;var b=d.getPooled(h,c,n,r);return b.type=f+"enter",b.target=g,b.relatedTarget=m,Ne(v,b,l,c),[v,b]}};function ei(e){return e._reactInternalFiber}var ti=0,ni=1,ri=2,ai=4,ii=6,oi=8,si=16,li=32,ci=64,ui=128,di=256,pi=511,hi=512,fi=1024,mi=1,gi=2,vi=3;function bi(e){var t=e;if(e.alternate)for(;t.return;)t=t.return;else{if((t.effectTag&ri)!==ti)return mi;for(;t.return;)if(((t=t.return).effectTag&ri)!==ti)return mi}return t.tag===Z?gi:vi}function yi(e){return bi(e)===gi}function wi(e){bi(e)!==gi&&n(!1,"Unable to find node on an unmounted component.")}function Ei(e){var t=e.alternate;if(!t){var r=bi(e);return r===vi&&n(!1,"Unable to find node on an unmounted component."),r===mi?null:e}for(var a=e,i=t;;){var o=a.return,s=o?o.alternate:null;if(!o||!s)break;if(o.child===s.child){for(var l=o.child;l;){if(l===a)return wi(o),e;if(l===i)return wi(o),t;l=l.sibling}n(!1,"Unable to find node on an unmounted component.")}if(a.return!==i.return)a=o,i=s;else{for(var c=!1,u=o.child;u;){if(u===a){c=!0,a=o,i=s;break}if(u===i){c=!0,i=o,a=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===a){c=!0,a=s,i=o;break}if(u===i){c=!0,i=s,a=o;break}u=u.sibling}c||n(!1,"Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}a.alternate!==i&&n(!1,"Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}return a.tag!==Z&&n(!1,"Unable to find node on an unmounted component."),a.stateNode.current===a?e:t}function Ci(e){var t=Ei(e);if(!t)return null;for(var n=t;;){if(n.tag===te||n.tag===ne)return n;if(n.child)n.child.return=n,n=n.child;else{if(n===t)return null;for(;!n.sibling;){if(!n.return||n.return===t)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}}return null}var Si=Tn.extend({animationName:null,elapsedTime:null,pseudoElement:null}),ki=Tn.extend({clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Ti=Ga.extend({relatedTarget:null});function xi(e){var t=void 0,n=e.keyCode;return"charCode"in e?0===(t=e.charCode)&&13===n&&(t=13):t=n,10===t&&(t=13),t>=32||13===t?t:0}var _i={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Pi={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"};var Ni=Ga.extend({key:function(e){if(e.key){var t=_i[e.key]||e.key;if("Unidentified"!==t)return t}if("keypress"===e.type){var n=xi(e);return 13===n?"Enter":String.fromCharCode(n)}return"keydown"===e.type||"keyup"===e.type?Pi[e.keyCode]||"Unidentified":""},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:Qa,charCode:function(e){return"keypress"===e.type?xi(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?xi(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),Mi=Ya.extend({dataTransfer:null}),Ri=Ga.extend({touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:Qa}),Ui=Tn.extend({propertyName:null,elapsedTime:null,pseudoElement:null}),Di=Ya.extend({deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null}),Ii=[[Fe,"abort"],[Le,"animationEnd"],[je,"animationIteration"],[ze,"animationStart"],[qe,"canPlay"],[Ve,"canPlayThrough"],[tt,"drag"],[rt,"dragEnter"],[at,"dragExit"],[it,"dragLeave"],[ot,"dragOver"],[ct,"durationChange"],[ut,"emptied"],[dt,"encrypted"],[pt,"ended"],[ht,"error"],[mt,"gotPointerCapture"],[Et,"load"],[St,"loadedData"],[kt,"loadedMetadata"],[Ct,"loadStart"],[Tt,"lostPointerCapture"],[_t,"mouseMove"],[Pt,"mouseOut"],[Nt,"mouseOver"],[It,"playing"],[Ft,"pointerMove"],[Lt,"pointerOut"],[jt,"pointerOver"],[Wt,"progress"],[Bt,"scroll"],[Gt,"seeking"],[$t,"stalled"],[Yt,"suspend"],[Jt,"timeUpdate"],[Zt,"toggle"],[nn,"touchMove"],[an,"transitionEnd"],[sn,"waiting"],[ln,"wheel"]],Ai={},Oi={};function Fi(e,t){var n=e[0],r=e[1],a="on"+(r[0].toUpperCase()+r.slice(1)),i={phasedRegistrationNames:{bubbled:a,captured:a+"Capture"},dependencies:[n],isInteractive:t};Ai[r]=i,Oi[n]=i}[[We,"blur"],[Be,"cancel"],[Ge,"click"],[Ke,"close"],[Xe,"contextMenu"],[Je,"copy"],[Ze,"cut"],[et,"doubleClick"],[nt,"dragEnd"],[st,"dragStart"],[lt,"drop"],[ft,"focus"],[gt,"input"],[vt,"invalid"],[bt,"keyDown"],[yt,"keyPress"],[wt,"keyUp"],[xt,"mouseDown"],[Mt,"mouseUp"],[Rt,"paste"],[Ut,"pause"],[Dt,"play"],[At,"pointerCancel"],[Ot,"pointerDown"],[zt,"pointerUp"],[qt,"rateChange"],[Vt,"reset"],[Ht,"seeked"],[Qt,"submit"],[en,"touchCancel"],[tn,"touchEnd"],[rn,"touchStart"],[on,"volumeChange"]].forEach(function(e){Fi(e,!0)}),Ii.forEach(function(e){Fi(e,!1)});var Li=[Fe,Be,qe,Ve,Ke,ct,ut,dt,pt,ht,gt,vt,Et,St,kt,Ct,Ut,Dt,It,Wt,qt,Vt,Ht,Gt,$t,Qt,Yt,Jt,Zt,on,sn],ji={eventTypes:Ai,isInteractiveTopLevelEventType:function(e){var t=Oi[e];return void 0!==t&&!0===t.isInteractive},extractEvents:function(e,t,n,r){var i=Oi[e];if(!i)return null;var o=void 0;switch(e){case yt:if(0===xi(n))return null;case bt:case wt:o=Ni;break;case We:case ft:o=Ti;break;case Ge:if(2===n.button)return null;case et:case xt:case _t:case Mt:case Pt:case Nt:case Xe:o=Ya;break;case tt:case nt:case rt:case at:case it:case ot:case st:case lt:o=Mi;break;case en:case tn:case nn:case rn:o=Ri;break;case Le:case je:case ze:o=Si;break;case an:o=Ui;break;case Bt:o=Ga;break;case ln:o=Di;break;case Je:case Ze:case Rt:o=ki;break;case mt:case Tt:case At:case Ot:case Ft:case Lt:case jt:case zt:o=Xa;break;default:-1===Li.indexOf(e)&&a(!1,"SimpleEventPlugin: Unhandled event type, `%s`. This warning is likely caused by a bug in React. Please file an issue.",e),o=Tn}var s=o.getPooled(i,t,n,r);return Pe(s),s}},zi=ji.isInteractiveTopLevelEventType,Wi=10,qi=[];function Vi(e){for(;e.return;)e=e.return;return e.tag!==Z?null:e.stateNode.containerInfo}function Bi(e){var t=e.targetInst,n=t;do{if(!n){e.ancestors.push(n);break}var r=Vi(n);if(!r)break;e.ancestors.push(n),n=fe(r)}while(n);for(var a=0;a=t)return{node:n,offset:t-r};r=a}n=ro(ao(n))}}function oo(e){var t=window.getSelection&&window.getSelection();if(!t||0===t.rangeCount)return null;var n=t.anchorNode,r=t.anchorOffset,a=t.focusNode,i=t.focusOffset;try{n.nodeType,a.nodeType}catch(e){return null}return function(e,t,n,r,a){var i=0,o=-1,s=-1,l=0,c=0,u=e,d=null;e:for(;;){for(var p=null;u!==t||0!==n&&u.nodeType!==cr||(o=i+n),u!==r||0!==a&&u.nodeType!==cr||(s=i+a),u.nodeType===cr&&(i+=u.nodeValue.length),null!==(p=u.firstChild);)d=u,u=p;for(;;){if(u===e)break e;if(d===t&&++l===n&&(o=i),d===r&&++c===a&&(s=i),null!==(p=u.nextSibling))break;d=(u=d).parentNode}u=p}if(-1===o||-1===s)return null;return{start:o,end:s}}(e,n,r,a,i)}function so(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}function lo(){var e=c();return{focusedElem:e,selectionRange:so(e)?function(e){var t=void 0;t="selectionStart"in e?{start:e.selectionStart,end:e.selectionEnd}:oo(e);return t||{start:0,end:0}}(e):null}}function co(e){var t,n=c(),r=e.focusedElem,a=e.selectionRange;if(n!==r&&(t=r,d(document.documentElement,t))){null!==a&&so(r)&&function(e,t){var n=t.start,r=t.end;void 0===r&&(r=n);"selectionStart"in e?(e.selectionStart=n,e.selectionEnd=Math.min(r,e.value.length)):function(e,t){if(window.getSelection){var n=window.getSelection(),r=e[pn()].length,a=Math.min(t.start,r),i=void 0===t.end?a:Math.min(t.end,r);if(!n.extend&&a>i){var o=i;i=a,a=o}var s=io(e,a),l=io(e,i);if(s&&l){if(1===n.rangeCount&&n.anchorNode===s.node&&n.anchorOffset===s.offset&&n.focusNode===l.node&&n.focusOffset===l.offset)return;var c=document.createRange();c.setStart(s.node,s.offset),n.removeAllRanges(),a>i?(n.addRange(c),n.extend(l.node,l.offset)):(c.setEnd(l.node,l.offset),n.addRange(c))}}}(e,t)}(r,a);for(var i=[],o=r;o=o.parentNode;)o.nodeType===lr&&i.push({element:o,left:o.scrollLeft,top:o.scrollTop});"function"==typeof r.focus&&r.focus();for(var s=0;s0?e:0}},Fo=function(e,t){var n=e.scheduledCallback,r=!1;try{n(t),r=!0}finally{xo(e),r||(Ro=!0,window.postMessage(Lo,"*"))}},Lo="__reactIdleCallback$"+Math.random().toString(36).slice(2);window.addEventListener("message",function(e){if(e.source===window&&e.data===Lo&&(Ro=!1,null!==Po)){!function(){if(null!==Po){var e=So();if(!(-1===Mo||Mo>e)){for(var t=-1,n=[],r=Po;null!==r;){var a=r.timeoutTime;-1!==a&&a<=e?n.push(r):-1!==a&&(-1===t||a0){Oo.didTimeout=!0;for(var i=0,o=n.length;i0&&null!==Po;){var n=Po;Oo.didTimeout=!1,Fo(n,Oo),t=So()}null!==Po&&(Uo||(Uo=!0,_o(jo)))}},!1);var jo=function(e){Uo=!1;var t=e-Do+Ao;t instead of setting `selected` on