(r.prefix.name)} has quit `;break;case"NICK":let f=r.params[0];e=tS` ${u(r.prefix.name)} is now known as ${u(f)} `;break;case"KICK":e=tS` ${u(r.params[1])} was kicked by ${u(r.prefix.name)} (${r.params.slice(2)}) `;break;case"MODE":s=r.params[0];let g=r.params[1],b=tS`${u(r.prefix.name)}`;if(a.type==sa.CHANNEL&&2===g.length&&i.cm(a.name)===i.cm(s)){let t,s,n=g[0],a=g[1],i=r.params[2];switch(a){case"b":t="+"===n?"added":"removed",e=tS`${b} has ${t} a ban on ${i}`;break;case"e":t="+"===n?"added":"removed",e=tS`${b} has ${t} a ban exemption on ${i}`;break;case"l":e="+"===n?tS`${b} has set the channel user limit to ${i}`:tS`${b} has unset the channel user limit`;break;case"i":t="+"===n?"marked":"unmarked",e=tS`${b} has ${t} as invite-only`;break;case"m":t="+"===n?"marked":"unmarked",e=tS`${b} has ${t} as moderated`;break;case"s":t="+"===n?"marked":"unmarked",e=tS`${b} has ${t} as secret`;break;case"t":t="+"===n?"locked":"unlocked",e=tS`${b} has ${t} the channel topic`;break;case"n":t="+"===n?"allowed":"denied",e=tS`${b} has ${t} external messages to this channel`}if(e)break;for(let e in tN)if(tN[e]===a){s=t$[e];break}if(s&&i){e=tS` ${b} has ${"+"===n?"granted":"revoked"} ${s} privileges ${"+"===n?"to":"from"} ${u(i)} `;break}}e=tS` ${b} sets mode ${r.params.slice(1).join(" ")} `,i.cm(a.name)!==i.cm(s)&&(e=tS`${e} on ${s}`);break;case"TOPIC":let k=r.params[1];e=tS` ${u(r.prefix.name)} changed the topic to: ${st(sr(k),l)} `;break;case"INVITE":t=r.params[0];let v=r.params[1];a.type===sa.SERVER?(h="talk",e=tS` You have been invited to ${tS` ${v} `} by ${u(r.prefix.name)} `):e=tS` ${u(r.prefix.name)} has invited ${u(t)} to the channel `;break;case"001":let w=r.params[0];e=tS`Connected to server, your nickname is ${w}`;break;case"341":t=r.params[1],e=tS`${u(t)} has been invited to the channel`;break;case"372":h="motd",e=st(sr(r.params[1]),l);break;case"900":n=r.params[2],e=tS`You are now authenticated as ${n}`;break;case"901":e=tS`You are now unauthenticated`;break;case"REGISTER":n=r.params[1];let E=r.params[2];switch(r.params[0]){case"SUCCESS":e=tS`A new account has been created, you are now authenticated as ${n}`;break;case"VERIFICATION_REQUIRED":e=tS`A new account has been created, but you need to verify it: ${st(E)}`}break;case"VERIFY":n=r.params[1],e=tS`The new account has been verified, you are now authenticated as ${n}`;break;case"221":let y=r.params[1];e=y?tS`Your user mode is ${y}`:tS`You have no user mode`;break;case"324":e=tS`Channel mode is ${r.params.slice(2).join(" ")}`;break;case"329":let S=new Date(1e3*parseInt(r.params[2],10));e=tS`Channel was created on ${S.toLocaleString()}`;break;case"730":e=tS`${u(a.name)} is online`;break;case"731":e=tS`${u(a.name)} is offline`;break;default:tB(r.command)&&"422"!=r.command&&(h="error"),e=tS`${r.command} ${st(r.params.join(" "))}`}return e?tS`
<${sD} date=${new Date(r.tags.time)} url=${sp(a,r)}/> ${" "} ${e}
`:null}}class sL extends I{shouldComponentUpdate(e){return this.props.messages[0]!==e.messages[0]||this.props.messages[this.props.messages.length-1]!==e.messages[e.messages.length-1]}render(){let e=this.props.messages,t=this.props.buffer,s=this.props.server,n=this.props.onNickClick;function r(e){return tS` <${sx} nick=${e} user=${s.users.get(e)} onClick=${()=>n(e)} /> `}let a={JOIN:[],PART:[],QUIT:[],NICK:[]};e.forEach(e=>{a[e.command].push(e)});let i=!0,o=[];["JOIN","PART","QUIT"].forEach(e=>{let t;if(0===a[e].length)return;let s=new Set(a[e].map(e=>e.prefix.name)),n=s.size>1;switch(e){case"JOIN":t=n?"have joined":"has joined";break;case"PART":t=n?"have left":"has left";break;case"QUIT":t=n?"have quit":"has quit"}i?i=!1:o.push(", "),o.push(function(e,t){if(0===e.length)return null;if(1===e.length)return t(e[0]);let s=e.slice(0,e.length-1).map((e,s)=>0===s?t(e):[", ",t(e)]);return s.push(" and "),s.push(t(e[e.length-1])),s}([...s],r)),o.push(" "+t)}),a.NICK.forEach(e=>{i?i=!1:o.push(", ");let t=e.params[0];o.push(tS` ${r(e.prefix.name)} is now known as ${r(t)} `)});let l=e[e.length-1],c=new Date(e[0].tags.time),u=new Date(l.tags.time),h=tS` <${sD} date=${c} url=${sp(t,e[0])}/> `;return u-c>6e3&&(h=[h," — ",tS` <${sD} date=${u} url=${sp(t,l)}/> `]),tS`
${h} ${" "} ${o}
`}}let sM=!1;if(window.Notification&&(sM=!0,"default"===Notification.permission))try{new Notification("")}catch(e){"TypeError"===e.name&&(sM=!1)}class sP extends I{state={nag:!1};constructor(e){super(e),this.handleClick=this.handleClick.bind(this),this.state.nag=this.shouldNag()}shouldNag(){return sM&&"default"===Notification.permission}handleClick(e){e.preventDefault(),Notification.requestPermission(e=>{this.setState({nag:this.shouldNag()})})}render(){return this.state.nag?tS`
<${sD}/> ${" "} Turn on desktop notifications to get notified about new messages
`:null}}class sB extends I{state={nag:!0};constructor(e){super(e),this.handleClick=this.handleClick.bind(this),this.state.nag=!sN.load()}handleClick(e){e.preventDefault();let t=window.location.origin+window.location.pathname+"?open=%s";try{navigator.registerProtocolHandler("irc",t),navigator.registerProtocolHandler("ircs",t)}catch(e){console.error("Failed to register protocol handler: ",e)}sN.put(!0),this.setState({nag:!1})}render(){if(!navigator.registerProtocolHandler||!this.state.nag)return null;let e=this.props.bouncerName||"this bouncer";return tS`
<${sD}/> ${" "} Register our protocol handler to open IRC links with ${e}
`}}function sH({server:e,onAuthClick:t,onRegisterClick:s}){let n="an account on this server";e.name&&(n="a "+e.name+" account");let r=[tS` You are unauthenticated on this server, ${" "} login ${" "} `];return e.supportsAccountRegistration?r.push(tS`or register ${n}`):r.push(tS`if you have ${n}`),tS`
<${sD}/> ${r}
`}class sj extends I{constructor(e){super(e)}shouldComponentUpdate(e){return this.props.date.getTime()!==e.date.getTime()}render(){let e=this.props.date.toLocaleDateString([],{year:"numeric",month:"2-digit",day:"2-digit"});return tS`
${e}
`}}function sU(e){return tS`
New messages
`}class sW extends I{shouldComponentUpdate(e){return this.props.buffer!==e.buffer||this.props.settings!==e.settings}render(){let e=this.props.buffer;if(!e)return null;let t=this.props.server,s=this.props.settings,n=t.name,r=[];e.type==sa.SERVER&&r.push(tS`<${sP}/>`),e.type==sa.SERVER&&t.isBouncer&&!t.bouncerNetID&&r.push(tS`<${sB} bouncerName=${n}/>`),e.type==sa.SERVER&&t.status==si.REGISTERED&&t.supportsSASLPlain&&!t.account&&r.push(tS` <${sH} server=${t} onAuthClick=${this.props.onAuthClick} onRegisterClick=${this.props.onRegisterClick} /> `);let a=this.props.onChannelClick,i=this.props.onNickClick,o=this.props.onVerifyClick;function l(s){return tS` <${sA} key=${"msg-"+s.key} message=${s} buffer=${e} server=${t} onChannelClick=${a} onNickClick=${i} onVerifyClick=${o} /> `}function c(s){let n=new Map,r=[];for(let e of s){let t=!0;switch(e.command){case"PART":case"QUIT":n.delete(e.prefix.name);break;case"NICK":let s=n.get(e.prefix.name);if(!s){e={...e},n.set(e.params[0],e);break}s.params=e.params,n.delete(e.prefix.name),n.set(e.params[0],s),t=!1}t&&r.push(e)}s=r;let a=new Map,o=[];return(s.forEach((e,t)=>{("PART"===e.command||"QUIT"===e.command)&&a.set(e.prefix.name,t),"JOIN"===e.command&&a.has(e.prefix.name)?(o[a.get(e.prefix.name)]=!1,a.delete(e.prefix.name),o.push(!1)):"NICK"===e.command&&e.prefix.name==e.params[0]?o.push(!1):o.push(!0)}),0===(s=s.filter((e,t)=>o[t])).length)?null:1===s.length?l(s[0]):tS` <${sL} key=${"fold-"+s[0].key+"-"+s[s.length-1].key} messages=${s} buffer=${e} server=${t} onNickClick=${i} /> `}let u=!1,h=new Date,p=[],d=null;return e.messages.forEach(t=>{var n;let a=[];if(s.bufferEvents===sc.HIDE&&sO(t))return;if("730"===t.command||"731"===t.command){let e=!d||t.command===d;if(d=t.command,e)return}u||e.type==sa.SERVER||sg(t,e.prevReadReceipt)||(a.push(tS`<${sU} key="unread"/>`),u=!0);let i=new Date(t.tags.time);if(((n=h).getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()||n.getDate()!==i.getDate())&&a.push(tS`<${sj} key=${"date-"+i} date=${i}/>`),h=i,a.length>0&&(r.push(c(p)),r.push(a),p=[]),s.bufferEvents===sc.FOLD&&sO(t)){p.push(t);return}p.length>0&&(r.push(c(p)),p=[]),r.push(l(t))}),r.push(c(p)),tS`
${r}
`}}function sF(e){let t;let s=e.buffer.name;e.buffer.type==sa.SERVER&&(s=sd(e.server,e.bouncerNetwork));let n=["type-"+e.buffer.type];switch(e.active&&n.push("active"),e.buffer.unread!=so.NONE&&n.push("unread-"+e.buffer.unread),e.buffer.type){case sa.SERVER:let r=e.server.status===si.DISCONNECTED;e.bouncerNetwork&&e.bouncerNetwork.error&&(r=!0),r&&n.push("error");break;case sa.NICK:let a=e.server.users.get(s);a&&tz(a.realname,s)&&(t=sr(a.realname))}return tS`
  • ${s}
  • `}function sK(e){let t=Array.from(e.buffers.values()).map(t=>{let s=e.servers.get(t.server),n=null;return s.bouncerNetID&&(n=e.bouncerNetworks.get(s.bouncerNetID)),tS` <${sF} key=${t.id} buffer=${t} server=${s} bouncerNetwork=${n} onClick=${()=>e.onBufferClick(t)} onClose=${()=>e.onBufferClose(t)} active=${e.activeBuffer==t.id} /> `});return tS``}const sG={HERE:"here",GONE:"gone",OFFLINE:"offline"};function sV(e){let t={[sG.HERE]:"User is online",[sG.GONE]:"User is away",[sG.OFFLINE]:"User is offline"}[e.status];return tS``}function sz(e){let t=e.server.status===si.REGISTERED;e.bouncerNetwork&&(t=t&&"connected"===e.bouncerNetwork.state);let s=null,n=[];switch(e.buffer.type){case sa.SERVER:switch(e.server.status){case si.DISCONNECTED:s="Disconnected";break;case si.CONNECTING:s="Connecting...";break;case si.REGISTERING:s="Logging in...";break;case si.REGISTERED:if(e.bouncerNetwork)switch(e.bouncerNetwork.state){case"disconnected":s="Bouncer disconnected from network",e.bouncerNetwork.error&&(s+=": "+e.bouncerNetwork.error);break;case"connecting":s="Bouncer connecting to network...";break;case"connected":s=`Connected to ${e.bouncerNetwork.host||"network"}`}else if(e.buffer.serverInfo){let t=e.buffer.serverInfo;s=`Connected to ${t.name}`}else s="Connected"}let r=tS` `,a=tS` `,i=tS` `;e.server.isBouncer?e.server.bouncerNetID?(t&&n.push(r),e.server.status===si.REGISTERED&&n.push(tS` `)):(t?n.push(tS` `):e.server.status===si.DISCONNECTED&&n.push(a),n.push(i)):(t?n.push(r):e.server.status===si.DISCONNECTED&&n.push(a),n.push(i));break;case sa.CHANNEL:e.buffer.topic&&(s=st(sr(e.buffer.topic),e.onChannelClick)),e.buffer.joined?n.push(tS` `):(t&&n.push(tS` `),n.push(tS` `));break;case sa.NICK:if(e.user){let t=sG.HERE;e.user.offline?t=sG.OFFLINE:e.user.away&&(t=sG.GONE);let n=e.buffer.name;tz(e.user.realname,e.buffer.name)&&(n=sr(e.user.realname||""));let r=[];if(e.user.username&&e.user.hostname&&r.push(`${e.user.username}@${e.user.hostname}`),e.user.account){let t,s=`This user is verified and has logged in to the server with the account ${e.user.account}.`;t=e.user.account===e.buffer.name?"authenticated":`authenticated as ${e.user.account}`,r.push(tS`${t}`)}else e.server.reliableUserAccounts&&r.push(tS`unauthenticated`);e.user.operator&&r.push(tS`server operator`),e.user.bot&&r.push(tS`bot`),(r=r.map((e,t)=>0===t?e:[", ",e])).length>0&&(r=["(",r,")"]),s=tS`<${sV} status=${t}/> ${n} ${r}`}n=tS` `}let o=e.buffer.name;return e.buffer.type==sa.SERVER&&(o=sd(e.server,e.bouncerNetwork)),tS`
    ${o}
    ${s?tS`
    ${s}
    `:null}
    ${n}
    `}class sq extends I{constructor(e){super(e),this.handleClick=this.handleClick.bind(this)}shouldComponentUpdate(e){return this.props.nick!==e.nick||this.props.membership!==e.membership||this.props.user!==e.user}handleClick(e){e.preventDefault(),this.props.onClick()}render(){let e;let t=this.props.user,s=["nick"];if(t){let n="";t.username&&t.hostname&&(n=`${t.username}@${t.hostname}`),tz(t.realname,this.props.nick)?(e=sr(t.realname),n&&(e=`${e} (${n})`)):e=n,t.account&&(e+=` Authenticated as ${t.account}`),t.away&&(s.push("away"),e+="\nAway")}return tS`
  • <${s_} value=${this.props.membership}/> ${this.props.nick}
  • `}}function sQ(e,t){let[s,n]=e,[r,a]=t,i=["~","&","@","%","+"],o=i.indexOf(n[0]),l=i.indexOf(a[0]);return(o<0&&(o=i.length),l<0&&(l=i.length),o!==l)?o-l:s.localeCompare(r)}class sJ extends I{shouldComponentUpdate(e){return this.props.members!==e.members||this.props.users!==e.users}render(){return tS` `}}class sY extends I{state={url:"",pass:"",nick:"",password:"",rememberMe:!1,username:"",realname:"",autojoin:!0};nickInput=$();constructor(e){super(e),this.handleInput=this.handleInput.bind(this),this.handleSubmit=this.handleSubmit.bind(this),e.params&&(this.state={...this.state,url:e.params.url||"",nick:e.params.nick||"",rememberMe:e.params.autoconnect||!1,username:e.params.username||"",realname:e.params.realname||""})}handleInput(e){let t=e.target,s="checkbox"==t.type?t.checked:t.value;this.setState({[t.name]:s})}handleSubmit(e){if(e.preventDefault(),this.props.connecting)return;let t={url:this.state.url,pass:this.state.pass,nick:this.state.nick,autoconnect:this.state.rememberMe,username:this.state.username,realname:this.state.realname,saslPlain:null,autojoin:[]};this.state.password?t.saslPlain={username:t.username||t.nick,password:this.state.password}:"external"===this.props.auth?t.saslExternal=!0:"oauth2"===this.props.auth&&(t.saslOauthBearer=this.props.params.saslOauthBearer),this.state.autojoin&&(t.autojoin=this.props.params.autojoin||[]),this.props.onSubmit(t)}componentDidMount(){this.nickInput.current&&this.nickInput.current.focus()}render(){let e=this.props.connecting,t=null;this.props.params&&this.props.params.url||(t=tS`

    `);let s=null;this.props.connecting?s=tS`

    Connecting...

    `:this.props.error&&(s=tS`

    ${st(this.props.error)}

    `);let n=null;"disabled"!==this.props.auth&&"external"!==this.props.auth&&"oauth2"!==this.props.auth&&(n=tS`

    `);let r=null,a=this.props.params.autojoin||[];if(a.length>0){let e=a.length>1?"s":"";r=tS`

    `}return tS`

    Connect to IRC



    ${n} ${r}

    Advanced options
    ${t}






    ${s}
    `}}class sX extends I{state={channel:"#"};constructor(e){super(e),this.handleInput=this.handleInput.bind(this),this.handleSubmit=this.handleSubmit.bind(this),e.channel&&(this.state.channel=e.channel)}handleInput(e){let t=e.target,s="checkbox"==t.type?t.checked:t.value;this.setState({[t.name]:s})}handleSubmit(e){e.preventDefault();let t={channel:this.state.channel};this.props.onSubmit(t)}render(){return tS`


    `}}function sZ(e,t,s){let n=Array.from(e.values()),r=n.findIndex(e=>e.id===t);return r<0?null:(r=(r+n.length+s)%n.length,n[r])}const s0=[{key:"h",altKey:!0,description:"Mark all messages as read",execute:e=>{e.setState(t=>{let s=new Map;return t.buffers.forEach(t=>{s.set(t.id,{...t,unread:so.NONE,prevReadReceipt:null});let n={};if(t.messages.length>0){let e=t.messages[t.messages.length-1];n[sl.READ]=sm(e)}let r=e.clients.get(t.server);e.bufferStore.put({name:t.name,server:r.params,unread:so.NONE,receipts:n})}),{buffers:s}},()=>{e.updateDocumentTitle()})}},{key:"a",altKey:!0,description:"Jump to next buffer with activity",execute:e=>{let t=null,s=null;for(let n of e.state.buffers.values())t||n.type!==sa.SERVER||(t=n),n.unread!==so.NONE&&(!s||so.compare(n.unread,s.unread)>0)&&(s=n);s||(s=t),s&&e.switchBuffer(s)}},{key:"ArrowUp",altKey:!0,description:"Jump to the previous buffer",execute:e=>{let t=sZ(e.state.buffers,e.state.activeBuffer,-1);t&&e.switchBuffer(t)}},{key:"ArrowDown",altKey:!0,description:"Jump to the next buffer",execute:e=>{let t=sZ(e.state.buffers,e.state.activeBuffer,1);t&&e.switchBuffer(t)}},{key:"k",ctrlKey:!0,description:"Switch to a buffer",execute:e=>{e.openDialog("switch")}}];function s1(e){let t=e.state.buffers.get(e.state.activeBuffer);if(!t)throw Error("Not connected to server");return e.clients.get(t.server)}function s2(e){let t=e.state.buffers.get(e.state.activeBuffer);if(!t||t.type!==sa.CHANNEL)throw Error("Not in a channel");return t.name}async function s3(e,t,s){let n=t[0];if(!n)throw Error("Missing nick");let r=s2(e),a=s1(e),i=(await a.whois(n))["311"].params,o=i[2],l=i[3];a.send({command:"MODE",params:[r,s,`*!${o}@${l}`]})}function s4(e){let t=e.state.buffers.get(e.state.activeBuffer);t&&t.type!==sa.SERVER&&e.setBufferState({server:t.server},e=>({unread:so.union(e.unread,so.MESSAGE)}))}const s5={usage:" [password]",description:"Join a channel",execute:(e,t)=>{let s=t[0];if(!s)throw Error("Missing channel name");t.length>1?e.open(s,null,t[1]):e.open(s)}},s6={usage:" [comment]",description:"Remove a user from the channel",execute:(e,t)=>{let s=t[0],n=[s2(e),s];t.length>1&&n.push(t.slice(1).join(" ")),s1(e).send({command:"KICK",params:n})}},s7={usage:"[nick]",description:"Ban a user from the channel, or display the current ban list",execute:(e,t)=>{if(0!=t.length)return s3(e,t,"+b");{let t=s2(e);s1(e).send({command:"MODE",params:[t,"+b"]})}}};function s9(e,t,s){let n=t[0];if(!n)throw Error("Missing nick");let r=s2(e);s1(e).send({command:"MODE",params:[r,s,n]})}var s8={away:{usage:"[message]",description:"Set away message",execute:(e,t)=>{let s=[];t.length&&s.push(t.join(" ")),s1(e).send({command:"AWAY",params:s})}},ban:s7,buffer:{usage:"",description:"Switch to a buffer",execute:(e,t)=>{let s=t[0];for(let t of e.state.buffers.values())if(t.name===s){e.switchBuffer(t);return}throw Error("Unknown buffer")}},close:{description:"Close the current buffer",execute:(e,t)=>{let s=e.state.buffers.get(e.state.activeBuffer);if(!s||s.type==sa.SERVER)throw Error("Not in a user or channel buffer");e.close(s.id)}},deop:{usage:"",description:"Remove operator status for a user on this channel",execute:(e,t)=>s9(e,t,"-o")},devoice:{usage:"",description:"Remove voiced status for a user on this channel",execute:(e,t)=>s9(e,t,"-v")},disconnect:{description:"Disconnect from the server",execute:(e,t)=>{e.disconnect()}},help:{description:"Show help menu",execute:(e,t)=>{e.openHelp()}},invite:{usage:"",description:"Invite a user to the channel",execute:(e,t)=>{let s=t[0];if(!s)throw Error("Missing nick");let n=s2(e);s1(e).send({command:"INVITE",params:[s,n]})}},j:s5,join:s5,kick:s6,kickban:{usage:"",description:"Ban a user and removes them from the channel",execute:(e,t)=>{s6.execute(e,t),s7.execute(e,t)}},lusers:{usage:"[ []]",description:"Request user statistics about the network",execute:(e,t)=>{s1(e).send({command:"LUSERS",params:t}),s4(e)}},me:{usage:"",description:"Send an action message to the current buffer",execute:(e,t)=>{let s=t.join(" "),n=function(e){let t=e.state.buffers.get(e.state.activeBuffer);if(!t)throw Error("Not in a buffer");return t.name}(e),r=`\x01ACTION ${s}\x01`;e.privmsg(n,r)}},mode:{usage:"[target] [modes] [mode args...]",description:"Query or change a channel or user mode",execute:(e,t)=>{let s=t[0];(!s||s.startsWith("+")||s.startsWith("-"))&&(t=[s2(e),...t]),s1(e).send({command:"MODE",params:t})}},motd:{usage:"[server]",description:"Get the Message Of The Day",execute:(e,t)=>{s1(e).send({command:"MOTD",params:t}),s4(e)}},msg:{usage:" ",description:"Send a message to a nickname or a channel",execute:(e,t)=>{let s=t[0],n=t.slice(1).join(" ");s1(e).send({command:"PRIVMSG",params:[s,n]})}},nick:{usage:"",description:"Change current nickname",execute:(e,t)=>{let s=t[0];s1(e).send({command:"NICK",params:[s]})}},notice:{usage:" ",description:"Send a notice to a nickname or a channel",execute:(e,t)=>{let s=t[0],n=t.slice(1).join(" ");s1(e).send({command:"NOTICE",params:[s,n]})}},op:{usage:"",description:"Give a user operator status on this channel",execute:(e,t)=>s9(e,t,"+o")},part:{usage:"[reason]",description:"Leave a channel",execute:(e,t)=>{let s=t.join(" "),n=[s2(e)];s&&n.push(s),s1(e).send({command:"PART",params:n})}},query:{usage:" [message]",description:"Open a buffer to send messages to a nickname",execute:(e,t)=>{let s=t[0];if(!s)throw Error("Missing nickname");if(e.open(s),t.length>1){let n=t.slice(1).join(" ");e.privmsg(s,n)}}},quiet:{usage:"[nick]",description:"Quiet a user in the channel, or display the current quiet list",execute:(e,t)=>{if(0!=t.length)return s3(e,t,"+q");s1(e).send({command:"MODE",params:[s2(e),"+q"]})}},quit:{description:"Quit",execute:(e,t)=>{e.close({name:"*"})}},quote:{usage:"",description:"Send a raw IRC command to the server",execute:(e,t)=>{let s;try{s=tD(t.join(" "))}catch(e){throw Error("Failed to parse IRC command: "+e.message)}s1(e).send(s)}},reconnect:{description:"Reconnect to the server",execute:(e,t)=>{e.reconnect()}},setname:{usage:"",description:"Change current realname",execute:(e,t)=>{let s=t.join(" "),n=s1(e);if(!n.caps.enabled.has("setname"))throw Error("Server doesn't support changing the realname");n.send({command:"SETNAME",params:[s]})}},stats:{usage:" [server]",description:"Request server statistics",execute:(e,t)=>{let s=t[0];if(!s)throw Error("Missing query");let n=[s];t.length>1&&n.push(t.slice(1).join(" ")),s1(e).send({command:"STATS",params:n}),s4(e)}},topic:{usage:"",description:"Change the topic of the current channel",execute:(e,t)=>{let s=[s2(e)];t.length>0&&s.push(t.join(" ")),s1(e).send({command:"TOPIC",params:s})}},unban:{usage:"",description:"Remove a user from the ban list",execute:(e,t)=>s3(e,t,"-b")},unquiet:{usage:"",description:"Remove a user from the quiet list",execute:(e,t)=>s3(e,t,"-q")},voice:{usage:"",description:"Give a user voiced status on this channel",execute:(e,t)=>s9(e,t,"+v")},who:{usage:"",description:"Retrieve a list of users",execute:(e,t)=>{s1(e).send({command:"WHO",params:t}),s4(e)}},whois:{usage:"",description:"Retrieve information about a user",execute:(e,t)=>{let s=t[0];if(!s)throw Error("Missing nick");s1(e).send({command:"WHOIS",params:[s]}),s4(e)}},whowas:{usage:" [count]",description:"Retrieve information about an offline user",execute:(e,t)=>{if(t.length<1)throw Error("Missing nick");s1(e).send({command:"WHOWAS",params:t}),s4(e)}},list:{usage:"[filter]",description:"Retrieve a list of channels from a network",execute:(e,t)=>{s1(e).send({command:"LIST",params:t}),s4(e)}}};function ne(){let e=s0.map(e=>{let t=[];return e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),t.push(e.key),t=t.map((e,t)=>tS` ${t>0?"+":null} ${e} `),tS`
    ${t}
    ${e.description}
    `});return e.push(tS`
    Tab
    Automatically complete nickname or channel
    `),window.matchMedia("(pointer: none)").matches||e.push(tS`
    Middle mouse click
    Close buffer
    `),tS`
    ${e}
    `}function nt(){let e=Object.keys(s8).map(e=>{let t=s8[e],s=[tS`/${e}`];return t.usage&&s.push(" "+t.usage),tS`
    ${s}
    ${t.description}
    `});return tS`
    ${e}
    `}function ns(){return tS`

    Key bindings

    <${ne}/>

    Commands

    <${nt}/> `}const nn={name:"",host:"",port:6697,nickname:"",username:"",realname:"",pass:""};class nr extends I{prevParams=null;state={...nn,autojoin:!0};constructor(e){super(e),this.prevParams={...nn},this.handleInput=this.handleInput.bind(this),this.handleSubmit=this.handleSubmit.bind(this),e.params&&Object.keys(nn).forEach(t=>{void 0!==e.params[t]&&(this.state[t]=e.params[t],this.prevParams[t]=e.params[t])})}handleInput(e){let t=e.target,s="checkbox"==t.type?t.checked:t.value;this.setState({[t.name]:s})}handleSubmit(e){e.preventDefault();let t={};Object.keys(nn).forEach(e=>{(this.props.isNew||this.prevParams[e]!=this.state[e])&&(this.props.isNew&&nn[e]==this.state[e]||(t[e]=this.state[e]))});let s=this.state.autojoin?this.props.autojoin:null;this.props.onSubmit(t,s)}render(){let e=null;this.props.isNew||(e=tS` `);let t=null;return this.props.autojoin&&(t=tS`

    `),tS`


    ${t}
    Advanced options












    ${e} ${" "}
    `}}class na extends I{state={username:"",password:""};constructor(e){super(e),this.handleInput=this.handleInput.bind(this),this.handleSubmit=this.handleSubmit.bind(this),e.username&&(this.state.username=e.username)}handleInput(e){let t=e.target,s="checkbox"==t.type?t.checked:t.value;this.setState({[t.name]:s})}handleSubmit(e){e.preventDefault(),this.props.onSubmit(this.state.username,this.state.password)}render(){return tS`




    `}}class ni extends I{state={email:"",password:""};constructor(e){super(e),this.handleInput=this.handleInput.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}handleInput(e){let t=e.target,s="checkbox"==t.type?t.checked:t.value;this.setState({[t.name]:s})}handleSubmit(e){e.preventDefault(),this.props.onSubmit(this.state.email,this.state.password)}render(){return tS`




    `}}class no extends I{state={code:""};constructor(e){super(e),this.handleInput=this.handleInput.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}handleInput(e){let t=e.target,s="checkbox"==t.type?t.checked:t.value;this.setState({[t.name]:s})}handleSubmit(e){e.preventDefault(),this.props.onSubmit(this.state.code)}render(){return tS`

    Your account ${this.props.account} has been created, but a verification code is required to complete the registration.

    ${st(this.props.message)}



    `}}class nl extends I{state={};constructor(e){super(e),this.state.secondsInTimestamps=e.settings.secondsInTimestamps,this.state.bufferEvents=e.settings.bufferEvents,this.handleInput=this.handleInput.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}handleInput(e){let t=e.target,s="checkbox"==t.type?t.checked:t.value;this.setState({[t.name]:s},()=>{this.props.onChange(this.state)})}handleSubmit(e){e.preventDefault(),this.props.onClose()}registerProtocol(){let e=window.location.origin+window.location.pathname+"?open=%s";try{navigator.registerProtocolHandler("irc",e),navigator.registerProtocolHandler("ircs",e)}catch(e){console.error("Failed to register protocol handler: ",e)}}render(){let e=null;return this.props.showProtocolHandler&&(e=tS`
    Set gamja as your default IRC client for this browser. IRC links will be automatically opened here.


    `),tS`






    ${e}
    `}}class nc extends I{constructor(e){super(e),this.handleClick=this.handleClick.bind(this)}handleClick(e){e.preventDefault(),this.props.onClick()}render(){let e=this.props.selected?"selected":"";return tS`
  • ${sd(this.props.server,this.props.bouncerNetwork)} ${this.props.buffer.name}
  • `}}function nu(e,t){return e.toLowerCase().includes(t)?1:0}class nh extends I{state={query:"",selected:0};constructor(e){super(e),this.handleInput=this.handleInput.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this)}getSuggestions(){let e=this.state.query.toLowerCase(),t=[],s=new Map;for(let n of this.props.buffers.values()){if(n.type===sa.SERVER)continue;let r=0;if(""!==e){let t=this.props.servers.get(n.server);if(!(r=function(e,t,s){let n=2*nu(e.name,s);switch(e.type){case sa.CHANNEL:n+=nu(e.topic||"",s);break;case sa.NICK:let r=t.users.get(e.name);r&&r.realname&&tz(r.realname,e.name)&&(n+=nu(r.realname,s))}return n}(n,t,e)))continue}s.set(n.id,r),t.push(n)}return t.sort((e,t)=>s.get(t.id)-s.get(e.id)),t.slice(0,20)}handleInput(e){let t=e.target;this.setState({[t.name]:t.value})}handleSubmit(e){e.preventDefault(),this.props.onSubmit(this.getSuggestions()[this.state.selected])}handleKeyUp(e){switch(e.key){case"ArrowUp":e.stopPropagation(),this.move(-1);break;case"ArrowDown":e.stopPropagation(),this.move(1)}}move(e){let t=this.getSuggestions().length;this.setState(s=>({selected:(s.selected+e+t)%t}))}render(){let e=this.getSuggestions().map((e,t)=>{let s=this.props.servers.get(e.server),n=null;return s.bouncerNetID&&(n=this.props.bouncerNetworks.get(s.bouncerNetID)),tS` <${nc} buffer=${e} server=${s} bouncerNetwork=${n} selected=${this.state.selected===t} onClick=${()=>this.props.onSubmit(e)} /> `});return tS`
      ${e}
    `}}class np extends I{state={text:""};textInput=$();lastAutocomplete=null;constructor(e){super(e),this.handleInput=this.handleInput.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleInputKeyDown=this.handleInputKeyDown.bind(this),this.handleInputPaste=this.handleInputPaste.bind(this),this.handleDragOver=this.handleDragOver.bind(this),this.handleDrop=this.handleDrop.bind(this),this.handleWindowKeyDown=this.handleWindowKeyDown.bind(this),this.handleWindowPaste=this.handleWindowPaste.bind(this)}handleInput(e){this.setState({[e.target.name]:e.target.value}),this.props.readOnly&&"text"===e.target.name&&!e.target.value&&e.target.blur()}handleSubmit(e){e.preventDefault(),this.props.onSubmit(this.state.text),this.setState({text:""})}handleInputKeyDown(e){let t,s=e.target;if(!this.props.autocomplete||"Tab"!==e.key||s.selectionStart!==s.selectionEnd)return;e.preventDefault();let n=s.selectionStart,r=this.state.text;if(this.lastAutocomplete&&this.lastAutocomplete.text===r&&this.lastAutocomplete.carretPos===n)t=this.lastAutocomplete;else{let e,a;for(this.lastAutocomplete=null,e=n-1;e>=0&&" "!==r[e];e--);for(e++,a=n;ae.text?{text:e.text+" "+s.join(" ")}:{text:s.join(" ")})}async handleInputPaste(e){0!==e.clipboardData.files.length&&this.canUploadFiles()&&(e.preventDefault(),e.stopImmediatePropagation(),await this.uploadFileList(e.clipboardData.files))}handleDragOver(e){if(0!==e.dataTransfer.items.length&&this.canUploadFiles()){for(let t of e.dataTransfer.items)if("file"!==t.kind)return;e.preventDefault()}}async handleDrop(e){0!==e.dataTransfer.files.length&&this.canUploadFiles()&&(e.preventDefault(),e.stopImmediatePropagation(),await this.uploadFileList(e.dataTransfer.files))}handleWindowKeyDown(e){if(document.activeElement&&document.activeElement!==document.body)switch(document.activeElement.tagName.toLowerCase()){case"section":case"a":break;default:return}e.altKey||e.ctrlKey||e.metaKey||1!=[...e.key].length||this.state.text||this.props.readOnly||this.props.commandOnly&&"/"!==e.key||(e.preventDefault(),this.setState({text:e.key},()=>{this.focus()}))}handleWindowPaste(e){if(document.activeElement!==document.body&&"SECTION"!==document.activeElement.tagName||this.props.readOnly||!this.textInput.current)return;if(e.clipboardData.files.length>0){this.handleInputPaste(e);return}let t=e.clipboardData.getData("text");e.preventDefault(),e.stopImmediatePropagation(),this.textInput.current.focus(),this.textInput.current.setRangeText(t,void 0,void 0,"end"),this.setState({text:this.textInput.current.value})}componentDidMount(){window.addEventListener("keydown",this.handleWindowKeyDown),window.addEventListener("paste",this.handleWindowPaste)}componentWillUnmount(){window.removeEventListener("keydown",this.handleWindowKeyDown),window.removeEventListener("paste",this.handleWindowPaste)}focus(){this.textInput.current&&(document.activeElement.blur(),this.textInput.current.focus())}render(){let e="";this.props.readOnly&&!this.state.text&&(e="read-only");let t="Type a message";return this.props.commandOnly&&(t="Type a command (see /help)"),tS`
    `}}let nd=new Map;class nm extends I{constructor(e){super(e),this.handleScroll=this.handleScroll.bind(this)}isAtBottom(){let e=this.props.target.current;return 10>=Math.abs(e.scrollHeight-e.clientHeight-e.scrollTop)}saveScrollPosition(e){let t=this.props.target.current,s=t.querySelectorAll(this.props.stickTo),n=null;if(!this.isAtBottom())for(let e=0;e=t.scrollTop+t.offsetTop){n=r.dataset.key;break}}nd.set(e,n)}restoreScrollPosition(){let e=this.props.target.current;if(!e.firstChild)return;let t=nd.get(this.props.scrollKey);if(t){let s=e.querySelector('[data-key="'+t+'"]');s&&s.scrollIntoView()}else e.firstChild.scrollIntoView({block:"end"});0==e.scrollTop&&this.props.onScrollTop()}handleScroll(){0==this.props.target.current.scrollTop&&this.props.onScrollTop()}componentDidMount(){this.restoreScrollPosition(),this.props.target.current.addEventListener("scroll",this.handleScroll)}getSnapshotBeforeUpdate(e){(this.props.scrollKey!==e.scrollKey||this.props.children!==e.children)&&this.saveScrollPosition(e.scrollKey)}componentDidUpdate(e){this.props.target.current&&this.restoreScrollPosition()}componentWillUnmount(){this.props.target.current.removeEventListener("scroll",this.handleScroll),this.saveScrollPosition(this.props.scrollKey)}render(){return this.props.children}}class nf extends I{body=$();constructor(e){super(e),this.handleCloseClick=this.handleCloseClick.bind(this),this.handleBackdropClick=this.handleBackdropClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}dismiss(){this.props.onDismiss()}handleCloseClick(e){e.preventDefault(),this.dismiss()}handleBackdropClick(e){"dialog"==e.target.className&&this.dismiss()}handleKeyDown(e){"Escape"==e.key&&this.dismiss()}componentDidMount(){window.addEventListener("keydown",this.handleKeyDown);let e=this.body.current.querySelector("input[autofocus]");e&&e.focus()}componentWillUnmount(){window.removeEventListener("keydown",this.handleKeyDown)}render(){return tS`

    ${this.props.title}

    ${this.props.children}
    `}}const ng={server:{}},nb=fetch("./config.json").then(e=>e.ok?e.json():(404!==e.status&&console.error("Failed to fetch config: HTTP error:",e.status,e.statusText),{})).catch(e=>(console.error("Failed to fetch config:",e),{})).then(e=>({...ng,...e}));function nk(e,t){return e&&e.receipts?e.receipts[sl.READ]:null}let nv=0;class nw extends I{state={...sS.create(),connectParams:{url:null,pass:null,username:null,realname:null,nick:null,saslPlain:null,saslExternal:!1,autoconnect:!1,autojoin:[],ping:0},connectForm:!0,loading:!0,dialog:null,dialogData:null,error:null,openPanels:{bufferList:!1,memberList:!1}};debug=!function(){try{return!0}catch(e){return!1}}();config={...ng};clients=new Map;endOfHistory=new Map;receipts=new Map;buffer=$();composer=$();switchToChannel=null;autoOpenURL=null;messageNotifications=new Set;baseTitle=null;lastFocusPingDate=null;constructor(e){super(e),this.handleConnectSubmit=this.handleConnectSubmit.bind(this),this.handleJoinSubmit=this.handleJoinSubmit.bind(this),this.handleBufferListClick=this.handleBufferListClick.bind(this),this.handleBufferListClose=this.handleBufferListClose.bind(this),this.toggleBufferList=this.toggleBufferList.bind(this),this.toggleMemberList=this.toggleMemberList.bind(this),this.handleComposerSubmit=this.handleComposerSubmit.bind(this),this.handleChannelClick=this.handleChannelClick.bind(this),this.handleNickClick=this.handleNickClick.bind(this),this.autocomplete=this.autocomplete.bind(this),this.handleBufferScrollTop=this.handleBufferScrollTop.bind(this),this.dismissDialog=this.dismissDialog.bind(this),this.handleAddNetworkClick=this.handleAddNetworkClick.bind(this),this.handleNetworkSubmit=this.handleNetworkSubmit.bind(this),this.handleNetworkRemove=this.handleNetworkRemove.bind(this),this.handleDismissError=this.handleDismissError.bind(this),this.handleAuthSubmit=this.handleAuthSubmit.bind(this),this.handleRegisterSubmit=this.handleRegisterSubmit.bind(this),this.handleVerifyClick=this.handleVerifyClick.bind(this),this.handleVerifySubmit=this.handleVerifySubmit.bind(this),this.handleOpenSettingsClick=this.handleOpenSettingsClick.bind(this),this.handleSettingsChange=this.handleSettingsChange.bind(this),this.handleSettingsDisconnect=this.handleSettingsDisconnect.bind(this),this.handleSwitchSubmit=this.handleSwitchSubmit.bind(this),this.handleWindowFocus=this.handleWindowFocus.bind(this),this.state.settings={...this.state.settings,...sI.load()},this.bufferStore=new sR,nb.then(e=>(this.handleConfig(e),e))}async handleConfig(e){let t,s,n={...this.state.connectParams};"string"==typeof e.server.url&&(n.url=e.server.url),Array.isArray(e.server.autojoin)?n.autojoin=e.server.autojoin:"string"==typeof e.server.autojoin&&(n.autojoin=[e.server.autojoin]),"string"==typeof e.server.nick&&(n.nick=e.server.nick),"boolean"==typeof e.server.autoconnect&&(n.autoconnect=e.server.autoconnect),"external"===e.server.auth&&(n.saslExternal=!0),"number"==typeof e.server.ping&&(n.ping=e.server.ping),n.autoconnect&&"mandatory"===e.server.auth&&(console.error('Error in config.json: cannot set server.autoconnect = true and server.auth = "mandatory"'),n.autoconnect=!1),"oauth2"!==e.server.auth||e.oauth2&&e.oauth2.url&&e.oauth2.client_id||(console.error('Error in config.json: server.auth = "oauth2" requires oauth2 settings'),e.server.auth=null);let r=s$.load();r&&(n={...n,...r,autoconnect:!0,autojoin:[]});let a=[],i=(t=window.location.search.substring(1),s={},t.split("&").forEach(e=>{if(!e)return;let t=e.split("=");s[decodeURIComponent(t[0])]=decodeURIComponent(t[1]||"")}),s);if("string"!=typeof i.server||n.url&&i.server||(n.url=i.server,e.server.auth=null),"string"==typeof i.nick&&(n.nick=i.nick),"string"==typeof i.channels&&(a=i.channels.split(",")),"string"==typeof i.open&&(this.autoOpenURL=tq(i.open)),"1"===i.debug&&(this.debug=!0),window.location.hash&&(a=window.location.hash.split(",")),this.config=e,!n.nick&&n.autoconnect&&(n.nick="user-*"),n.nick&&n.nick.includes("*")){let e=Math.random().toString(36).substr(2,7);n.nick=n.nick.replace("*",e)}if("oauth2"===e.server.auth&&!n.saslOauthBearer){let e;if(i.error){console.error("OAuth 2.0 authorization failed: ",i.error),this.showError("Authentication failed: "+(i.error_description||i.error));return}if(!i.code){this.redirectOauth2Authorize();return}let t=new URL(window.location.toString());t.searchParams.delete("code"),t.searchParams.delete("state"),window.history.replaceState(null,"",t.toString());try{e=await this.exchangeOauth2Code(i.code)}catch(e){this.showError(e);return}n.saslOauthBearer=e,e.username&&!n.nick&&(n.nick=e.username)}a.length>0&&(n.autoconnect?this.autoOpenURL={host:"",entity:a[0]}:n.autojoin=a),this.setState({loading:!1,connectParams:n}),n.autoconnect&&(this.setState({connectForm:!1}),this.connect(n))}async redirectOauth2Authorize(){let e;try{e=await t6(this.config.oauth2.url)}catch(e){console.error("Failed to fetch OAuth 2.0 server metadata:",e),this.showError("Failed to fetch OAuth 2.0 server metadata");return}!function({serverMetadata:e,clientId:t,redirectUri:s,scope:n}){let r={response_type:"code",client_id:t,redirect_uri:s};n&&(r.scope=n),window.location.assign(e.authorization_endpoint+"?"+t5(r))}({serverMetadata:e,clientId:this.config.oauth2.client_id,redirectUri:window.location.toString(),scope:this.config.oauth2.scope})}async exchangeOauth2Code(e){let t=await t6(this.config.oauth2.url),s=new URL(window.location.toString());s.searchParams.delete("code"),s.searchParams.delete("state");let n=(await t9({serverMetadata:t,redirectUri:s.toString(),code:e,clientId:this.config.oauth2.client_id,clientSecret:this.config.oauth2.client_secret})).access_token,r=null;if(t.introspection_endpoint)try{(r=(await t8({serverMetadata:t,token:n,clientId:this.config.oauth2.client_id,clientSecret:this.config.oauth2.client_secret})).username)||console.warn("Username missing from OAuth 2.0 token introspection response")}catch(e){console.warn("Failed to introspect OAuth 2.0 token:",e)}return{token:n,username:r}}showError(e){let t;if(console.error("App error: ",e),e instanceof Error){let s=[];for(;e;)s.push(e.message),e=e.cause;t=s.join(": ")}else t=String(e);return this.setState({error:t}),++nv}dismissError(e){e&&e!==nv||this.setState({error:null})}handleDismissError(e){e.preventDefault(),this.dismissError()}setServerState(e,t,s){this.setState(s=>sS.updateServer(s,e,t),s)}setBufferState(e,t,s){this.setState(s=>sS.updateBuffer(s,e,t),s)}syncBufferUnread(e,t){let s=this.clients.get(e),n=this.bufferStore.get({name:t,server:s.params});s.caps.enabled.has("draft/chathistory")&&n&&this.setBufferState({server:e,name:t},{unread:n.unread},()=>{this.updateDocumentTitle()}),this.bufferStore.put({name:t,server:s.params,closed:!1})}createBuffer(e,t){let s=this.clients.get(e),n=null,r=!1;return this.setState(a=>{let i;return[n,i]=sS.createBuffer(a,t,e,s),r=!!i,i}),r&&this.syncBufferUnread(e,t),n}sendReadReceipt(e,t){if(!e.supportsReadMarker())return;let s=t.receipts[sl.READ];"*"!==t.name&&s&&e.setReadMarker(t.name,s.time)}switchBuffer(e){let t;this.setState(s=>{if(!(t=sS.getBuffer(s,e)))return;let n=this.clients.get(t.server),r=nk(this.bufferStore.get({name:t.name,server:n.params}),sl.READ),a=sS.updateBuffer(s,t.id,{prevReadReceipt:r});return{activeBuffer:t.id,...a}},()=>{if(!t)return;this.buffer.current&&this.buffer.current.focus();let e=this.state.servers.get(t.server);t.type!==sa.NICK||e.users.has(t.name)||this.whoUserBuffer(t.name,t.server),t.type!==sa.CHANNEL||t.hasInitialWho||this.whoChannelBuffer(t.name,t.server),this.updateDocumentTitle()}),this.markBufferAsRead(e)}markBufferAsRead(e){let t;this.setState(s=>{if(t=sS.getBuffer(s,e))return sS.updateBuffer(s,t.id,{unread:so.NONE})},()=>{if(!t)return;let e=this.clients.get(t.server);for(let s of this.messageNotifications)e.cm(s.data.bufferName)===e.cm(t.name)&&s.close();if(t.messages.length>0){let s=t.messages[t.messages.length-1],n={name:t.name,server:e.params,unread:so.NONE,receipts:{[sl.READ]:sm(s)}};this.bufferStore.put(n)&&this.sendReadReceipt(e,n)}this.updateDocumentTitle()})}updateDocumentTitle(){let e,t,s=sS.getBuffer(this.state,this.state.activeBuffer);s&&(e=this.state.servers.get(s.server)),e.bouncerNetID&&(t=this.state.bouncerNetworks.get(e.bouncerNetID));let n=0;for(let e of this.state.buffers.values())so.compare(e.unread,so.HIGHLIGHT)>=0&&n++;let r=[];s&&s.type!==sa.SERVER&&r.push(s.name),t&&r.push(sd(e,t)),r.push(this.baseTitle);let a="";n>0&&(a=`(${n}) `),a+=r.join(" · "),document.title=a}prepareChatMessage(e,t){if(void 0===t.isHighlight){let s=this.clients.get(e);t.isHighlight=function(e,t,s){if("PRIVMSG"!=e.command&&"NOTICE"!=e.command||(t=s(t),e.prefix&&s(e.prefix.name)==t))return!1;let n=s(e.params[1]);for(;;){let e=n.indexOf(t);if(e<0)return!1;let s="\0",r="\0";if(e>0&&(s=n[e-1]),e+t.length=0;t--)if(tM.test(e[t])){e=e.slice(t);break}let t=e.indexOf("://");if(t<=0)return!1;let s=e[t-1];switch(s){case"+":case"-":case".":return!0;default:return tL.test(s)}}(n.slice(0,e)))return!0;n=n.slice(e+t.length)}}(t,s.nick,s.cm)||("PRIVMSG"==t.command||"NOTICE"==t.command)&&t.params[0].startsWith("$")}t.tags||(t.tags={}),t.tags.time||(t.tags.time=tH(new Date))}addChatMessage(e,t,s){this.prepareChatMessage(e,s);let n={server:e,name:t};this.setState(e=>sS.addMessage(e,s,n))}handleChatMessage(e,t,s){let n=this.clients.get(e);this.prepareChatMessage(e,s);let r=this.bufferStore.get({name:t,server:n.params}),a=nk(r,sl.DELIVERED),i=nk(r,sl.READ),o=sg(s,a),l=sg(s,i);n.isMyNick(s.prefix.name)&&(l=!0);let c=so.NONE;if(("PRIVMSG"==s.command||"NOTICE"==s.command)&&!l){let r,a=s.params[0],i=s.params[1];if(s.isHighlight?(c=so.HIGHLIGHT,r="highlight"):n.isMyNick(a)?(c=so.HIGHLIGHT,r="private message"):c=so.MESSAGE,c==so.HIGHLIGHT&&!o&&!tj(s)){let a="New "+r+" from "+s.prefix.name;n.isChannel(t)&&(a+=" in "+t);let o=function(e,t){if(!window.Notification||"granted"!==Notification.permission)return null;try{return new Notification(e,t)}catch(e){return console.error("Failed to show notification: ",e),null}}(a,{body:sr(i),requireInteraction:!0,tag:"msg,server="+e+",from="+s.prefix.name+",to="+t,data:{bufferName:t,message:s}});o&&(o.addEventListener("click",()=>{this.switchBuffer({server:e,name:t})}),o.addEventListener("close",()=>{this.messageNotifications.delete(o)}),this.messageNotifications.add(o))}}if("INVITE"===s.command&&n.isMyNick(s.params[0])){c=so.HIGHLIGHT;let r=s.params[1],a=new Notification("Invitation to "+r,{body:s.prefix.name+" has invited you to "+r,requireInteraction:!0,tag:"invite,server="+e+",from="+s.prefix.name+",channel="+r,actions:[{action:"accept",title:"Accept"}]});a&&a.addEventListener("click",a=>{if("accept"===a.action){let a={name:t,server:n.params,receipts:{[sl.READ]:sm(s)}};this.bufferStore.put(a)&&this.sendReadReceipt(n,a),this.open(r,e)}else this.switchBuffer({server:e,name:t})})}(!n.isMyNick(s.prefix.name)||n.isMyNick(t))&&"PART"!=s.command&&"QUIT"!=s.comand&&"730"!=s.command&&"731"!=s.command&&this.createBuffer(e,t);let u={server:e,name:t};this.setState(e=>sS.addMessage(e,s,u)),this.setBufferState(u,e=>{let t=e.unread,r=e.prevReadReceipt,a={[sl.DELIVERED]:sm(s)};this.state.activeBuffer===e.id&&document.hasFocus()?a[sl.READ]=sm(s):t=so.union(t,c),n.isMyNick(s.prefix.name)&&!sg(s,r)&&(r=sm(s));let i={name:e.name,server:n.params,unread:t,receipts:a};return this.bufferStore.put(i)&&this.sendReadReceipt(n,i),{unread:t,prevReadReceipt:r}},()=>{c===so.HIGHLIGHT&&this.updateDocumentTitle()})}connect(e){var t;let s,n,r;e={...this.state.connectParams,...e};let a=null;this.setState(e=>{let t;return[a,t]=sS.createServer(e),t}),this.setState({connectParams:e});let i=new t4({...(t=e,s=window.location.host||"localhost:8080",n="wss:","https:"!=window.location.protocol&&(n="ws:"),r=window.location.pathname||"/",window.location.host||(r="/"),(t={...t}).url||(t.url=n+"//"+s+r+"socket"),t.url.startsWith("/")&&(t.url=n+"//"+s+t.url),0>t.url.indexOf("://")&&(t.url=n+"//"+t.url),t.username||(t.username=t.nick),t.realname||(t.realname=t.nick),t),eventPlayback:this.state.settings.bufferEvents!==sc.HIDE});i.debug=this.debug,this.clients.set(a,i),this.setServerState(a,{status:i.status});let o=null;i.addEventListener("status",()=>{switch(this.setServerState(a,{status:i.status}),i.status){case t4.Status.DISCONNECTED:this.setServerState(a,{account:null}),this.setState(e=>{let t=new Map(e.buffers);return e.buffers.forEach(e=>{e.server===a&&t.set(e.id,{...e,joined:!1})}),{buffers:t}});break;case t4.Status.REGISTERED:this.setState({connectForm:!1}),o&&this.dismissError(o)}}),i.addEventListener("message",e=>{this.handleMessage(a,e.detail.message)}),i.addEventListener("error",e=>{o=this.showError(e.detail)}),this.createBuffer(a,"*"),this.state.activeBuffer||this.switchBuffer({server:a,name:"*"}),e.autojoin.length>0&&(this.switchToChannel=e.autojoin[0])}disconnect(e){e||(e=sS.getActiveServerID(this.state));let t=this.clients.get(e);t&&(this.clients.delete(e),t.disconnect())}reconnect(e){e||(e=sS.getActiveServerID(this.state));let t=this.clients.get(e);t&&t.reconnect()}serverFromBouncerNetwork(e){for(let[t,s]of this.clients)if(s.params.bouncerNetwork===e)return t;return null}routeMessage(e,t){let s,n,r,a=this.clients.get(e),i=tV(t,"chathistory");if(t.internal)return[];switch(t.command){case"MODE":if(s=t.params[0],a.isChannel(s))return[s];return["*"];case"NOTICE":case"PRIVMSG":if(s=t.params[0],a.isMyNick(s)){if(a.cm(t.prefix.name)===a.cm(a.serverPrefix.name))s="*";else{let n=t.tags["+draft/channel-context"];s=n&&a.isChannel(n)&&sS.getBuffer(this.state,{server:e,name:n})?n:t.prefix.name}}let o=a.isupport.statusMsg();if(o){let e=tA(s,o);a.isChannel(e.name)&&(s=e.name)}let l=!0;if("PRIVMSG"!==t.command)l=!1;else{let e=tj(t);e&&"ACTION"!==e.command&&(l=!1)}return l||sS.getBuffer(this.state,{server:e,name:s})||(s="*"),[s];case"JOIN":if(n=t.params[0],!a.isMyNick(t.prefix.name))return[n];return[];case"PART":case"KICK":case"TOPIC":return[n=t.params[0]];case"QUIT":return r=[],i?r.push(i.params[0]):this.state.buffers.forEach(s=>{s.server==e&&s.members.has(t.prefix.name)&&r.push(s.name)}),r;case"NICK":let c=t.params[0];return r=[],i?r.push(i.params[0]):(this.state.buffers.forEach(s=>{s.server==e&&s.members.has(t.prefix.name)&&r.push(s.name)}),a.isMyNick(c)&&r.push("*")),r;case"INVITE":let u=n=t.params[1];return sS.getBuffer(this.state,{server:e,name:n})||(u="*"),[u];case"324":case"329":case"346":case"347":case"348":case"349":case"367":case"368":case"728":case"729":return[n=t.params[1]];case"341":return[n=t.params[2]];case"730":case"731":let h=t.params[1].split(",");for(let e of(r=[],h)){let t=tT(e);r.push(t.name)}return r;case"002":case"004":case"005":case"376":case"422":case"301":case"331":case"332":case"333":case"353":case"366":case"903":case"328":case"AWAY":case"SETNAME":case"CHGHOST":case"ACCOUNT":case"CAP":case"AUTHENTICATE":case"PING":case"PONG":case"BATCH":case"TAGMSG":case"CHATHISTORY":case"ACK":case"BOUNCER":case"MARKREAD":return[];default:return["*"]}}handleMessage(e,t){let s,n,r,a=this.clients.get(e);if(tV(t,"chathistory"))return;let i=this.routeMessage(e,t);switch(this.setState(s=>sS.handleMessage(s,t,e,a)),t.command){case"001":this.fetchBacklog(e);break;case"376":case"422":let o=[];for(let t of this.bufferStore.list(a.params))if("*"!==t.name&&!t.closed){if(a.isChannel(t.name)){if(a.caps.enabled.has("soju.im/bouncer-networks"))continue;o.push(t.name)}else this.createBuffer(e,t.name),this.whoUserBuffer(t.name,e)}let l=this.state.servers.get(e).bouncerNetID,c=null;l&&(c=this.state.bouncerNetworks.get(l)),c&&"connected"!==c.state||(o=o.concat(a.params.autojoin),a.params.autojoin=[]),o.length>0&&a.send({command:"JOIN",params:[o.join(",")]});let u=c?c.host:"";this.autoOpenURL&&u===this.autoOpenURL.host&&(this.openURL(this.autoOpenURL),this.autoOpenURL=null);break;case"JOIN":n=t.params[0],a.isMyNick(t.prefix.name)&&this.syncBufferUnread(e,n),n==this.switchToChannel&&(this.switchBuffer({server:e,name:n}),this.switchToChannel=null);break;case"BOUNCER":if("NETWORK"!==t.params[0]||a.isupport.bouncerNetID())break;let h=t.params[1],p=null;"*"!==t.params[2]&&(p=t_(t.params[2]));let d=!1;this.setState(e=>p?(d=!e.bouncerNetworks.has(h),sS.storeBouncerNetwork(e,h,p)):sS.deleteBouncerNetwork(e,h),()=>{if(p)d&&this.connect({...a.params,bouncerNetwork:h});else{let e=this.serverFromBouncerNetwork(h);e&&this.close({server:e,name:"*"})}if(p&&"connected"===p.state){let e=this.serverFromBouncerNetwork(h),t=this.clients.get(e);t&&t.status===t4.Status.REGISTERED&&t.params.autojoin&&t.params.autojoin.length>0&&(t.send({command:"JOIN",params:[t.params.autojoin.join(",")]}),t.params.autojoin=[])}});break;case"BATCH":if(!t.params[0].startsWith("-"))break;let m=t.params[0].slice(1),f=a.batches.get(m);if(!f||"soju.im/bouncer-networks"!==f.type)break;this.autoOpenURL&&this.autoOpenURL.host&&!this.findBouncerNetIDByHost(this.autoOpenURL.host)&&(this.openURL(this.autoOpenURL),this.autoOpenURL=null);break;case"MARKREAD":s=t.params[0];let g=t.params[1];if("*"===g||!g.startsWith("timestamp="))break;let b={time:g.replace("timestamp=","")};if(sf(b,nk(this.bufferStore.get({name:s,server:a.params}),sl.READ)))break;for(let e of this.messageNotifications)a.cm(e.data.bufferName)===a.cm(s)&&sg(e.data.message,b)&&e.close();let k=!0;this.setBufferState({server:e,name:s},e=>{k=!1,r=so.NONE;for(let t=e.messages.length-1;t>=0;t--){let s=e.messages[t];if("PRIVMSG"===s.command||"NOTICE"===s.command){if(sg(s,b))break;if(s.isHighlight||a.isMyNick(e.name)){r=so.HIGHLIGHT;break}r=so.MESSAGE}}return{unread:r}},()=>{this.bufferStore.put({name:s,server:a.params,unread:r,closed:k,receipts:{[sl.READ]:b}}),this.updateDocumentTitle()});break;default:if(tB(t.command)&&"422"!=t.command){let e=t.params[t.params.length-1];this.showError(e)}}i.forEach(s=>{this.handleChatMessage(e,s,t)})}async fetchBacklog(e){let t=this.clients.get(e);if(!t.caps.enabled.has("draft/chathistory")||t.caps.enabled.has("soju.im/bouncer-networks")&&!t.params.bouncerNetwork)return;let s=function(e,t,s){let n=e.list(t),r=null;for(let e of n){if("*"===e.name)continue;let t=nk(e,s);sf(r,t)&&(r=t)}return r}(this.bufferStore,t.params,sl.DELIVERED);if(!s)return;let n=tH(new Date);(await t.fetchHistoryTargets(n,s.time)).forEach(async r=>{let a,i=s,o=nk(this.bufferStore.get({name:r.name,server:t.params}),sl.READ);sf(i,o)&&(i=o);let l=sS.getBuffer(this.state,{server:e,name:r.name});l&&l.messages.length>0&&(i=sm(l.messages[l.messages.length-1])),t.supportsReadMarker()&&t.isNick(r.name)&&t.fetchReadMarker(r.name);try{a=await t.fetchHistoryBetween(r.name,i,{time:n},4e3)}catch(e){console.error("Failed to fetch backlog for '"+r.name+"': ",e),this.showError("Failed to fetch backlog for '"+r.name+"'");return}for(let t of a.messages)for(let s of this.routeMessage(e,t))this.handleChatMessage(e,s,t)})}handleConnectSubmit(e){this.dismissError(),e.autoconnect?s$.put(e):s$.put(null);let t=this.state.buffers.get(this.state.activeBuffer);t&&this.close(t.server),this.connect(e)}handleChannelClick(e){this.openURL(e.target.href)&&e.preventDefault()}findBouncerNetIDByHost(e){for(let[t,s]of this.state.bouncerNetworks)if(s.host===e)return t;return null}openURL(e){var t;let s,n,r,a;if("string"==typeof e&&(e=tq(e)),!e)return!1;let{host:i,port:o}=(n=t=e.host,r=null,(a=t.lastIndexOf(":"))>0&&!t.endsWith("]")&&(n=t.slice(0,a),r=parseInt(t.slice(a+1),10)),n.startsWith("[")&&n.endsWith("]")&&(n=n.slice(1,n.length-1)),{host:n,port:r});if(e.host){let t=this.findBouncerNetIDByHost(i);if(!t){let t=this.clients.values().next().value;if(!t||!t.caps.enabled.has("soju.im/bouncer-networks"))return!1;let s={host:i};return"number"==typeof o&&(s.port=o),this.openDialog("network",{params:s,autojoin:e.entity}),!0}for(let[e,n]of this.state.servers)if(n.bouncerNetID===t){s=e;break}}else s=sS.getActiveServerID(this.state);if(!s)return!1;let l=sS.getBuffer(this.state,{server:s,name:e.entity||"*"});return l?this.switchBuffer(l.id):this.openDialog("join",{server:s,channel:e.entity}),!0}handleNickClick(e){this.open(e)}whoUserBuffer(e,t){let s=this.clients.get(t);s.who(e,{fields:["flags","hostname","nick","realname","username","account"]}),s.monitor(e),s.supportsReadMarker()&&s.fetchReadMarker(e)}async whoChannelBuffer(e,t){let s=this.clients.get(t);this.setBufferState({name:e,server:t},{hasInitialWho:!0});let n=!1;try{await s.who(e,{fields:["flags","hostname","nick","realname","username","account"]}),n=!0}finally{this.setBufferState({name:e,server:t},{hasInitialWho:n})}}open(e,t,s){t||(t=sS.getActiveServerID(this.state));let n=this.clients.get(t);n.isServer(e)?this.switchBuffer({server:t}):n.isChannel(e)?(this.switchToChannel=e,n.join(e,s).catch(e=>{this.showError(e)})):(this.whoUserBuffer(e,t),this.createBuffer(t,e),this.switchBuffer({server:t,name:e}))}close(e){let t=sS.getBuffer(this.state,e);if(!t)return;let s=this.clients.get(t.server);switch(t.type){case sa.SERVER:this.setState(e=>{let s=new Map(e.buffers);for(let[n,r]of e.buffers)r.server===t.server&&s.delete(n);let n=e.activeBuffer;return n&&e.buffers.get(n).server===t.server&&(n=s.size>0?s.keys().next().value:null),{buffers:s,activeBuffer:n}});let n=s&&!s.params.bouncerNetwork&&s.caps.enabled.has("soju.im/bouncer-networks"),r=this.state.servers.keys().next().value===t.server;if(this.disconnect(t.server),this.setState(e=>{let s=new Map(e.servers);s.delete(t.server);let n=e.connectForm;return 0==s.size&&(n=!0),{servers:s,connectForm:n}}),n){for(let e of this.clients.keys())this.close({server:e,name:"*"});this.bufferStore.clear()}else this.bufferStore.clear(s.params);r&&s$.put(null);break;case sa.CHANNEL:t.joined&&s.send({command:"PART",params:[t.name]});case sa.NICK:this.state.activeBuffer===t.id&&this.switchBuffer({name:"*"}),this.setState(e=>{let s=new Map(e.buffers);return s.delete(t.id),{buffers:s}}),s.unmonitor(t.name),this.bufferStore.put({name:t.name,server:s.params,closed:!0})}}disconnectAll(){this.close(this.state.buffers.keys().next().value)}executeCommand(e){let t=e.split(" "),s=t[0].toLowerCase().slice(1),n=t.slice(1),r=s8[s];if(!r){this.showError(`Unknown command "${s}" (run "/help" to get a command list)`);return}try{r.execute(this,n)}catch(e){console.error(`Failed to execute command "${s}":`,e),this.showError(e.message)}}privmsg(e,t){if("*"==e){this.showError("Cannot send message in server buffer");return}let s=sS.getActiveServerID(this.state),n=this.clients.get(s),r={command:"PRIVMSG",params:[e,t]};n.send(r),n.caps.enabled.has("echo-message")||(r.prefix={name:n.nick},this.handleChatMessage(s,e,r))}handleComposerSubmit(e){if(!e)return;if(e.startsWith("//"))e=e.slice(1);else if(e.startsWith("/")){this.executeCommand(e);return}let t=this.state.buffers.get(this.state.activeBuffer);t&&this.privmsg(t.name,e)}handleBufferListClick(e){this.switchBuffer(e),this.closeBufferList()}handleBufferListClose(e){this.close(e),this.closeBufferList()}toggleBufferList(){this.setState(e=>({openPanels:{...e.openPanels,bufferList:!e.openPanels.bufferList}}))}toggleMemberList(){this.setState(e=>({openPanels:{...e.openPanels,memberList:!e.openPanels.memberList}}))}closeBufferList(){this.setState(e=>({openPanels:{...e.openPanels,bufferList:!1}}))}closeMemberList(){this.setState(e=>({openPanels:{...e.openPanels,memberList:!1}}))}handleJoinClick(e){switch(e.type){case sa.SERVER:this.openDialog("join",{server:e.server});break;case sa.CHANNEL:this.clients.get(e.server).send({command:"JOIN",params:[e.name]})}}handleJoinSubmit(e){this.open(e.channel,this.state.dialogData.server),this.dismissDialog()}autocomplete(e){function t(e,t){t=t.toLowerCase();let s=[];for(let n of e)n.toLowerCase().startsWith(t)&&s.push(n);return s}if(e.startsWith("/"))return t(Object.keys(s8),e.slice(1)).map(e=>"/"+e);if(e.startsWith("#")){let s=[];for(let e of this.state.buffers.values())e.name.startsWith("#")&&s.push(e.name);return t(s,e)}let s=this.state.buffers.get(this.state.activeBuffer);return s&&s.members?t(s.members.keys(),e):[]}openHelp(){this.openDialog("help")}async handleBufferScrollTop(){let e,t=this.state.buffers.get(this.state.activeBuffer);if(!t||t.type==sa.SERVER)return;let s=this.clients.get(t.server);if(!s||!s.caps.enabled.has("draft/chathistory")||!s.caps.enabled.has("server-time")||this.endOfHistory.get(t.id))return;e=t.messages.length>0?t.messages[0].tags.time:tH(new Date),this.endOfHistory.set(t.id,!0);let n=100;s.caps.enabled.has("draft/event-playback")&&(n=200);let r=await s.fetchHistoryBefore(t.name,e,n);if(this.endOfHistory.set(t.id,!r.more),r.messages.length>0){let e=r.messages[r.messages.length-1],n={[sl.DELIVERED]:sm(e)};this.state.activeBuffer===t.id&&(n[sl.READ]=sm(e));let a={name:t.name,server:s.params,receipts:n};this.bufferStore.put(a)&&this.sendReadReceipt(s,a),this.setBufferState(t,({prevReadReceipt:t})=>(sg(e,t)||(t=sm(e)),{prevReadReceipt:t}))}for(let e of r.messages)this.addChatMessage(t.server,t.name,e)}openDialog(e,t){this.setState({dialog:e,dialogData:t})}dismissDialog(){this.setState({dialog:null,dialogData:null})}setDialogLoading(e){let t=e=>{this.setState(t=>({dialogData:{...t.dialogData,loading:e}}))};t(!0),e.finally(()=>t(!1))}handleAuthClick(e){let t=this.clients.get(e);this.openDialog("auth",{username:t.nick})}handleAuthSubmit(e,t){let s=sS.getActiveServerID(this.state),n=this.clients.get(s),r=n.authenticate("PLAIN",{username:e,password:t}).then(()=>{if(this.dismissDialog(),n!==this.clients.values().next().value)return;let s=s$.load();s&&(console.log("Saving SASL PLAIN credentials"),s={...s,saslPlain:{username:e,password:t}},s$.put(s))});this.setDialogLoading(r)}handleRegisterClick(e){let t=this.clients.get(e).checkAccountRegistrationCap("email-required");this.openDialog("register",{emailRequired:t})}handleRegisterSubmit(e,t){let s=sS.getActiveServerID(this.state),n=this.clients.get(s),r=n.registerAccount(e,t).then(e=>{if(this.dismissDialog(),e.verificationRequired&&this.handleVerifyClick(e.account,e.message),n!==this.clients.values().next().value)return;let s=s$.load();s&&(console.log("Saving account registration credentials"),s={...s,saslPlain:{username:e.account,password:t}},s$.put(s))});this.setDialogLoading(r)}handleVerifyClick(e,t){this.openDialog("verify",{account:e,message:t})}handleVerifySubmit(e){let t=sS.getActiveServerID(this.state),s=this.clients.get(t).verifyAccount(this.state.dialogData.account,e).then(()=>{this.dismissDialog()});this.setDialogLoading(s)}handleAddNetworkClick(){this.openDialog("network")}handleManageNetworkClick(e){let t=this.state.servers.get(e).bouncerNetID,s=this.state.bouncerNetworks.get(t);this.openDialog("network",{id:t,params:s})}async handleNetworkSubmit(e,t){let s=this.clients.values().next().value;if(this.dismissDialog(),this.state.dialogData&&this.state.dialogData.id){if(0==Object.keys(e).length)return;s.send({command:"BOUNCER",params:["CHANGENETWORK",this.state.dialogData.id,tx(e)]})}else{e={...e,tls:"1"};let n=await s.createBouncerNetwork(e);if(!t)return;let r=this.serverFromBouncerNetwork(n);this.clients.get(r).params.autojoin=[t],this.switchToChannel=t}}handleNetworkRemove(){this.clients.values().next().value.send({command:"BOUNCER",params:["DELNETWORK",this.state.dialogData.id]}),this.dismissDialog()}handleOpenSettingsClick(){let e=!1;for(let[t,s]of this.clients)if(s.caps.enabled.has("soju.im/bouncer-networks")){e=!0;break}this.openDialog("settings",{showProtocolHandler:e})}handleSettingsChange(e){sI.put(e),this.setState({settings:e})}handleSettingsDisconnect(){this.dismissDialog(),this.disconnectAll()}handleSwitchSubmit(e){this.dismissDialog(),e&&this.switchBuffer(e)}handleWindowFocus(){this.state.activeBuffer&&this.markBufferAsRead(this.state.activeBuffer);let e=new Date;if(!(this.lastFocusPingDate&&e.getTime()-this.lastFocusPingDate.getTime()<15e3))for(let t of(this.lastFocusPingDate=e,this.clients.values()))t.send({command:"PING",params:["gamja"]})}componentDidMount(){var e;let t;this.baseTitle=document.title,e=this,t={},s0.forEach(e=>{t[e.key]||(t[e.key]=[]),t[e.key].push(e)}),window.addEventListener("keydown",s=>{let n=t[s.key];n&&1==(n=n.filter(e=>!!e.altKey==s.altKey&&!!e.ctrlKey==s.ctrlKey)).length&&(s.preventDefault(),n[0].execute(e))}),window.addEventListener("focus",this.handleWindowFocus)}componentWillUnmount(){document.title=this.baseTitle,window.removeEventListener("focus",this.handleWindowFocus)}render(){let e,t;if(this.state.loading){let e=null;return this.state.error&&(e=tS`

    ${this.state.error}

    `),tS`
    ${e}
    `}let s=null,n=null,r=null;if(this.state.buffers.get(this.state.activeBuffer)){s=this.state.buffers.get(this.state.activeBuffer);let e=(n=this.state.servers.get(s.server)).bouncerNetID;e&&(r=this.state.bouncerNetworks.get(e))}let a=null;if(s&&(a=this.clients.get(s.server)),this.state.connectForm){let e=n?n.status:si.DISCONNECTED,t=e===si.CONNECTING||e===si.REGISTERING;return tS`
    <${sY} error=${this.state.error} params=${this.state.connectParams} auth=${this.config.server.auth} connecting=${t} onSubmit=${this.handleConnectSubmit} />
    `}let i=null;if(s){let e=null;s.type==sa.NICK&&(e=n.users.get(s.name)),i=tS`
    <${sz} buffer=${s} server=${n} user=${e} bouncerNetwork=${r} onChannelClick=${this.handleChannelClick} onClose=${()=>this.close(s)} onJoin=${()=>this.handleJoinClick(s)} onReconnect=${()=>this.reconnect()} onAddNetwork=${this.handleAddNetworkClick} onManageNetwork=${()=>this.handleManageNetworkClick(s.server)} onOpenSettings=${this.handleOpenSettingsClick} />
    `}let o=null;s&&s.type==sa.CHANNEL&&(o=tS`
    ${s.members.size} users
    <${sJ} members=${s.members} users=${n.users} onNickClick=${this.handleNickClick} />
    `);let l=null,c=this.state.dialogData||{};switch(this.state.dialog){case"network":let u=!c.id;l=tS` <${nf} title=${u?"Add network":"Edit network"} onDismiss=${this.dismissDialog}> <${nr} onSubmit=${this.handleNetworkSubmit} onRemove=${this.handleNetworkRemove} params=${c.params} autojoin=${c.autojoin} isNew=${u} /> `;break;case"help":l=tS` <${nf} title="Help" onDismiss=${this.dismissDialog}> <${ns}/> `;break;case"join":l=tS` <${nf} title="Join channel" onDismiss=${this.dismissDialog}> <${sX} channel=${c.channel} onSubmit=${this.handleJoinSubmit}/> `;break;case"auth":e=c.loading?tS`

    Logging in…

    `:tS` <${na} username=${c.username} onSubmit=${this.handleAuthSubmit}/> `,l=tS` <${nf} title="Login to ${sd(n,r)}" onDismiss=${this.dismissDialog}> ${e} `;break;case"register":e=c.loading?tS`

    Creating account…

    `:tS` <${ni} emailRequired=${c.emailRequired} onSubmit=${this.handleRegisterSubmit}/> `,l=tS` <${nf} title="Register a new ${sd(n,r)} account" onDismiss=${this.dismissDialog}> ${e} `;break;case"verify":e=c.loading?tS`

    Verifying account…

    `:tS` <${no} account=${c.account} message=${c.message} onSubmit=${this.handleVerifySubmit}/> `,l=tS` <${nf} title="Verify ${sd(n,r)} account" onDismiss=${this.dismissDialog}> ${e} `;break;case"settings":l=tS` <${nf} title="Settings" onDismiss=${this.dismissDialog}> <${nl} settings=${this.state.settings} showProtocolHandler=${c.showProtocolHandler} onChange=${this.handleSettingsChange} onDisconnect=${this.handleSettingsDisconnect} onClose=${this.dismissDialog} /> `;break;case"switch":l=tS` <${nf} title="Switch to a channel or user" onDismiss=${this.dismissDialog}> <${nh} buffers=${this.state.buffers} servers=${this.state.servers} bouncerNetworks=${this.state.bouncerNetworks} onSubmit=${this.handleSwitchSubmit}/> `}let h=null;this.state.error&&(h=tS`
    ${this.state.error} ${" "}
    `);let p=!1;n&&n.status!==si.REGISTERED&&(p=!0);let d=!1;if(s&&s.type===sa.SERVER)d=!0;else if(s){var m,f,g;let e,n=this.clients.get(s.server);m=n.isupport,f=n.nick,g=s.name,e=tO({prefix:{name:f,user:"_".repeat(m.userLen()),host:"_".repeat(m.hostLen())},command:"PRIVMSG",params:[g,""]})+"\r\n",t=m.lineLen()-e.length}let b=tS`
    <${sK} buffers=${this.state.buffers} servers=${this.state.servers} bouncerNetworks=${this.state.bouncerNetworks} activeBuffer=${this.state.activeBuffer} onBufferClick=${this.handleBufferListClick} onBufferClose=${this.handleBufferListClose} />
    ${i} <${nm} target=${this.buffer} stickTo=".logline" scrollKey=${this.state.activeBuffer} onScrollTop=${this.handleBufferScrollTop} >
    <${sW} buffer=${s} server=${n} settings=${this.state.settings} onChannelClick=${this.handleChannelClick} onNickClick=${this.handleNickClick} onAuthClick=${()=>this.handleAuthClick(s.server)} onRegisterClick=${()=>this.handleRegisterClick(s.server)} onVerifyClick=${this.handleVerifyClick} />
    ${o} <${np} ref=${this.composer} client=${a} readOnly=${p} onSubmit=${this.handleComposerSubmit} autocomplete=${this.autocomplete} commandOnly=${d} maxLen=${t} /> ${l} ${h} `;return tS` <${su.Provider} value=${this.state.settings}> ${b} `}}n=tS`<${nw}/>`,r=document.body,u.__&&u.__(n,r),i=a&&a.__k||r.__k,o=[],l=[],P(r,n=(a||r).__k=S(N,null,[n]),i||b,b,void 0!==r.ownerSVGElement,a?[a]:i?null:r.firstChild?c.call(r.childNodes):null,o,a||(i?i.__e:r.firstChild),!1,l),B(o,n,l); //# sourceMappingURL=index.0cb6c23c.js.map A Eo