liveroom-client-element 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  // src/constants.ts
2
- var e = "0.3.0", t = "liveroom-client-element", n = "_liveroom_id", r = "_liveroom_token", i = "_liveroom_user_name", a = "_liveroom_user_color", o = "liveroom-id", s = "liveroom-token", c = "liveroom-user-name", l = "liveroom-user-color";
2
+ var e = "0.4.0", t = "liveroom-client-element", n = "_liveroom_id", r = "_liveroom_token", i = "_liveroom_user_name", a = "_liveroom_user_color", o = "liveroom-id", s = "liveroom-token", c = "liveroom-user-name", l = "liveroom-user-color";
3
3
  export { i as a, l as c, a as i, c as l, n, o, r, s, t, e as u };
@@ -1 +1 @@
1
- Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return`_liveroom_user_name`}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return`liveroom-user-color`}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return`_liveroom_user_color`}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return`liveroom-user-name`}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return`_liveroom_id`}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return`liveroom-id`}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return`_liveroom_token`}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return`liveroom-token`}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return`liveroom-client-element`}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return`0.3.0`}});
1
+ Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return`_liveroom_user_name`}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return`liveroom-user-color`}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return`_liveroom_user_color`}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return`liveroom-user-name`}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return`_liveroom_id`}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return`liveroom-id`}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return`_liveroom_token`}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return`liveroom-token`}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return`liveroom-client-element`}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return`0.4.0`}});
@@ -1,20 +1,26 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-DkKqHYud.cjs");var t={mouseDown:1,shift:2,alt:4,block:8,focus:16},n=e=>Math.round(Math.min(100,Math.max(0,e))*100),r=e=>e/100,i=e=>typeof e==`function`?e:function(){return e},a=typeof self<`u`?self:null,o=typeof window<`u`?window:null,s=a||o||globalThis,c=`2.0.0`,l={connecting:0,open:1,closing:2,closed:3},u=100,d=1e4,f=1e3,p={closed:`closed`,errored:`errored`,joined:`joined`,joining:`joining`,leaving:`leaving`},m={close:`phx_close`,error:`phx_error`,join:`phx_join`,reply:`phx_reply`,leave:`phx_leave`},h={longpoll:`longpoll`,websocket:`websocket`},g={complete:4},_=`base64url.bearer.phx.`,v=class{constructor(e,t,n,r){this.channel=e,this.event=t,this.payload=n||function(){return{}},this.receivedResp=null,this.timeout=r,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived(`timeout`)||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()},this.channel))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:e,response:t,_ref:n}){this.recHooks.filter(t=>t.status===e).forEach(e=>e.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.cancelRefEvent(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger(`timeout`,{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},y=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries+=1,this.callback()},this.timerCalc(this.tries+1))}},b=class{constructor(e,t,n){this.state=p.closed,this.topic=e,this.params=i(t||{}),this.socket=n,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new v(this,m.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new y(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive(`ok`,()=>{this.state=p.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive(`error`,()=>{this.state=p.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log(`channel`,`close ${this.topic} ${this.joinRef()}`),this.state=p.closed,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log(`channel`,`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=p.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive(`timeout`,()=>{this.socket.hasLogger()&&this.socket.log(`channel`,`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new v(this,m.leave,i({}),this.timeout).send(),this.state=p.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(m.reply,(e,t)=>{this.trigger(this.replyEventName(t),e)})}join(e=this.timeout){if(this.joinedOnce)throw Error(`tried to join multiple times. 'join' can only be called a single time per channel instance`);return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(e){this.on(m.close,e)}onError(e){return this.on(m.error,t=>e(t))}on(e,t){let n=this.bindingRef++;return this.bindings.push({event:e,ref:n,callback:t}),n}off(e,t){this.bindings=this.bindings.filter(n=>n.event!==e||t!==void 0&&t!==n.ref)}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,n=this.timeout){if(t||={},!this.joinedOnce)throw Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let r=new v(this,e,function(){return t},n);return this.canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=p.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log(`channel`,`leave ${this.topic}`),this.trigger(m.close,`leave`)},n=new v(this,m.leave,i({}),e);return n.receive(`ok`,()=>t()).receive(`timeout`,()=>t()),n.send(),this.canPush()||n.trigger(`ok`,{}),n}onMessage(e,t,n){return t}isMember(e,t,n,r){return this.topic===e?r&&r!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log(`channel`,`dropping outdated message`,{topic:e,event:t,payload:n,joinRef:r}),!1):!0:!1}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=p.joining,this.joinPush.resend(e))}trigger(e,t,n,r){let i=this.onMessage(e,t,n,r);if(t&&!i)throw Error(`channel onMessage callbacks must return the payload, modified or unmodified`);let a=this.bindings.filter(t=>t.event===e);for(let e=0;e<a.length;e++)a[e].callback(i,n,r||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===p.closed}isErrored(){return this.state===p.errored}isJoined(){return this.state===p.joined}isJoining(){return this.state===p.joining}isLeaving(){return this.state===p.leaving}},x=class{static request(e,t,n,r,i,a,o){if(s.XDomainRequest){let n=new s.XDomainRequest;return this.xdomainRequest(n,e,t,r,i,a,o)}if(s.XMLHttpRequest){let c=new s.XMLHttpRequest;return this.xhrRequest(c,e,t,n,r,i,a,o)}if(s.fetch&&s.AbortController)return this.fetchRequest(e,t,n,r,i,a,o);throw Error(`No suitable XMLHttpRequest implementation found`)}static fetchRequest(e,t,n,r,i,a,o){let c={method:e,headers:n,body:r},l=null,u=null;return i&&(l=new AbortController,u=setTimeout(()=>l.abort(),i),c.signal=l.signal),s.fetch(t,c).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>{u&&clearTimeout(u),o&&o(e)}).catch(e=>{u&&clearTimeout(u),e.name===`AbortError`&&a?a():o&&o(null)}),l}static xdomainRequest(e,t,n,r,i,a,o){return e.timeout=i,e.open(t,n),e.onload=()=>{let t=this.parseJSON(e.responseText);o&&o(t)},a&&(e.ontimeout=a),e.onprogress=()=>{},e.send(r),e}static xhrRequest(e,t,n,r,i,a,o,s){e.open(t,n,!0),e.timeout=a;for(let[t,n]of Object.entries(r))e.setRequestHeader(t,n);return e.onerror=()=>s&&s(null),e.onreadystatechange=()=>{e.readyState===g.complete&&s&&s(this.parseJSON(e.responseText))},o&&(e.ontimeout=o),e.send(i),e}static parseJSON(e){if(!e||e===``)return null;try{return JSON.parse(e)}catch{return console&&console.log(`failed to parse JSON response`,e),null}}static serialize(e,t){let n=[];for(var r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=t?`${t}[${r}]`:r,a=e[r];typeof a==`object`?n.push(this.serialize(a,i)):n.push(encodeURIComponent(i)+`=`+encodeURIComponent(a))}return n.join(`&`)}static appendParams(e,t){return Object.keys(t).length===0?e:`${e}${e.match(/\?/)?`&`:`?`}${this.serialize(t)}`}},S=e=>{let t=``,n=new Uint8Array(e),r=n.byteLength;for(let e=0;e<r;e++)t+=String.fromCharCode(n[e]);return btoa(t)},C=class{constructor(e,t){t&&t.length===2&&t[1].startsWith(_)&&(this.authToken=atob(t[1].slice(_.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.messageTimers=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=l.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace(`ws://`,`http://`).replace(`wss://`,`https://`).replace(RegExp(`(.*)/`+h.websocket),`$1/`+h.longpoll)}endpointURL(){return x.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,n,r){this.isActive()&&(this.stop(l.connecting),this.onerror(e),this.isActive()&&this.emitClose(t,n,r))}ontimeout(){this.closeAndRetry(`timeout`,1005,`timeout`,!1)}isActive(){return this.readyState===l.open||this.readyState===l.connecting}poll(){if(!this.isActive())return;let e={Accept:`application/json`};this.authToken&&(e[`X-Phoenix-AuthToken`]=this.authToken),this.ajax(`GET`,e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:n,messages:r}=e;if(t===410&&this.token!==null){this.closeAndRetry(410,3410,`session_gone`,!1);return}this.token=n}else t=0;switch(t){case 200:r.forEach(e=>{let t=setTimeout(()=>{this.messageTimers.delete(t),this.onmessage({data:e})},0);this.messageTimers.add(t)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=l.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,`forbidden`,!1);break;case 0:case 500:this.closeAndRetry(500,1011,`internal server error`,!1);break;default:throw Error(`unhandled poll status ${t}`)}})}send(e){typeof e!=`string`&&(e=S(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e,t=0){this.awaitingBatchAck=!0;let n=t+u,r=e.slice(t,n);this.ajax(`POST`,{"Content-Type":`application/x-ndjson`},r.join(`
2
- `),()=>this.ontimeout(),t=>{!t||t.status!==200?this.closeAndRetry(t&&t.status,1011,`internal server error`,!1):n<e.length?this.batchSend(e,n):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1})}close(e,t,n){this.stop(l.closed),this.emitClose(e,t,n)}stop(e){this.readyState=e;let t=this.reqs;this.reqs=new Set;for(let{req:e}of t)e&&e.abort();for(let e of this.messageTimers)clearTimeout(e);this.messageTimers.clear(),this.batchBuffer=[],this.awaitingBatchAck=!1,clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,this.currentBatch=null}emitClose(e=1005,t,n=!0){let r={code:e,reason:t,wasClean:n};typeof CloseEvent<`u`?this.onclose(new CloseEvent(`close`,r)):this.onclose(r)}ajax(e,t,n,r,i){let a={req:null};this.reqs.add(a),a.req=x.request(e,this.endpointURL(),t,n,this.timeout,()=>{this.reqs.delete(a)&&r()},e=>{this.reqs.delete(a)&&i(e)})}},w={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[n,r,i,a,o]=JSON.parse(e);return t({join_ref:n,ref:r,topic:i,event:a,payload:o})}},binaryEncode(e){let{join_ref:t,ref:n,event:r,topic:i,payload:a}=e,o=new TextEncoder,s=o.encode(t),c=o.encode(n),l=o.encode(i),u=o.encode(r);this.assertFieldSize(s.byteLength,`join_ref`),this.assertFieldSize(c.byteLength,`ref`),this.assertFieldSize(l.byteLength,`topic`),this.assertFieldSize(u.byteLength,`event`);let d=this.META_LENGTH+s.byteLength+c.byteLength+l.byteLength+u.byteLength,f=new ArrayBuffer(this.HEADER_LENGTH+d),p=new Uint8Array(f),m=new DataView(f),h=0;m.setUint8(h++,this.KINDS.push),m.setUint8(h++,s.byteLength),m.setUint8(h++,c.byteLength),m.setUint8(h++,l.byteLength),m.setUint8(h++,u.byteLength),p.set(s,h),h+=s.byteLength,p.set(c,h),h+=c.byteLength,p.set(l,h),h+=l.byteLength,p.set(u,h),h+=u.byteLength;var g=new Uint8Array(f.byteLength+a.byteLength);return g.set(p,0),g.set(new Uint8Array(a),f.byteLength),g.buffer},assertFieldSize(e,t){if(e>255)throw Error(`unable to convert ${t} to binary: must be less than or equal to 255 bytes, but is ${e} bytes`)},binaryDecode(e){let t=new DataView(e),n=t.getUint8(0),r=new TextDecoder;switch(n){case this.KINDS.push:return this.decodePush(e,t,r);case this.KINDS.reply:return this.decodeReply(e,t,r);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,r)}},decodePush(e,t,n){let r=t.getUint8(1),i=t.getUint8(2),a=t.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,s=n.decode(e.slice(o,o+r));o+=r;let c=n.decode(e.slice(o,o+i));o+=i;let l=n.decode(e.slice(o,o+a));return o+=a,{join_ref:s,ref:null,topic:c,event:l,payload:e.slice(o,e.byteLength)}},decodeReply(e,t,n){let r=t.getUint8(1),i=t.getUint8(2),a=t.getUint8(3),o=t.getUint8(4),s=this.HEADER_LENGTH+this.META_LENGTH,c=n.decode(e.slice(s,s+r));s+=r;let l=n.decode(e.slice(s,s+i));s+=i;let u=n.decode(e.slice(s,s+a));s+=a;let d=n.decode(e.slice(s,s+o));s+=o;let f={status:d,response:e.slice(s,e.byteLength)};return{join_ref:c,ref:l,topic:u,event:m.reply,payload:f}},decodeBroadcast(e,t,n){let r=t.getUint8(1),i=t.getUint8(2),a=this.HEADER_LENGTH+2,o=n.decode(e.slice(a,a+r));a+=r;let s=n.decode(e.slice(a,a+i));return a+=i,{join_ref:null,ref:null,topic:o,event:s,payload:e.slice(a,e.byteLength)}}},T=class{constructor(e,t){this.socket=e,this.transport=t,this.joins=new WeakMap,this.pings=new Map,this.closing=!1,this.ended=!1,this.channelsErrored=!1,this.closeHandled=!1,t.onopen=()=>{this.isCurrent()&&e.onConnOpen()},t.onerror=t=>{this.isCurrent()&&e.onConnError(t)},t.onmessage=t=>{this.isCurrent()&&e.onConnMessage(t)},t.onclose=t=>{this.isCurrent()&&!this.closeHandled&&(this.closeHandled=!0,e.onConnClose(t))}}isCurrent(){return this.socket.connection===this}isOpen(){return this.transport.readyState===l.open}isConnecting(){return this.transport.readyState===l.connecting}carried(e,t=e.joinRef()){return this.joins.has(e)&&this.joins.get(e)===t}close(e,t){this.closing=!0,this.transport.onerror=function(){},e?this.transport.close(e,t||``):this.transport.close()}},E=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.fallbackErrorRef=null,this.timeout=t.timeout||d,this.transport=t.transport||s.WebSocket||C,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||s&&s.sessionStorage,this.establishedConnections=0,this.defaultEncoder=w.encode.bind(w),this.defaultDecoder=w.decode.bind(w),this.closeWasClean=!0,this.binaryType=t.binaryType||`arraybuffer`,this.connection=null,this.connectClock=1,this.visibilityConnection=null,this.transport===C?(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder):(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder);let n=null;o&&o.addEventListener&&(o.addEventListener(`pagehide`,e=>{this.connection&&!this.connection.ended&&(this.disconnect(),n=this.connectClock)}),o.addEventListener(`pageshow`,e=>{n===this.connectClock&&(n=null,this.connect())}),o.addEventListener(`visibilitychange`,()=>{this.handleVisibilityChange()}),o.document&&o.document.addEventListener(`resume`,()=>{this.handleVisibilityChange()})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=e=>t.rejoinAfterMs?t.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>t.reconnectAfterMs?t.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(e,t,n)=>{console.log(`${e}: ${t}`,n)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=i(t.params||{}),this.endPoint=`${e}/${h.websocket}`,this.vsn=t.vsn||c,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new y(()=>{this.pageHidden?(this.log(`Not reconnecting as page is hidden!`),this.teardown()):this.teardownAndReconnect(()=>this.connect())},this.reconnectAfterMs),this.authToken=t.authToken&&i(t.authToken)}get conn(){return this.connection&&this.connection.transport}get pageHidden(){return o&&o.document?o.document.visibilityState===`hidden`:!1}handleVisibilityChange(){if(this.pageHidden){this.visibilityConnection=null;return}let e=this.connection;e&&e===this.visibilityConnection&&e.isConnecting()||!this.isConnected()&&!this.closeWasClean&&(this.reconnectTimer.reset(),this.teardownAndReconnect(()=>{this.connect(),this.visibilityConnection=this.connection}))}getLongPollTransport(){return C}replaceTransport(e){let t=++this.connectClock;this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.transport=e;let n=this.connection;if(n){let e=n.isOpen();this.connection=null,n.ended=!0,n.close(),this.clearHeartbeats(),e&&this.triggerChanError(`connection_closed`,n)}return t}protocol(){return location.protocol.match(/^https/)?`wss`:`ws`}endPointURL(){let e=x.appendParams(x.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)===`/`?e.charAt(1)===`/`?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`:e}disconnect(e,t,n){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.connection&&(this.connection.ended=!0),this.teardown(e,t,n)}connect(e){e&&(console&&console.log(`passing params to connect is deprecated. Instead pass :params to the Socket constructor`),this.params=i(e)),(!this.connection||this.connection.ended)&&(this.longPollFallbackMs&&this.transport!==C?this.connectWithFallback(C,this.longPollFallbackMs):this.transportConnect())}log(e,t,n){this.logger&&this.logger(e,t,n)}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),n=Date.now();return this.connection.pings.set(t,()=>e(Date.now()-n)),this.push({topic:`phoenix`,event:`heartbeat`,payload:{},ref:t}),!0}transportName(e){switch(e){case C:return`LongPoll`;default:return e.name}}transportConnect(){let e=this.connection;this.connectClock++,this.closeWasClean=!1,clearTimeout(this.reconnectTimer.timer);let t;this.authToken&&(t=[`phoenix`,`${_}${btoa(this.authToken()).replace(/=/g,``)}`]);let n=new this.transport(this.endPointURL(),t);n.binaryType=this.binaryType,n.timeout=this.longpollerTimeout,this.connection=new T(this,n),e&&e.isOpen()&&this.triggerChanError(`connection_closed`,e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){this.cancelFallback();let n=!1,r=!0,i,a,o=()=>a===this.connectClock&&!this.closeWasClean,s=this.transportName(e),c=t=>{this.log(`transport`,`falling back to ${s}...`,t),this.off([i]),r=!1,this.replaceTransport(e)===this.connectClock&&this.transportConnect()};if(this.getSession(`phx:fallback:${s}`))return c(`memorized`);this.fallbackTimer=setTimeout(c,t),i=this.fallbackErrorRef=this.onError(e=>{o()&&(this.log(`transport`,`error`,e),r&&!n&&(clearTimeout(this.fallbackTimer),c(e)))}),this.fallbackRef=this.onOpen(()=>{if(!r){if(this.transport!==e||this.closeWasClean)return;let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t}`,`true`),this.log(`transport`,`established ${t} fallback`)}o()&&(n=!0,clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(c,t),this.ping(e=>{this.log(`transport`,`connected to primary after`,e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)}))}),this.transportConnect(),a=this.connectClock}cancelFallback(){clearTimeout(this.fallbackTimer),this.off([this.fallbackRef,this.fallbackErrorRef])}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer),this.pendingHeartbeatRef=null}onConnOpen(){this.hasLogger()&&this.log(`transport`,`${this.transportName(this.transport)} connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,e])=>e())}heartbeatTimeout(){if(this.pendingHeartbeatRef){let e=this.connection;if(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log(`transport`,`heartbeat timeout. Attempting to re-establish connection`),this.closeWasClean=!1,e&&e.close(f,`heartbeat timeout`),!this.stillUses(e)||(this.triggerChanError(`heartbeat_timeout`),!this.stillUses(e)))return;this.teardownAndReconnect(()=>this.reconnectTimer.scheduleTimeout())}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardownAndReconnect(e){let t=this.connection,n=this.connectClock;this.teardown(()=>{n!==this.connectClock||t&&t.ended||e()})}stillUses(e){return this.connection===e&&!(e&&e.ended)}teardown(e,t,n){let r=this.connection;if(!r)return e&&e();this.clearHeartbeats(),this.waitForBufferDone(r.transport,()=>{if(!r.closing){let e=!r.isConnecting();r.close(t,n),e&&this.triggerChanError(`connection_closed`,r)}this.waitForSocketClosed(r.transport,()=>{this.connection===r&&(this.connection=null),e&&e()})})}waitForBufferDone(e,t,n=1){n===5||!e.bufferedAmount||e.readyState!==l.open?t():setTimeout(()=>{this.waitForBufferDone(e,t,n+1)},150*n)}waitForSocketClosed(e,t,n=1){n===5||e.readyState===l.closed?t():setTimeout(()=>{this.waitForSocketClosed(e,t,n+1)},150*n)}onConnClose(e){let t=this.connection;this.hasLogger()&&this.log(`transport`,`close`,e),this.clearHeartbeats();let n=!!(t&&t.closing);this.triggerChanError(`connection_closed`,t),this.stillUses(t)&&!n&&!this.closeWasClean&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,t])=>t(e))}onConnError(e){let t=this.connection;this.hasLogger()&&this.log(`transport`,`error`,e);let n=this.transport,r=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,t])=>{t(e,n,r)}),this.triggerChanError(`connection_error`,t)}triggerChanError(e,t=this.connection){let n=!1;t&&!t.isOpen()&&(n=t.channelsErrored,t.channelsErrored=!0),this.channels.map(e=>[e,e.joinRef()]).forEach(([r,i])=>{r.joinRef()===i&&(!t||!n&&t.isCurrent()||t.carried(r,i))&&(r.isErrored()||r.isLeaving()||r.isClosed()||r.trigger(m.error,{source:`transport`,reason:e}))})}connectionState(){switch(this.conn&&this.conn.readyState){case l.connecting:return`connecting`;case l.open:return`open`;case l.closing:return`closing`;default:return`closed`}}isConnected(){return this.connectionState()===`open`}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([t])=>e.indexOf(t)===-1)}channel(e,t={}){let n=new b(e,t,this);return this.channels.push(n),n}push(e,t){if(this.hasLogger()){let{topic:t,event:n,payload:r,ref:i,join_ref:a}=e;this.log(`push`,`${t} ${n} (${a}, ${i})`,r)}this.isConnected()?this.send(e,t):this.sendBuffer.push(()=>{this.isOutdated(e,t)||this.send(e,t)})}send(e,t){let n=this.connection;t&&e.event===m.join&&n.joins.set(t,e.join_ref),this.encode(e,r=>{n.isCurrent()&&n.isOpen()&&(e.event!==m.leave&&this.isOutdated(e,t)||n.transport.send(r))})}isOutdated(e,t){return!!t&&(e.join_ref!==t.joinRef()||t.isClosed())}makeRef(){let e=this.ref+1;return this.ref=e===this.ref?0:e,this.ref.toString()}sendHeartbeat(){(!this.pendingHeartbeatRef||this.isConnected())&&(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:`phoenix`,event:`heartbeat`,payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){let t=this.connection,n=t&&t.isOpen();this.decode(e.data,e=>{if(t!==this.connection||n&&!t.isOpen())return;let{topic:r,event:i,payload:a,ref:o,join_ref:s}=e;o&&o===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log(`receive`,`${a.status||``} ${r} ${i} ${o&&`(`+o+`)`||``}`,a);let c=this.channels;for(let e=0;e<c.length;e++){let t=c[e];t.isMember(r,i,a,s)&&t.trigger(i,a,o,s)}let l=this.stateChangeCallbacks.message;for(let t=0;t<l.length;t++){let[,n]=l[t];n(e)}let u=o&&t.pings.get(o);u&&(t.pings.delete(o),u())})}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log(`transport`,`leaving duplicate topic "${e}"`),t.leave())}},D=1e3,O=1e3,k=150,ee=2,te=3e4,ne=1e4,re=60,ie=class{probe;onChange;now;quality=`good`;rtt=null;rtts=[];pings=0;stalls=0;stallMs=0;maxStallMs=0;unstableMs=0;offlineMs=0;reconnects=0;everOnline=!1;wasOnline=!1;pingSentAt=null;stallSince=null;lastIssueAt=-1/0;slowAt=[];lastPingAt=-1/0;lastTick;timer=null;constructor(e,t,n=()=>performance.now()){this.probe=e,this.onChange=t,this.now=n,this.lastTick=n()}start(e=250){this.stop(),this.timer=setInterval(()=>this.tick(),e)}stop(){this.timer&&clearInterval(this.timer),this.timer=null}tick(){let e=this.now(),t=e-this.lastTick;this.lastTick=e,this.quality===`unstable`&&(this.unstableMs+=t),this.quality===`offline`&&(this.offlineMs+=t);let n=this.probe.online();n&&!this.wasOnline&&(this.everOnline&&this.reconnects++,this.everOnline=!0),!n&&this.wasOnline&&this.endStall(e),this.wasOnline=n,n?(this.pingSentAt!==null&&this.stallSince===null&&e-this.pingSentAt>=O&&(this.stallSince=this.pingSentAt),this.pingSentAt===null&&e-this.lastPingAt>=D&&this.sendPing(e)):this.pingSentAt=null;let r=n?this.stallSince!==null||e-this.lastIssueAt<ne||this.recentSlow(e)>=ee?`unstable`:`good`:this.everOnline?`offline`:`good`;r!==this.quality&&(this.quality=r,this.onChange(r))}report(){let e=[...this.rtts].sort((e,t)=>e-t),t=t=>Math.round(e[Math.min(e.length-1,Math.floor(t*e.length))]);return{q:this.quality===`good`?`good`:`unstable`,rtt:e.length?[t(.5),t(.95),Math.round(e[e.length-1])]:null,pings:this.pings,stalls:this.stalls,stall_ms:Math.round(this.stallMs),max_stall_ms:Math.round(this.maxStallMs),unstable_ms:Math.round(this.unstableMs),offline_ms:Math.round(this.offlineMs),reconnects:this.reconnects}}sendPing(e){this.lastPingAt=e,this.probe.ping(t=>{if(this.pingSentAt!==e)return;let n=this.now();this.pingSentAt=null,this.pings++,this.rtt=t,this.rtts.push(t),this.rtts.length>re&&this.rtts.shift();let[r,i,a]=this.rtts.slice(-3);a!==void 0&&i>=r+k&&i>=a+k&&this.slowAt.push(n),this.endStall(n),this.tick()})&&(this.pingSentAt=e)}recentSlow(e){for(;this.slowAt.length&&e-this.slowAt[0]>=te;)this.slowAt.shift();return this.slowAt.length}endStall(e){if(this.stallSince===null)return;let t=e-this.stallSince;this.stalls++,this.stallMs+=t,this.maxStallMs=Math.max(this.maxStallMs,t),this.stallSince=null,this.lastIssueAt=e}},A=[80,160,320,640,1e3];function j(e,t=Math.random){let n=A[Math.min(Math.max(e,1),A.length)-1],r=Math.round(n*.2),i=Math.min(Math.max(t(),0),.999999);return n-r+Math.floor(i*(r*2+1))}var M=class{options;participants=new Map;status=`connecting`;you=null;livekit=null;account=null;socket=null;channel=null;bySlot=new Map;listeners=new Map;flags=t.alt;renames=new Map;cursor=null;sentCursor=null;moveScheduled=!1;lastMoveAt=0;localState={};follow=`all`;monitor=null;reportTimer=null;offPageHide=null;tabs=null;control=null;serverStop=!1;constructor(e){this.options=e}on(e,t){let n=this.listeners.get(e);return n||this.listeners.set(e,n=new Set),n.add(t),()=>n.delete(t)}emit(e,t){for(let n of this.listeners.get(e)??[])n(t)}get me(){return this.you?this.participants.get(this.you):void 0}hasFlag(e){return(this.flags&t[e])!==0}connect(){let e=this.options,t=()=>this.reportNet();window.addEventListener(`pagehide`,t),this.offPageHide=()=>window.removeEventListener(`pagehide`,t),this.socket=new E(e.url,{params:e.apiToken?{api_token:e.apiToken}:{},heartbeatIntervalMs:e.heartbeatMs??5e3,reconnectAfterMs:e=>j(e),rejoinAfterMs:e=>[100,500,1e3,2e3][e-1]??5e3,logger:e.logger}),this.socket.onClose(()=>this.setStatus(`disconnected`)),this.socket.connect();let n=this.socket;this.monitor=new ie({ping:e=>n.ping(e),online:()=>n.isConnected()&&this.status===`joined`},e=>{this.emit(`quality`,e),this.reportNet()}),this.monitor.start(),this.reportTimer=setInterval(()=>this.reportNet(),1e4),this.channel=this.socket.channel(`room:${e.roomId}`,()=>this.joinParams()),this.channel.on(`snapshot`,e=>this.onSnapshot(e)),this.channel.on(`presence`,e=>this.onPresence(e)),this.channel.on(`cursors`,e=>this.onCursors(e)),this.channel.on(`state`,e=>this.onState(e)),this.channel.on(`click`,e=>this.emit(`click`,e)),this.channel.on(`wheel`,e=>this.emit(`wheel`,e)),this.channel.on(`account`,({account:e})=>{this.account=e,this.emit(`account`,e)});let r=this.channel;this.whenResumeIsFree(()=>this.join(r)),r.onError(()=>this.setStatus(`disconnected`))}join(e){e===this.channel&&e.join().receive(`ok`,({you:e,resume:t,stopped:n})=>{this.you=e,t&&this.storage?.setItem(this.resumeKey,t),this.serverStop=typeof n==`boolean`}).receive(`error`,({reason:e,code:t})=>{if(t!==`refused`)return this.setStatus(`disconnected`);this.setStatus(`refused`),this.emit(`refused`,e),this.disconnect()})}whenResumeIsFree(e){if(typeof BroadcastChannel>`u`)return e();let t=this.tabs=new BroadcastChannel(`liveroom:${this.options.roomId}`),n=this.storage?.getItem(this.resumeKey)||null,r=!1;if(t.onmessage=({data:e})=>{let i=this.storage?.getItem(this.resumeKey);e?.type===`who`&&i&&e.resume===i&&this.status===`joined`?t.postMessage({type:`mine`,resume:i}):e?.type===`mine`&&n&&e.resume===n&&(r=!0)},!n)return e();t.postMessage({type:`who`,resume:n}),setTimeout(()=>{r&&this.storage?.setItem(this.resumeKey,``),e()},150)}disconnect(){for(let e of[...this.renames.keys()])this.flushRename(e);this.reportNet(),this.monitor?.stop(),this.reportTimer&&clearInterval(this.reportTimer),this.offPageHide?.(),this.tabs?.close(),this.tabs=null,this.monitor=null,this.reportTimer=null,this.offPageHide=null,this.channel?.leave(),this.socket?.disconnect(),this.channel=null,this.socket=null}get quality(){return this.monitor?.quality??`good`}get rtt(){return this.monitor?.rtt??null}reportNet(){this.monitor&&this.push(`net`,this.monitor.report())}setStatus(e){this.status!==`refused`&&this.status!==e&&(this.status=e,this.emit(`status`,e))}get storage(){if(this.options.storage!==void 0)return this.options.storage;try{return window.sessionStorage}catch{return null}}get resumeKey(){return`liveroom-resume:${this.options.roomId}`}joinParams(){let e=this.options;return F({v:2,room_token:e.roomToken,type:e.type,resume:this.storage?.getItem(this.resumeKey)||void 0,name:e.name??void 0,color:e.color??void 0,viewport:e.viewport?.()??this.localState.viewport,cursor:this.cursor?this.cursor.map(n):void 0,net:this.monitor&&this.monitor.quality!==`good`?`unstable`:void 0,...e.analytics})}onSnapshot(e){this.you=e.you,this.livekit=e.livekit,this.account=e.account,this.participants.clear(),this.bySlot.clear();for(let t of Object.values(e.users))this.put(t);this.setStatus(`joined`),this.sentCursor=null,this.push(`f`,this.flags),Object.keys(this.localState).length&&this.push(`s`,this.localState),this.follow!==`all`&&this.push(`follow`,this.follow),this.reportNet(),this.flushMove(),this.flushControl(),this.emit(`snapshot`,void 0),this.emit(`account`,this.account)}onPresence(e){let t=Object.values(e.joins).map(e=>(this.put(e),e.id));for(let t of e.leaves){let e=this.participants.get(t);e&&this.bySlot.delete(e.slot),this.participants.delete(t)}let n=[];for(let[t,r]of Object.entries(e.updates)){let e=this.participants.get(t);e&&(Object.assign(e,r),n.push(t))}this.emit(`presence`,{joined:t,left:e.leaves,updated:n})}onCursors({t:e,c:t}){let n=[];for(let i=0;i+3<t.length;i+=4){let a=this.bySlot.get(t[i]),o=a?this.participants.get(a):void 0;o&&(o.x=r(t[i+1]),o.y=r(t[i+2]),o.flags=t[i+3],o.cursorAt=e,n.push(o.id))}n.length&&this.emit(`cursors`,{ids:n,t:e})}onState(e){let t=[];for(let[n,r]of Object.entries(e)){let e=this.participants.get(n);e&&(Object.assign(e,r),t.push(n))}t.length&&this.emit(`state`,{ids:t})}put(e){this.participants.set(e.id,{...e,x:r(e.x),y:r(e.y),cursorAt:0}),this.bySlot.set(e.slot,e.id)}push(e,t){this.channel&&this.status===`joined`&&this.channel.push(e,t)}move(e,t){if(this.cursor=[e,t],this.moveScheduled)return;if(performance.now()-this.lastMoveAt>=15)return this.flushMove();this.moveScheduled=!0;let n=()=>{this.moveScheduled=!1,this.flushMove()};typeof document<`u`&&document.visibilityState===`visible`&&typeof requestAnimationFrame==`function`?requestAnimationFrame(n):setTimeout(n,16)}flushMove(){if(!this.cursor)return;let e=[n(this.cursor[0]),n(this.cursor[1])];this.sentCursor&&e[0]===this.sentCursor[0]&&e[1]===this.sentCursor[1]||this.status===`joined`&&(this.sentCursor=e,this.lastMoveAt=performance.now(),this.push(`m`,e))}setFlag(e,n){let r=n?this.flags|t[e]:this.flags&~t[e];r!==this.flags&&(this.flags=r,this.flushMove(),this.push(`f`,r),this.emit(`flags`,r))}toggleFlag(e){this.setFlag(e,!this.hasFlag(e))}get ownFlags(){return this.flags}setState(e){e.url&&(e={...e,url:P(e.url)}),Object.assign(this.localState,e),this.push(`s`,e)}stop(){this.control=`stop`,this.flushControl()}resume(){this.control=`resume`,this.flushControl()}flushControl(){this.control&&this.status===`joined`&&this.serverStop&&(this.push(this.control,{}),this.control=null)}click(e){this.flushMove(),this.push(`click`,{to:e,...this.cursorPayload()})}wheel(e,t,n){this.flushMove(),this.push(`wheel`,{to:e,dx:Math.round(t),dy:Math.round(n),...this.cursorPayload()})}cursorPayload(){return this.cursor?{x:n(this.cursor[0]),y:n(this.cursor[1])}:{}}rename(e,t){let n=this.renames.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>this.flushRename(e),250);this.renames.set(e,{name:t,timer:r})}flushRename(e){let t=this.renames.get(e);t&&(clearTimeout(t.timer),this.renames.delete(e),this.push(`rename`,{id:e,name:t.name}))}cameras(e){this.push(`cameras`,{enabled:e})}presenter(e){this.push(`presenter`,{name:e})}setFollow(e){e===this.follow||Array.isArray(e)&&Array.isArray(this.follow)&&e.length===this.follow.length&&e.every((e,t)=>e===this.follow[t])||(this.follow=e,this.push(`follow`,e))}},N=2048;function P(e){return e.length>2048?e.slice(0,N):e}function F(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`string`?P(t):t]))}var I=`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-D2391gVh.cjs");var t={mouseDown:1,shift:2,alt:4,block:8,focus:16},n=e=>Math.round(Math.min(100,Math.max(0,e))*100),r=e=>e/100,i=e=>typeof e==`function`?e:function(){return e},a=typeof self<`u`?self:null,o=typeof window<`u`?window:null,s=a||o||globalThis,c=`2.0.0`,l={connecting:0,open:1,closing:2,closed:3},u=100,d=1e4,f=1e3,p={closed:`closed`,errored:`errored`,joined:`joined`,joining:`joining`,leaving:`leaving`},m={close:`phx_close`,error:`phx_error`,join:`phx_join`,reply:`phx_reply`,leave:`phx_leave`},h={longpoll:`longpoll`,websocket:`websocket`},g={complete:4},_=`base64url.bearer.phx.`,v=class{constructor(e,t,n,r){this.channel=e,this.event=t,this.payload=n||function(){return{}},this.receivedResp=null,this.timeout=r,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived(`timeout`)||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()},this.channel))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:e,response:t,_ref:n}){this.recHooks.filter(t=>t.status===e).forEach(e=>e.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.cancelRefEvent(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger(`timeout`,{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},y=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries+=1,this.callback()},this.timerCalc(this.tries+1))}},b=class{constructor(e,t,n){this.state=p.closed,this.topic=e,this.params=i(t||{}),this.socket=n,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new v(this,m.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new y(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive(`ok`,()=>{this.state=p.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive(`error`,()=>{this.state=p.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log(`channel`,`close ${this.topic} ${this.joinRef()}`),this.state=p.closed,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log(`channel`,`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=p.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive(`timeout`,()=>{this.socket.hasLogger()&&this.socket.log(`channel`,`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new v(this,m.leave,i({}),this.timeout).send(),this.state=p.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(m.reply,(e,t)=>{this.trigger(this.replyEventName(t),e)})}join(e=this.timeout){if(this.joinedOnce)throw Error(`tried to join multiple times. 'join' can only be called a single time per channel instance`);return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(e){this.on(m.close,e)}onError(e){return this.on(m.error,t=>e(t))}on(e,t){let n=this.bindingRef++;return this.bindings.push({event:e,ref:n,callback:t}),n}off(e,t){this.bindings=this.bindings.filter(n=>n.event!==e||t!==void 0&&t!==n.ref)}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,n=this.timeout){if(t||={},!this.joinedOnce)throw Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let r=new v(this,e,function(){return t},n);return this.canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=p.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log(`channel`,`leave ${this.topic}`),this.trigger(m.close,`leave`)},n=new v(this,m.leave,i({}),e);return n.receive(`ok`,()=>t()).receive(`timeout`,()=>t()),n.send(),this.canPush()||n.trigger(`ok`,{}),n}onMessage(e,t,n){return t}isMember(e,t,n,r){return this.topic===e?r&&r!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log(`channel`,`dropping outdated message`,{topic:e,event:t,payload:n,joinRef:r}),!1):!0:!1}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=p.joining,this.joinPush.resend(e))}trigger(e,t,n,r){let i=this.onMessage(e,t,n,r);if(t&&!i)throw Error(`channel onMessage callbacks must return the payload, modified or unmodified`);let a=this.bindings.filter(t=>t.event===e);for(let e=0;e<a.length;e++)a[e].callback(i,n,r||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===p.closed}isErrored(){return this.state===p.errored}isJoined(){return this.state===p.joined}isJoining(){return this.state===p.joining}isLeaving(){return this.state===p.leaving}},x=class{static request(e,t,n,r,i,a,o){if(s.XDomainRequest){let n=new s.XDomainRequest;return this.xdomainRequest(n,e,t,r,i,a,o)}if(s.XMLHttpRequest){let c=new s.XMLHttpRequest;return this.xhrRequest(c,e,t,n,r,i,a,o)}if(s.fetch&&s.AbortController)return this.fetchRequest(e,t,n,r,i,a,o);throw Error(`No suitable XMLHttpRequest implementation found`)}static fetchRequest(e,t,n,r,i,a,o){let c={method:e,headers:n,body:r},l=null,u=null;return i&&(l=new AbortController,u=setTimeout(()=>l.abort(),i),c.signal=l.signal),s.fetch(t,c).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>{u&&clearTimeout(u),o&&o(e)}).catch(e=>{u&&clearTimeout(u),e.name===`AbortError`&&a?a():o&&o(null)}),l}static xdomainRequest(e,t,n,r,i,a,o){return e.timeout=i,e.open(t,n),e.onload=()=>{let t=this.parseJSON(e.responseText);o&&o(t)},a&&(e.ontimeout=a),e.onprogress=()=>{},e.send(r),e}static xhrRequest(e,t,n,r,i,a,o,s){e.open(t,n,!0),e.timeout=a;for(let[t,n]of Object.entries(r))e.setRequestHeader(t,n);return e.onerror=()=>s&&s(null),e.onreadystatechange=()=>{e.readyState===g.complete&&s&&s(this.parseJSON(e.responseText))},o&&(e.ontimeout=o),e.send(i),e}static parseJSON(e){if(!e||e===``)return null;try{return JSON.parse(e)}catch{return console&&console.log(`failed to parse JSON response`,e),null}}static serialize(e,t){let n=[];for(var r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=t?`${t}[${r}]`:r,a=e[r];typeof a==`object`?n.push(this.serialize(a,i)):n.push(encodeURIComponent(i)+`=`+encodeURIComponent(a))}return n.join(`&`)}static appendParams(e,t){return Object.keys(t).length===0?e:`${e}${e.match(/\?/)?`&`:`?`}${this.serialize(t)}`}},ee=e=>{let t=``,n=new Uint8Array(e),r=n.byteLength;for(let e=0;e<r;e++)t+=String.fromCharCode(n[e]);return btoa(t)},S=class{constructor(e,t){t&&t.length===2&&t[1].startsWith(_)&&(this.authToken=atob(t[1].slice(_.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.messageTimers=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=l.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace(`ws://`,`http://`).replace(`wss://`,`https://`).replace(RegExp(`(.*)/`+h.websocket),`$1/`+h.longpoll)}endpointURL(){return x.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,n,r){this.isActive()&&(this.stop(l.connecting),this.onerror(e),this.isActive()&&this.emitClose(t,n,r))}ontimeout(){this.closeAndRetry(`timeout`,1005,`timeout`,!1)}isActive(){return this.readyState===l.open||this.readyState===l.connecting}poll(){if(!this.isActive())return;let e={Accept:`application/json`};this.authToken&&(e[`X-Phoenix-AuthToken`]=this.authToken),this.ajax(`GET`,e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:n,messages:r}=e;if(t===410&&this.token!==null){this.closeAndRetry(410,3410,`session_gone`,!1);return}this.token=n}else t=0;switch(t){case 200:r.forEach(e=>{let t=setTimeout(()=>{this.messageTimers.delete(t),this.onmessage({data:e})},0);this.messageTimers.add(t)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=l.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,`forbidden`,!1);break;case 0:case 500:this.closeAndRetry(500,1011,`internal server error`,!1);break;default:throw Error(`unhandled poll status ${t}`)}})}send(e){typeof e!=`string`&&(e=ee(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e,t=0){this.awaitingBatchAck=!0;let n=t+u,r=e.slice(t,n);this.ajax(`POST`,{"Content-Type":`application/x-ndjson`},r.join(`
2
+ `),()=>this.ontimeout(),t=>{!t||t.status!==200?this.closeAndRetry(t&&t.status,1011,`internal server error`,!1):n<e.length?this.batchSend(e,n):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1})}close(e,t,n){this.stop(l.closed),this.emitClose(e,t,n)}stop(e){this.readyState=e;let t=this.reqs;this.reqs=new Set;for(let{req:e}of t)e&&e.abort();for(let e of this.messageTimers)clearTimeout(e);this.messageTimers.clear(),this.batchBuffer=[],this.awaitingBatchAck=!1,clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,this.currentBatch=null}emitClose(e=1005,t,n=!0){let r={code:e,reason:t,wasClean:n};typeof CloseEvent<`u`?this.onclose(new CloseEvent(`close`,r)):this.onclose(r)}ajax(e,t,n,r,i){let a={req:null};this.reqs.add(a),a.req=x.request(e,this.endpointURL(),t,n,this.timeout,()=>{this.reqs.delete(a)&&r()},e=>{this.reqs.delete(a)&&i(e)})}},C={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[n,r,i,a,o]=JSON.parse(e);return t({join_ref:n,ref:r,topic:i,event:a,payload:o})}},binaryEncode(e){let{join_ref:t,ref:n,event:r,topic:i,payload:a}=e,o=new TextEncoder,s=o.encode(t),c=o.encode(n),l=o.encode(i),u=o.encode(r);this.assertFieldSize(s.byteLength,`join_ref`),this.assertFieldSize(c.byteLength,`ref`),this.assertFieldSize(l.byteLength,`topic`),this.assertFieldSize(u.byteLength,`event`);let d=this.META_LENGTH+s.byteLength+c.byteLength+l.byteLength+u.byteLength,f=new ArrayBuffer(this.HEADER_LENGTH+d),p=new Uint8Array(f),m=new DataView(f),h=0;m.setUint8(h++,this.KINDS.push),m.setUint8(h++,s.byteLength),m.setUint8(h++,c.byteLength),m.setUint8(h++,l.byteLength),m.setUint8(h++,u.byteLength),p.set(s,h),h+=s.byteLength,p.set(c,h),h+=c.byteLength,p.set(l,h),h+=l.byteLength,p.set(u,h),h+=u.byteLength;var g=new Uint8Array(f.byteLength+a.byteLength);return g.set(p,0),g.set(new Uint8Array(a),f.byteLength),g.buffer},assertFieldSize(e,t){if(e>255)throw Error(`unable to convert ${t} to binary: must be less than or equal to 255 bytes, but is ${e} bytes`)},binaryDecode(e){let t=new DataView(e),n=t.getUint8(0),r=new TextDecoder;switch(n){case this.KINDS.push:return this.decodePush(e,t,r);case this.KINDS.reply:return this.decodeReply(e,t,r);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,r)}},decodePush(e,t,n){let r=t.getUint8(1),i=t.getUint8(2),a=t.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,s=n.decode(e.slice(o,o+r));o+=r;let c=n.decode(e.slice(o,o+i));o+=i;let l=n.decode(e.slice(o,o+a));return o+=a,{join_ref:s,ref:null,topic:c,event:l,payload:e.slice(o,e.byteLength)}},decodeReply(e,t,n){let r=t.getUint8(1),i=t.getUint8(2),a=t.getUint8(3),o=t.getUint8(4),s=this.HEADER_LENGTH+this.META_LENGTH,c=n.decode(e.slice(s,s+r));s+=r;let l=n.decode(e.slice(s,s+i));s+=i;let u=n.decode(e.slice(s,s+a));s+=a;let d=n.decode(e.slice(s,s+o));s+=o;let f={status:d,response:e.slice(s,e.byteLength)};return{join_ref:c,ref:l,topic:u,event:m.reply,payload:f}},decodeBroadcast(e,t,n){let r=t.getUint8(1),i=t.getUint8(2),a=this.HEADER_LENGTH+2,o=n.decode(e.slice(a,a+r));a+=r;let s=n.decode(e.slice(a,a+i));return a+=i,{join_ref:null,ref:null,topic:o,event:s,payload:e.slice(a,e.byteLength)}}},w=class{constructor(e,t){this.socket=e,this.transport=t,this.joins=new WeakMap,this.pings=new Map,this.closing=!1,this.ended=!1,this.channelsErrored=!1,this.closeHandled=!1,t.onopen=()=>{this.isCurrent()&&e.onConnOpen()},t.onerror=t=>{this.isCurrent()&&e.onConnError(t)},t.onmessage=t=>{this.isCurrent()&&e.onConnMessage(t)},t.onclose=t=>{this.isCurrent()&&!this.closeHandled&&(this.closeHandled=!0,e.onConnClose(t))}}isCurrent(){return this.socket.connection===this}isOpen(){return this.transport.readyState===l.open}isConnecting(){return this.transport.readyState===l.connecting}carried(e,t=e.joinRef()){return this.joins.has(e)&&this.joins.get(e)===t}close(e,t){this.closing=!0,this.transport.onerror=function(){},e?this.transport.close(e,t||``):this.transport.close()}},T=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.fallbackErrorRef=null,this.timeout=t.timeout||d,this.transport=t.transport||s.WebSocket||S,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||s&&s.sessionStorage,this.establishedConnections=0,this.defaultEncoder=C.encode.bind(C),this.defaultDecoder=C.decode.bind(C),this.closeWasClean=!0,this.binaryType=t.binaryType||`arraybuffer`,this.connection=null,this.connectClock=1,this.visibilityConnection=null,this.transport===S?(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder):(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder);let n=null;o&&o.addEventListener&&(o.addEventListener(`pagehide`,e=>{this.connection&&!this.connection.ended&&(this.disconnect(),n=this.connectClock)}),o.addEventListener(`pageshow`,e=>{n===this.connectClock&&(n=null,this.connect())}),o.addEventListener(`visibilitychange`,()=>{this.handleVisibilityChange()}),o.document&&o.document.addEventListener(`resume`,()=>{this.handleVisibilityChange()})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=e=>t.rejoinAfterMs?t.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>t.reconnectAfterMs?t.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(e,t,n)=>{console.log(`${e}: ${t}`,n)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=i(t.params||{}),this.endPoint=`${e}/${h.websocket}`,this.vsn=t.vsn||c,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new y(()=>{this.pageHidden?(this.log(`Not reconnecting as page is hidden!`),this.teardown()):this.teardownAndReconnect(()=>this.connect())},this.reconnectAfterMs),this.authToken=t.authToken&&i(t.authToken)}get conn(){return this.connection&&this.connection.transport}get pageHidden(){return o&&o.document?o.document.visibilityState===`hidden`:!1}handleVisibilityChange(){if(this.pageHidden){this.visibilityConnection=null;return}let e=this.connection;e&&e===this.visibilityConnection&&e.isConnecting()||!this.isConnected()&&!this.closeWasClean&&(this.reconnectTimer.reset(),this.teardownAndReconnect(()=>{this.connect(),this.visibilityConnection=this.connection}))}getLongPollTransport(){return S}replaceTransport(e){let t=++this.connectClock;this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.transport=e;let n=this.connection;if(n){let e=n.isOpen();this.connection=null,n.ended=!0,n.close(),this.clearHeartbeats(),e&&this.triggerChanError(`connection_closed`,n)}return t}protocol(){return location.protocol.match(/^https/)?`wss`:`ws`}endPointURL(){let e=x.appendParams(x.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)===`/`?e.charAt(1)===`/`?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`:e}disconnect(e,t,n){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.connection&&(this.connection.ended=!0),this.teardown(e,t,n)}connect(e){e&&(console&&console.log(`passing params to connect is deprecated. Instead pass :params to the Socket constructor`),this.params=i(e)),(!this.connection||this.connection.ended)&&(this.longPollFallbackMs&&this.transport!==S?this.connectWithFallback(S,this.longPollFallbackMs):this.transportConnect())}log(e,t,n){this.logger&&this.logger(e,t,n)}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),n=Date.now();return this.connection.pings.set(t,()=>e(Date.now()-n)),this.push({topic:`phoenix`,event:`heartbeat`,payload:{},ref:t}),!0}transportName(e){switch(e){case S:return`LongPoll`;default:return e.name}}transportConnect(){let e=this.connection;this.connectClock++,this.closeWasClean=!1,clearTimeout(this.reconnectTimer.timer);let t;this.authToken&&(t=[`phoenix`,`${_}${btoa(this.authToken()).replace(/=/g,``)}`]);let n=new this.transport(this.endPointURL(),t);n.binaryType=this.binaryType,n.timeout=this.longpollerTimeout,this.connection=new w(this,n),e&&e.isOpen()&&this.triggerChanError(`connection_closed`,e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){this.cancelFallback();let n=!1,r=!0,i,a,o=()=>a===this.connectClock&&!this.closeWasClean,s=this.transportName(e),c=t=>{this.log(`transport`,`falling back to ${s}...`,t),this.off([i]),r=!1,this.replaceTransport(e)===this.connectClock&&this.transportConnect()};if(this.getSession(`phx:fallback:${s}`))return c(`memorized`);this.fallbackTimer=setTimeout(c,t),i=this.fallbackErrorRef=this.onError(e=>{o()&&(this.log(`transport`,`error`,e),r&&!n&&(clearTimeout(this.fallbackTimer),c(e)))}),this.fallbackRef=this.onOpen(()=>{if(!r){if(this.transport!==e||this.closeWasClean)return;let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t}`,`true`),this.log(`transport`,`established ${t} fallback`)}o()&&(n=!0,clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(c,t),this.ping(e=>{this.log(`transport`,`connected to primary after`,e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)}))}),this.transportConnect(),a=this.connectClock}cancelFallback(){clearTimeout(this.fallbackTimer),this.off([this.fallbackRef,this.fallbackErrorRef])}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer),this.pendingHeartbeatRef=null}onConnOpen(){this.hasLogger()&&this.log(`transport`,`${this.transportName(this.transport)} connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,e])=>e())}heartbeatTimeout(){if(this.pendingHeartbeatRef){let e=this.connection;if(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log(`transport`,`heartbeat timeout. Attempting to re-establish connection`),this.closeWasClean=!1,e&&e.close(f,`heartbeat timeout`),!this.stillUses(e)||(this.triggerChanError(`heartbeat_timeout`),!this.stillUses(e)))return;this.teardownAndReconnect(()=>this.reconnectTimer.scheduleTimeout())}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardownAndReconnect(e){let t=this.connection,n=this.connectClock;this.teardown(()=>{n!==this.connectClock||t&&t.ended||e()})}stillUses(e){return this.connection===e&&!(e&&e.ended)}teardown(e,t,n){let r=this.connection;if(!r)return e&&e();this.clearHeartbeats(),this.waitForBufferDone(r.transport,()=>{if(!r.closing){let e=!r.isConnecting();r.close(t,n),e&&this.triggerChanError(`connection_closed`,r)}this.waitForSocketClosed(r.transport,()=>{this.connection===r&&(this.connection=null),e&&e()})})}waitForBufferDone(e,t,n=1){n===5||!e.bufferedAmount||e.readyState!==l.open?t():setTimeout(()=>{this.waitForBufferDone(e,t,n+1)},150*n)}waitForSocketClosed(e,t,n=1){n===5||e.readyState===l.closed?t():setTimeout(()=>{this.waitForSocketClosed(e,t,n+1)},150*n)}onConnClose(e){let t=this.connection;this.hasLogger()&&this.log(`transport`,`close`,e),this.clearHeartbeats();let n=!!(t&&t.closing);this.triggerChanError(`connection_closed`,t),this.stillUses(t)&&!n&&!this.closeWasClean&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,t])=>t(e))}onConnError(e){let t=this.connection;this.hasLogger()&&this.log(`transport`,`error`,e);let n=this.transport,r=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,t])=>{t(e,n,r)}),this.triggerChanError(`connection_error`,t)}triggerChanError(e,t=this.connection){let n=!1;t&&!t.isOpen()&&(n=t.channelsErrored,t.channelsErrored=!0),this.channels.map(e=>[e,e.joinRef()]).forEach(([r,i])=>{r.joinRef()===i&&(!t||!n&&t.isCurrent()||t.carried(r,i))&&(r.isErrored()||r.isLeaving()||r.isClosed()||r.trigger(m.error,{source:`transport`,reason:e}))})}connectionState(){switch(this.conn&&this.conn.readyState){case l.connecting:return`connecting`;case l.open:return`open`;case l.closing:return`closing`;default:return`closed`}}isConnected(){return this.connectionState()===`open`}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([t])=>e.indexOf(t)===-1)}channel(e,t={}){let n=new b(e,t,this);return this.channels.push(n),n}push(e,t){if(this.hasLogger()){let{topic:t,event:n,payload:r,ref:i,join_ref:a}=e;this.log(`push`,`${t} ${n} (${a}, ${i})`,r)}this.isConnected()?this.send(e,t):this.sendBuffer.push(()=>{this.isOutdated(e,t)||this.send(e,t)})}send(e,t){let n=this.connection;t&&e.event===m.join&&n.joins.set(t,e.join_ref),this.encode(e,r=>{n.isCurrent()&&n.isOpen()&&(e.event!==m.leave&&this.isOutdated(e,t)||n.transport.send(r))})}isOutdated(e,t){return!!t&&(e.join_ref!==t.joinRef()||t.isClosed())}makeRef(){let e=this.ref+1;return this.ref=e===this.ref?0:e,this.ref.toString()}sendHeartbeat(){(!this.pendingHeartbeatRef||this.isConnected())&&(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:`phoenix`,event:`heartbeat`,payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){let t=this.connection,n=t&&t.isOpen();this.decode(e.data,e=>{if(t!==this.connection||n&&!t.isOpen())return;let{topic:r,event:i,payload:a,ref:o,join_ref:s}=e;o&&o===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log(`receive`,`${a.status||``} ${r} ${i} ${o&&`(`+o+`)`||``}`,a);let c=this.channels;for(let e=0;e<c.length;e++){let t=c[e];t.isMember(r,i,a,s)&&t.trigger(i,a,o,s)}let l=this.stateChangeCallbacks.message;for(let t=0;t<l.length;t++){let[,n]=l[t];n(e)}let u=o&&t.pings.get(o);u&&(t.pings.delete(o),u())})}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log(`transport`,`leaving duplicate topic "${e}"`),t.leave())}},E=1e3,D=1e3,O=150,te=2,ne=3e4,re=1e4,ie=60,ae=class{probe;onChange;now;quality=`good`;rtt=null;rtts=[];pings=0;stalls=0;stallMs=0;maxStallMs=0;unstableMs=0;offlineMs=0;reconnects=0;everOnline=!1;wasOnline=!1;pingSentAt=null;stallSince=null;lastIssueAt=-1/0;slowAt=[];lastPingAt=-1/0;lastTick;timer=null;constructor(e,t,n=()=>performance.now()){this.probe=e,this.onChange=t,this.now=n,this.lastTick=n()}start(e=250){this.stop(),this.timer=setInterval(()=>this.tick(),e)}stop(){this.timer&&clearInterval(this.timer),this.timer=null}tick(){let e=this.now(),t=e-this.lastTick;this.lastTick=e,this.quality===`unstable`&&(this.unstableMs+=t),this.quality===`offline`&&(this.offlineMs+=t);let n=this.probe.online();n&&!this.wasOnline&&(this.everOnline&&this.reconnects++,this.everOnline=!0),!n&&this.wasOnline&&this.endStall(e),this.wasOnline=n,n?(this.pingSentAt!==null&&this.stallSince===null&&e-this.pingSentAt>=D&&(this.stallSince=this.pingSentAt),this.pingSentAt===null&&e-this.lastPingAt>=E&&this.sendPing(e)):this.pingSentAt=null;let r=n?this.stallSince!==null||e-this.lastIssueAt<re||this.recentSlow(e)>=te?`unstable`:`good`:this.everOnline?`offline`:`good`;r!==this.quality&&(this.quality=r,this.onChange(r))}report(){let e=[...this.rtts].sort((e,t)=>e-t),t=t=>Math.round(e[Math.min(e.length-1,Math.floor(t*e.length))]);return{q:this.quality===`good`?`good`:`unstable`,rtt:e.length?[t(.5),t(.95),Math.round(e[e.length-1])]:null,pings:this.pings,stalls:this.stalls,stall_ms:Math.round(this.stallMs),max_stall_ms:Math.round(this.maxStallMs),unstable_ms:Math.round(this.unstableMs),offline_ms:Math.round(this.offlineMs),reconnects:this.reconnects}}sendPing(e){this.lastPingAt=e,this.probe.ping(t=>{if(this.pingSentAt!==e)return;let n=this.now();this.pingSentAt=null,this.pings++,this.rtt=t,this.rtts.push(t),this.rtts.length>ie&&this.rtts.shift();let[r,i,a]=this.rtts.slice(-3);a!==void 0&&i>=r+O&&i>=a+O&&this.slowAt.push(n),this.endStall(n),this.tick()})&&(this.pingSentAt=e)}recentSlow(e){for(;this.slowAt.length&&e-this.slowAt[0]>=ne;)this.slowAt.shift();return this.slowAt.length}endStall(e){if(this.stallSince===null)return;let t=e-this.stallSince;this.stalls++,this.stallMs+=t,this.maxStallMs=Math.max(this.maxStallMs,t),this.stallSince=null,this.lastIssueAt=e}},k=[80,160,320,640,1e3];function oe(e,t=Math.random){let n=k[Math.min(Math.max(e,1),k.length)-1],r=Math.round(n*.2),i=Math.min(Math.max(t(),0),.999999);return n-r+Math.floor(i*(r*2+1))}var se=class{options;participants=new Map;status=`connecting`;you=null;livekit=null;account=null;socket=null;channel=null;bySlot=new Map;listeners=new Map;flags=t.alt;renames=new Map;cursor=null;sentCursor=null;moveScheduled=!1;lastMoveAt=0;localState={};follow=`all`;monitor=null;reportTimer=null;offPageHide=null;tabs=null;control=null;serverStop=!1;constructor(e){this.options=e}on(e,t){let n=this.listeners.get(e);return n||this.listeners.set(e,n=new Set),n.add(t),()=>n.delete(t)}emit(e,t){for(let n of this.listeners.get(e)??[])n(t)}get me(){return this.you?this.participants.get(this.you):void 0}hasFlag(e){return(this.flags&t[e])!==0}connect(){let e=this.options,t=()=>this.reportNet();window.addEventListener(`pagehide`,t),this.offPageHide=()=>window.removeEventListener(`pagehide`,t),this.socket=new T(e.url,{params:e.apiToken?{api_token:e.apiToken}:{},heartbeatIntervalMs:e.heartbeatMs??5e3,reconnectAfterMs:e=>oe(e),rejoinAfterMs:e=>[100,500,1e3,2e3][e-1]??5e3,logger:e.logger}),this.socket.onClose(()=>this.setStatus(`disconnected`)),this.socket.connect();let n=this.socket;this.monitor=new ae({ping:e=>n.ping(e),online:()=>n.isConnected()&&this.status===`joined`},e=>{this.emit(`quality`,e),this.reportNet()}),this.monitor.start(),this.reportTimer=setInterval(()=>this.reportNet(),1e4),this.channel=this.socket.channel(`room:${e.roomId}`,()=>this.joinParams()),this.channel.on(`snapshot`,e=>this.onSnapshot(e)),this.channel.on(`presence`,e=>this.onPresence(e)),this.channel.on(`cursors`,e=>this.onCursors(e)),this.channel.on(`state`,e=>this.onState(e)),this.channel.on(`click`,e=>this.emit(`click`,e)),this.channel.on(`wheel`,e=>this.emit(`wheel`,e)),this.channel.on(`account`,({account:e})=>{this.account=e,this.emit(`account`,e)});let r=this.channel;this.whenResumeIsFree(()=>this.join(r)),r.onError(()=>this.setStatus(`disconnected`))}join(e){e===this.channel&&e.join().receive(`ok`,({you:e,resume:t,stopped:n})=>{this.you=e,t&&this.storage?.setItem(this.resumeKey,t),this.serverStop=typeof n==`boolean`}).receive(`error`,({reason:e,code:t})=>{if(t!==`refused`)return this.setStatus(`disconnected`);this.setStatus(`refused`),this.emit(`refused`,e),this.disconnect()})}whenResumeIsFree(e){if(typeof BroadcastChannel>`u`)return e();let t=this.tabs=new BroadcastChannel(`liveroom:${this.options.roomId}`),n=this.storage?.getItem(this.resumeKey)||null,r=!1;if(t.onmessage=({data:e})=>{let i=this.storage?.getItem(this.resumeKey);e?.type===`who`&&i&&e.resume===i&&this.status===`joined`?t.postMessage({type:`mine`,resume:i}):e?.type===`mine`&&n&&e.resume===n&&(r=!0)},!n)return e();t.postMessage({type:`who`,resume:n}),setTimeout(()=>{r&&this.storage?.setItem(this.resumeKey,``),e()},150)}disconnect(){for(let e of[...this.renames.keys()])this.flushRename(e);this.reportNet(),this.monitor?.stop(),this.reportTimer&&clearInterval(this.reportTimer),this.offPageHide?.(),this.tabs?.close(),this.tabs=null,this.monitor=null,this.reportTimer=null,this.offPageHide=null,this.channel?.leave(),this.socket?.disconnect(),this.channel=null,this.socket=null}get quality(){return this.monitor?.quality??`good`}get rtt(){return this.monitor?.rtt??null}reportNet(){this.monitor&&this.push(`net`,this.monitor.report())}setStatus(e){this.status!==`refused`&&this.status!==e&&(this.status=e,this.emit(`status`,e))}get storage(){if(this.options.storage!==void 0)return this.options.storage;try{return window.sessionStorage}catch{return null}}get resumeKey(){return`liveroom-resume:${this.options.roomId}`}joinParams(){let e=this.options;return j({v:2,room_token:e.roomToken,type:e.type,resume:this.storage?.getItem(this.resumeKey)||void 0,name:e.name??void 0,color:e.color??void 0,viewport:e.viewport?.()??this.localState.viewport,cursor:this.cursor?this.cursor.map(n):void 0,net:this.monitor&&this.monitor.quality!==`good`?`unstable`:void 0,...e.analytics})}onSnapshot(e){this.you=e.you,this.livekit=e.livekit,this.account=e.account,this.participants.clear(),this.bySlot.clear();for(let t of Object.values(e.users))this.put(t);this.setStatus(`joined`),this.sentCursor=null,this.push(`f`,this.flags),Object.keys(this.localState).length&&this.push(`s`,this.localState),this.follow!==`all`&&this.push(`follow`,this.follow),this.reportNet(),this.flushMove(),this.flushControl(),this.emit(`snapshot`,void 0),this.emit(`account`,this.account)}onPresence(e){let t=Object.values(e.joins).map(e=>(this.put(e),e.id));for(let t of e.leaves){let e=this.participants.get(t);e&&this.bySlot.delete(e.slot),this.participants.delete(t)}let n=[];for(let[t,r]of Object.entries(e.updates)){let e=this.participants.get(t);e&&(Object.assign(e,r),n.push(t))}this.emit(`presence`,{joined:t,left:e.leaves,updated:n})}onCursors({t:e,c:t}){let n=[];for(let i=0;i+3<t.length;i+=4){let a=this.bySlot.get(t[i]),o=a?this.participants.get(a):void 0;o&&(o.x=r(t[i+1]),o.y=r(t[i+2]),o.flags=t[i+3],o.cursorAt=e,n.push(o.id))}n.length&&this.emit(`cursors`,{ids:n,t:e})}onState(e){let t=[];for(let[n,r]of Object.entries(e)){let e=this.participants.get(n);e&&(Object.assign(e,r),t.push(n))}t.length&&this.emit(`state`,{ids:t})}put(e){this.participants.set(e.id,{...e,x:r(e.x),y:r(e.y),cursorAt:0}),this.bySlot.set(e.slot,e.id)}push(e,t){this.channel&&this.status===`joined`&&this.channel.push(e,t)}move(e,t){if(this.cursor=[e,t],this.moveScheduled)return;if(performance.now()-this.lastMoveAt>=15)return this.flushMove();this.moveScheduled=!0;let n=()=>{this.moveScheduled=!1,this.flushMove()};typeof document<`u`&&document.visibilityState===`visible`&&typeof requestAnimationFrame==`function`?requestAnimationFrame(n):setTimeout(n,16)}flushMove(){if(!this.cursor)return;let e=[n(this.cursor[0]),n(this.cursor[1])];this.sentCursor&&e[0]===this.sentCursor[0]&&e[1]===this.sentCursor[1]||this.status===`joined`&&(this.sentCursor=e,this.lastMoveAt=performance.now(),this.push(`m`,e))}setFlag(e,n){let r=n?this.flags|t[e]:this.flags&~t[e];r!==this.flags&&(this.flags=r,this.flushMove(),this.push(`f`,r),this.emit(`flags`,r))}toggleFlag(e){this.setFlag(e,!this.hasFlag(e))}get ownFlags(){return this.flags}setState(e){e.url&&(e={...e,url:A(e.url)}),Object.assign(this.localState,e),this.push(`s`,e)}stop(){this.control=`stop`,this.flushControl()}resume(){this.control=`resume`,this.flushControl()}flushControl(){this.control&&this.status===`joined`&&this.serverStop&&(this.push(this.control,{}),this.control=null)}click(e){this.flushMove(),this.push(`click`,{to:e,...this.cursorPayload()})}wheel(e,t,n){this.flushMove(),this.push(`wheel`,{to:e,dx:Math.round(t),dy:Math.round(n),...this.cursorPayload()})}cursorPayload(){return this.cursor?{x:n(this.cursor[0]),y:n(this.cursor[1])}:{}}rename(e,t){let n=this.renames.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>this.flushRename(e),250);this.renames.set(e,{name:t,timer:r})}flushRename(e){let t=this.renames.get(e);t&&(clearTimeout(t.timer),this.renames.delete(e),this.push(`rename`,{id:e,name:t.name}))}cameras(e){this.push(`cameras`,{enabled:e})}presenter(e){this.push(`presenter`,{name:e})}setFollow(e){e===this.follow||Array.isArray(e)&&Array.isArray(this.follow)&&e.length===this.follow.length&&e.every((e,t)=>e===this.follow[t])||(this.follow=e,this.push(`follow`,e))}},ce=2048;function A(e){return e.length>2048?e.slice(0,ce):e}function j(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`string`?A(t):t]))}var M=`
3
3
  .lr-cursors { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2147483646; }
4
4
  .lr-user { position: absolute; top: 0; left: 0; user-select: none; will-change: transform; transform-origin: 0 0; }
5
5
  .lr-user[data-hidden="true"] { display: none; }
6
- .lr-cursor { position: absolute; top: 0; left: 0; color: var(--color); transform-origin: top left; transform: rotate(6deg);
6
+ .lr-cursor { position: absolute; top: 0; left: 0; color: var(--color); transform-origin: top left; rotate: 6deg;
7
+ transition: rotate 200ms cubic-bezier(0.22, 1, 0.36, 1);
7
8
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.2)); overflow: visible; }
9
+ .lr-user[data-flip="true"]:not([data-live="true"]):not([data-focus="true"]):not([data-focus-motion="true"]) .lr-cursor { rotate: 88deg; }
8
10
  /* Guests are light pastels: the dark contour keeps the arrow visible on white pages.
9
11
  Hosts are deep fills: a white ring keeps the arrow visible on dark pages and Meet.
10
12
  Role is the participant type already on the wire. The path touches the viewBox's
11
13
  top edge, hence the svg's visible overflow. */
12
14
  .lr-cursor path { stroke: rgb(0 0 0 / 0.6); stroke-width: 3; stroke-linejoin: round; paint-order: stroke fill; }
13
15
  .lr-user[data-type="admin"] .lr-cursor path { stroke: rgb(255 255 255/.92); }
14
- .lr-label { position: absolute; top: 18px; left: 14px; font: 600 12px/1.6 system-ui, sans-serif; color: black;
16
+ .lr-label { position: absolute; top: 18px; left: 0; translate: 14px 0;
17
+ transition: translate 200ms cubic-bezier(0.22, 1, 0.36, 1);
18
+ font: 600 12px/1.6 "Geist", system-ui, sans-serif; color: black;
15
19
  background: var(--color); border-radius: 9999px; padding: 0 8px; white-space: nowrap;
16
20
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12), 0 1px 2px rgb(0 0 0 / 0.08);
17
21
  display: flex; flex-direction: column; align-items: center; overflow: hidden; max-width: 200px; text-overflow: ellipsis; }
22
+ .lr-user[data-flip="true"]:not([data-live="true"]):not([data-focus="true"]):not([data-focus-motion="true"]) .lr-label {
23
+ translate: calc(-100% - 14px) 0; }
18
24
  .lr-user[data-type="admin"] .lr-label { color: white; }
19
25
  .lr-user[data-type="admin"]:not([data-live="true"]):not([data-focus-motion="true"]) .lr-label {
20
26
  box-shadow: 0 0 0 1.5px rgb(255 255 255/.92), 0 1px 3px rgb(0 0 0/.2); }
@@ -24,7 +30,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
24
30
  .lr-label video { display: none; width: 170.6667px; height: 96px; object-fit: cover; margin: 0; }
25
31
  /* Keep the same 16:9 video surface. The small bubble is a circular crop. */
26
32
  .lr-user[data-live="true"] .lr-label, .lr-user[data-focus-motion="true"] .lr-label {
27
- padding: 0; border-radius: 0; top: 10px; left: -31.3333px; width: 170.6667px; height: 96px;
33
+ padding: 0; border-radius: 0; top: 10px; left: -31.3333px; translate: none; transition: none; width: 170.6667px; height: 96px;
28
34
  background: transparent; box-shadow: none; overflow: visible;
29
35
  }
30
36
  .lr-user[data-live="true"] .lr-label video, .lr-user[data-focus-motion="true"] .lr-label video {
@@ -37,11 +43,19 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
37
43
  transform: translateX(-50%) scale(calc(1 / var(--focus-scale, 1))); transform-origin: top center;
38
44
  transition: opacity 200ms ease, visibility 200ms ease;
39
45
  }
46
+ .lr-ripple { position: absolute; top: -12px; left: -12px; width: 24px; height: 24px; border-radius: 9999px;
47
+ background: var(--color); opacity: 0; z-index: -1; pointer-events: none; }
48
+ /* Two identical keyframes let us restart the animation by alternating data-anim
49
+ between "a" and "b" without forcing a synchronous reflow. */
50
+ .lr-ripple[data-anim="a"] { animation: lr-click-a 450ms ease-out; }
51
+ .lr-ripple[data-anim="b"] { animation: lr-click-b 450ms ease-out; }
52
+ @keyframes lr-click-a { 0% { opacity: 0.55; transform: scale(0.4); } 100% { opacity: 0; transform: scale(1.65); } }
53
+ @keyframes lr-click-b { 0% { opacity: 0.55; transform: scale(0.4); } 100% { opacity: 0; transform: scale(1.65); } }
40
54
  .lr-halo { position: absolute; top: -60px; left: -60px; width: 120px; height: 120px; border-radius: 9999px; z-index: -1;
41
55
  border: 1px solid color-mix(in srgb, var(--color) 75%, transparent); background: color-mix(in srgb, var(--color) 25%, transparent);
42
56
  transform: scale(0); transition: transform 200ms ease-in-out; }
43
57
  .lr-user[data-halo="true"] .lr-halo { transform: scale(1); }
44
- .lr-user[data-self="true"] .lr-cursor, .lr-user[data-self="true"] .lr-label { display: none; }
58
+ .lr-user[data-self="true"] .lr-cursor, .lr-user[data-self="true"] .lr-label, .lr-user[data-self="true"] .lr-ripple { display: none; }
45
59
  .lr-cursors::before { content: ""; position: absolute; inset: 0; background: rgb(39 39 42 / 25%); backdrop-filter: blur(6px); opacity: 0; transition: opacity 200ms ease; }
46
60
  .lr-cursors[data-focus="true"]::before { opacity: 1; }
47
61
  .lr-user[data-focus-motion="true"] { transition: transform 250ms cubic-bezier(0.77, 0, 0.175, 1); }
@@ -49,9 +63,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
49
63
  .lr-user[data-focus="true"] .lr-label video { clip-path: inset(0 round 4px); }
50
64
  .lr-user[data-focus="true"] .lr-label > span { opacity: 1; visibility: visible; }
51
65
  .lr-user[data-focus="true"]:not([data-live="true"]) .lr-label { background: #18181b; border-radius: 4px; }
52
- .lr-user[data-focus="true"] .lr-cursor, .lr-user[data-focus="true"] .lr-halo { opacity: 0; }
66
+ .lr-user[data-focus="true"] .lr-cursor, .lr-user[data-focus="true"] .lr-halo, .lr-user[data-focus="true"] .lr-ripple { opacity: 0; }
53
67
  @media (prefers-reduced-motion: reduce) {
54
68
  .lr-user[data-focus-motion="true"], .lr-label video { transition: none !important; }
69
+ .lr-cursor, .lr-label { transition: none !important; }
70
+ .lr-ripple { animation: none !important; }
55
71
  .lr-cursors::before, .lr-label > span { transition-duration: 100ms; }
56
72
  .lr-user[data-net] .lr-label span::before { animation: none; }
57
73
  .lr-halo { transition: none !important; }
@@ -61,19 +77,23 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
61
77
  .lr-user[data-net="unstable"] .lr-label span::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 5px 1px 0;
62
78
  border-radius: 50%; background: #d97706; box-shadow: 0 0 0 1px rgb(255 255 255 / 70%); animation: lr-pulse 1.2s ease-in-out infinite; }
63
79
  @keyframes lr-pulse { 50% { opacity: 0.3; } }
64
- `,L=`<svg width="23" viewBox="0 0 27 24" fill="currentColor" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M2.27 0.06L25.43 8.06C25.66 8.13 25.83 8.26 25.95 8.43C26.07 8.59 26.14 8.79 26.14 8.99C26.14 9.2 26.07 9.4 25.95 9.56C25.83 9.73 25.66 9.86 25.46 9.93L15.35 13.77L11.31 23.37C11.23 23.56 11.1 23.72 10.92 23.83C10.75 23.94 10.54 24 10.33 24C10.12 24 9.91 23.94 9.73 23.82C9.55 23.7 9.42 23.53 9.34 23.34L0.92 1.34C0.86 1.16 0.84 0.97 0.89 0.78C0.93 0.6 1.03 0.43 1.17 0.29C1.31 0.16 1.49 0.07 1.68 0.02C1.88 -0.02 2.08 -0.01 2.27 0.06Z"/></svg>`,R=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,z=e=>R.test(e)?e:`#a3a3a3`;function B(e,t,n){e.dataset[t]!==n&&(e.dataset[t]=n)}var V=class{root;options;nodes=new Map;frame=0;style;trace;constructor(e){this.options={smooth:!0,minSmoothGapMs:24,maxSmoothMs:80,...e};let t=e.container.ownerDocument;this.style=t.createElement(`style`),this.style.textContent=I,(e.styleRoot.nodeType===9?e.styleRoot.head:e.styleRoot).appendChild(this.style),this.trace=t.documentElement.hasAttribute(`data-liveroom-trace`),this.root=t.createElement(`div`),this.root.className=`lr-cursors`,e.container.appendChild(this.root)}destroy(){cancelAnimationFrame(this.frame),this.root.remove(),this.style.remove();for(let e of this.nodes.values())clearTimeout(e.focusExitTimer);this.nodes.clear()}videoFor(e){return this.nodes.get(e)?.video}sync(e){let t=new Set;for(let n of e)t.add(n.id),this.update(n);for(let[e,n]of this.nodes)t.has(e)||(clearTimeout(n.focusExitTimer),n.el.remove(),this.nodes.delete(e));this.updateFocus()}setFocusScale(e){let t=e.ownerDocument.defaultView,n=Math.min(4,(t?.innerWidth??1e3)*.8/(512/3),(t?.innerHeight??800)*.7/96);e.style.setProperty(`--focus-scale`,String(n))}updateFocus(){B(this.root,`focus`,String(!!this.root.querySelector(`[data-focus="true"]`)))}update(e){let n=this.nodes.get(e.id)??this.create(e),r=n.el,i=z(e.color);r.style.getPropertyValue(`--color`)!==i&&r.style.setProperty(`--color`,i),n.label.firstChild.textContent!==e.name&&(n.label.firstChild.textContent=e.name),n.video.getAttribute(`aria-label`)!==e.name&&n.video.setAttribute(`aria-label`,e.name),B(r,`type`,e.type===`admin`?`admin`:`client`),B(r,`self`,String(!!e.self)),B(r,`camera`,String((e.camera||e.type===`admin`&&(e.flags&t.focus)!==0)&&!e.self));let a=String(e.type===`admin`&&!e.self&&(e.flags&t.focus)!==0);r.dataset.focus!==a&&(clearTimeout(n.focusExitTimer),(r.dataset.focus!==void 0||a===`true`)&&B(r,`focusMotion`,`true`),this.setFocusScale(r),B(r,`focus`,a),a===`false`&&r.dataset.focusMotion===`true`&&(n.focusExitTimer=setTimeout(()=>{B(r,`focusMotion`,`false`)},300)),this.updateFocus()),B(r,`blocked`,String(!!e.blocked)),B(r,`net`,e.net??`good`),B(r,`halo`,String((e.flags&t.shift)!==0||!e.self&&(e.flags&t.mouseDown)!==0)),this.setTarget(e.id,e.x,e.y)}setTarget(e,t,n,r=!1){let i=this.nodes.get(e);if(!i||!r&&i.target[0]===t&&i.target[1]===n)return;let a=this.options.map(t,n);if(i.target=[t,n],i.arrived=!1,i.el.dataset.hidden=String(!a),!a)return;let o=performance.now();i.fromX=i.x,i.fromY=i.y,i.toX=a.left,i.toY=a.top,i.start=o;let s=i.lastTargetAt===0?0:o-i.lastTargetAt;i.duration=this.options.smooth&&s>=this.options.minSmoothGapMs?Math.min(s,this.options.maxSmoothMs):0,i.lastTargetAt=o,i.duration===0?this.place(i,i.toX,i.toY,!0):this.schedule()}place(e,t,n,r,i=this.options.scale?.()??1){e.x=t,e.y=n,e.el.style.transform=`translate3d(${t}px, ${n}px, 0) scale(${i})`,r&&(e.arrived=!0,this.trace&&(e.el.dataset.x=e.target[0].toFixed(2),e.el.dataset.y=e.target[1].toFixed(2)))}relayout(){for(let[e,t]of this.nodes)t.el.dataset.focus===`true`&&this.setFocusScale(t.el),t.arrived=!1,t.lastTargetAt=0,this.setTarget(e,t.target[0],t.target[1],!0)}create(e){let t=this.root.ownerDocument.createElement(`div`);t.className=`lr-user`,t.id=`user-${e.id}`,t.innerHTML=`${L.replace(`<svg`,`<svg class="lr-cursor"`)}<div class="lr-label"><span></span><video autoplay muted playsinline></video></div><div class="lr-halo"></div>`;let n=t.querySelector(`.lr-label`);n.firstElementChild.textContent=e.name,this.root.appendChild(t);let r={el:t,label:n,video:t.querySelector(`video`),x:0,y:0,fromX:0,fromY:0,toX:0,toY:0,start:0,duration:0,lastTargetAt:0,target:[NaN,NaN],arrived:!1};return this.nodes.set(e.id,r),r}schedule(){this.frame||=requestAnimationFrame(()=>this.render())}render(){this.frame=0;let e=performance.now(),t=this.options.scale?.()??1,n=!1;for(let r of this.nodes.values()){if(r.arrived)continue;let i=r.duration>0?Math.min(1,(e-r.start)/r.duration):1,a=r.fromX+(r.toX-r.fromX)*i,o=r.fromY+(r.toY-r.fromY)*i;this.place(r,a,o,i>=1,t),i<1&&(n=!0)}n&&this.schedule()}};function H(e,t){let n=e?.closest(`.lr-user`);n&&(n.dataset.live=String(t))}var U=(e,n)=>e.type===`admin`&&((e.id===n.you?n.ownFlags:e.flags)&t.focus)!==0,W=(e,t)=>e.camera||U(e,t),G=class{options;room=null;connecting=null;tracks=new Map;stopped=!1;requested=``;wasFocused=!1;focusExitTimer=null;failures=0;retryTimer=null;constructor(e){this.options=e;let{client:t}=e,n=()=>{if(this.stopped)return;let e=[...t.participants.values()],n=e.some(e=>U(e,t)),r=`${e.some(e=>W(e,t))}/${t.me?W(t.me,t):!1}/${n}/${this.warm()}`;r!==this.requested&&(this.requested=r,this.focusExitTimer&&clearTimeout(this.focusExitTimer),this.wasFocused&&!n?this.focusExitTimer=setTimeout(()=>{this.focusExitTimer=null,this.update()},300):this.update(),this.wasFocused=n)};t.on(`snapshot`,n),t.on(`presence`,n),t.on(`cursors`,n),t.on(`flags`,n)}reattach(){for(let[e,t]of this.tracks){let n=this.options.videoFor(e);n&&!t.attachedElements.includes(n)&&t.attach(n);let r=this.options.client.participants.get(e);H(n,!!r&&(W(r,this.options.client)||!!this.focusExitTimer))}}async stop(){this.stopped=!0,this.focusExitTimer&&clearTimeout(this.focusExitTimer),this.focusExitTimer=null,this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=null,await this.room?.disconnect(),this.room=null,this.clearTracks()}warm(){return!!this.options.preconnect&&[...this.options.client.participants.values()].some(e=>e.type===`admin`)}scheduleRetry(){if(this.stopped||this.retryTimer)return;let e=Math.min(1e3*2**this.failures,15e3);this.failures++,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.update()},e)}clearTracks(){for(let e of this.tracks.keys())H(this.options.videoFor(e),!1);this.tracks.clear()}async update(){if(this.stopped)return;let{client:e}=this.options;if((this.warm()||[...e.participants.values()].some(t=>W(t,e)))&&!this.room&&!this.connecting&&e.livekit&&(this.connecting=this.connect().finally(()=>this.connecting=null)),this.connecting&&await this.connecting,!this.stopped){if(!this.warm()&&![...e.participants.values()].some(t=>W(t,e))&&this.room){let e=this.room;this.room=null,this.clearTracks(),await e.disconnect()}else{if(this.room&&this.options.publish){let t=e.me?W(e.me,e):!1;this.room.localParticipant.isCameraEnabled!==t&&await this.room.localParticipant.setCameraEnabled(t).catch(e=>this.options.log?.(`camera`,e))}this.reattach()}}}async connect(){let{client:e}=this.options,{Room:t,RoomEvent:n,Track:r}=await Promise.resolve().then(()=>require("./livekit-client.esm-DiyxitqE.cjs")),i=new t({dynacast:!0,adaptiveStream:!0});i.on(n.TrackSubscribed,(e,t,n)=>{t.source===r.Source.Camera&&(this.tracks.set(n.identity,e),this.reattach())}),i.on(n.TrackUnsubscribed,(e,t,n)=>{this.tracks.delete(n.identity),H(this.options.videoFor(n.identity),!1)}),i.on(n.Disconnected,()=>{this.room===i&&(this.room=null,this.clearTracks(),this.scheduleRetry())});try{if(await i.connect(e.livekit.url,e.livekit.token,{autoSubscribe:!0}),this.stopped)return void i.disconnect();this.room=i,this.failures=0}catch(e){this.options.log?.(`livekit connect failed`,e),this.scheduleRetry()}}},ae=`16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function K(e){return`:host { all: initial !important; display: block !important; font: ${ae} !important; color: #0f172a !important; text-align: left !important; direction: ltr !important; ${e.split(`;`).map(e=>e.trim()).filter(Boolean).map(e=>`${e.replace(/\s*!important$/,``)} !important;`).join(` `)} }`}var q=`#94A3B8`,J=`#F59E0B`,oe=`#EF4444`,se=3e3,ce=600;function Y(e){let t=le(e.people),n=t.filter(e=>e.pointed),r=n.some(e=>e.clicks),i=e.stopped&&t.length>0,a=n.length>0&&!e.stopped,o=e.quality!==`good`;if(!i&&!a&&!o)return{visible:!1,label:``,button:null,dots:[],quality:null};let s=i&&e.sinceStopMs!==null&&e.sinceStopMs<se,c=i?pe(t,e.sinceStopMs!==null&&e.sinceStopMs<ce):a?fe(n,r):null;return{visible:!0,label:o?e.quality===`offline`?`Reconnecting…`:`Unstable connection`:i?de(t,s):ue(n,r),button:c,dots:o?[e.quality===`offline`?oe:J]:i?[q]:n.slice(0,3).map(e=>e.color),quality:e.quality===`good`?null:e.quality}}function le(e){return[...e].sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))}function ue(e,t){if(e.length===1)return t?`${e[0].name} can point and click`:`${e[0].name} is pointing`;if(e.length===2){let n=`${e[0].name} and ${e[1].name}`;return t?`${n} can point and click`:`${n} are pointing`}return t?`${e.length} people can point and click`:`${e.length} people are pointing`}function de(e,t){return t?e.length===1?`You stopped ${e[0].name}'s cursor`:`You stopped ${e.length} cursors`:e.length===1?`${e[0].name}'s cursor is off`:`${e.length} cursors are off`}function fe(e,t){return{text:`Stop`,ariaLabel:e.length===1?t?`Stop ${e[0].name}'s cursor and clicks`:`Stop ${e[0].name}'s cursor`:e.length===2?`Stop ${e[0].name}'s and ${e[1].name}'s cursors`:`Stop all ${e.length} cursors`,disabled:!1,action:`stop`}}function pe(e,t){if(e.length===1){let n=`Let ${e[0].name} point again`;return{text:n,ariaLabel:n,disabled:t,action:`resume`}}return{text:`Let them point again`,ariaLabel:e.length===2?`Let ${e[0].name} and ${e[1].name} point again`:`Let all ${e.length} point again`,disabled:t,action:`resume`}}var me=`
80
+ `,N=`<svg width="23" viewBox="0 0 27 24" fill="currentColor" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M2.27 0.06L25.43 8.06C25.66 8.13 25.83 8.26 25.95 8.43C26.07 8.59 26.14 8.79 26.14 8.99C26.14 9.2 26.07 9.4 25.95 9.56C25.83 9.73 25.66 9.86 25.46 9.93L15.35 13.77L11.31 23.37C11.23 23.56 11.1 23.72 10.92 23.83C10.75 23.94 10.54 24 10.33 24C10.12 24 9.91 23.94 9.73 23.82C9.55 23.7 9.42 23.53 9.34 23.34L0.92 1.34C0.86 1.16 0.84 0.97 0.89 0.78C0.93 0.6 1.03 0.43 1.17 0.29C1.31 0.16 1.49 0.07 1.68 0.02C1.88 -0.02 2.08 -0.01 2.27 0.06Z"/></svg>`,P=120,F=600,I=22,L=24,R=64,z=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,B=e=>z.test(e)?e:`#a3a3a3`;function V(e,t,n){e.dataset[t]!==n&&(e.dataset[t]=n)}var H=class{root;options;nodes=new Map;frame=0;style;trace;constructor(e){this.options={smooth:!0,minSmoothGapMs:24,maxSmoothMs:80,...e};let t=e.container.ownerDocument;this.style=t.createElement(`style`),this.style.textContent=M,(e.styleRoot.nodeType===9?e.styleRoot.head:e.styleRoot).appendChild(this.style),this.trace=t.documentElement.hasAttribute(`data-liveroom-trace`),this.root=t.createElement(`div`),this.root.className=`lr-cursors`,e.container.appendChild(this.root)}destroy(){cancelAnimationFrame(this.frame),this.root.remove(),this.style.remove();for(let e of this.nodes.values())clearTimeout(e.focusExitTimer);this.nodes.clear()}videoFor(e){return this.nodes.get(e)?.video}pulse(e,t){let n=this.nodes.get(e);if(!n||n.el.dataset.self===`true`)return;let r=performance.now();t?.fromClick&&(n.mouseDown||r-n.lastMouseDownAt<F)||r-n.lastPulseAt<P||(n.lastPulseAt=r,n.ripple.dataset.anim=n.ripple.dataset.anim===`a`?`b`:`a`)}sync(e){let t=new Set;for(let n of e)t.add(n.id),this.update(n);for(let[e,n]of this.nodes)t.has(e)||(clearTimeout(n.focusExitTimer),n.el.remove(),this.nodes.delete(e));this.updateFocus()}setFocusScale(e){let t=e.ownerDocument.defaultView,n=Math.min(4,(t?.innerWidth??1e3)*.8/(512/3),(t?.innerHeight??800)*.7/96);e.style.setProperty(`--focus-scale`,String(n))}updateFocus(){V(this.root,`focus`,String(!!this.root.querySelector(`[data-focus="true"]`)))}update(e){let n=this.nodes.get(e.id)??this.create(e),r=n.el,i=B(e.color);r.style.getPropertyValue(`--color`)!==i&&r.style.setProperty(`--color`,i),n.label.firstChild.textContent!==e.name&&(n.label.firstChild.textContent=e.name,n.labelDirty=!0),n.video.getAttribute(`aria-label`)!==e.name&&n.video.setAttribute(`aria-label`,e.name),V(r,`type`,e.type===`admin`?`admin`:`client`),V(r,`self`,String(!!e.self));let a=String((e.camera||e.type===`admin`&&(e.flags&t.focus)!==0)&&!e.self);r.dataset.camera!==a&&(V(r,`camera`,a),n.labelDirty=!0);let o=String(e.type===`admin`&&!e.self&&(e.flags&t.focus)!==0);r.dataset.focus!==o&&(clearTimeout(n.focusExitTimer),(r.dataset.focus!==void 0||o===`true`)&&V(r,`focusMotion`,`true`),this.setFocusScale(r),V(r,`focus`,o),o===`false`&&r.dataset.focusMotion===`true`&&(n.focusExitTimer=setTimeout(()=>{V(r,`focusMotion`,`false`),n.labelDirty=!0},300)),this.updateFocus()),V(r,`blocked`,String(!!e.blocked));let s=e.net??`good`;r.dataset.net!==s&&(V(r,`net`,s),n.labelDirty=!0);let c=!e.self&&(e.flags&t.mouseDown)!==0;c&&!n.mouseDown&&(n.lastMouseDownAt=performance.now(),this.pulse(e.id)),n.mouseDown=c,V(r,`halo`,String((e.flags&t.shift)!==0||c)),this.setTarget(e.id,e.x,e.y)}setTarget(e,t,n,r=!1){let i=this.nodes.get(e);if(!i||!r&&i.target[0]===t&&i.target[1]===n)return;let a=this.options.map(t,n);if(i.target=[t,n],i.arrived=!1,i.el.dataset.hidden=String(!a),!a)return;let o=performance.now();i.fromX=i.x,i.fromY=i.y,i.toX=a.left,i.toY=a.top,i.start=o;let s=i.lastTargetAt===0?0:o-i.lastTargetAt;i.duration=this.options.smooth&&s>=this.options.minSmoothGapMs?Math.min(s,this.options.maxSmoothMs):0,i.lastTargetAt=o,i.duration===0?this.place(i,i.toX,i.toY,!0):this.schedule()}rightEdge(){return this.options.rightEdge?this.options.rightEdge():this.root.clientWidth||this.root.ownerDocument.defaultView?.innerWidth||0}measureLabelWidth(e){return e.labelDirty&&(e.labelDirty=!1,e.labelWidth=e.label.offsetWidth),e.labelWidth||R}updateFlip(e,t,n,r){if(r<=0)return;let i=(this.measureLabelWidth(e)+I)*n,a=L*n;!e.flipped&&r-t<i?e.flipped=!0:e.flipped&&r-t>i+a&&(e.flipped=!1),V(e.el,`flip`,String(e.flipped))}place(e,t,n,r,i=this.options.scale?.()??1,a=this.rightEdge()){e.x=t,e.y=n,e.el.style.transform=`translate3d(${t}px, ${n}px, 0) scale(${i})`,this.updateFlip(e,t,i,a),r&&(e.arrived=!0,this.trace&&(e.el.dataset.x=e.target[0].toFixed(2),e.el.dataset.y=e.target[1].toFixed(2)))}relayout(){let e=this.options.scale?.()??1,t=this.rightEdge(),n=[];for(let e of this.nodes.values())e.labelDirty=!0,this.measureLabelWidth(e),n.push({node:e,px:this.options.map(e.target[0],e.target[1])});for(let{node:r,px:i}of n)r.el.dataset.focus===`true`&&this.setFocusScale(r.el),r.arrived=!1,r.lastTargetAt=0,r.el.dataset.hidden=String(!i),i&&(r.fromX=r.x,r.fromY=r.y,r.toX=i.left,r.toY=i.top,r.duration=0,this.place(r,i.left,i.top,!0,e,t))}create(e){let t=this.root.ownerDocument.createElement(`div`);t.className=`lr-user`,t.id=`user-${e.id}`,t.innerHTML=`<div class="lr-ripple"></div>${N.replace(`<svg`,`<svg class="lr-cursor"`)}<div class="lr-label"><span></span><video autoplay muted playsinline></video></div><div class="lr-halo"></div>`;let n=t.querySelector(`.lr-label`),r=t.querySelector(`.lr-ripple`);n.firstElementChild.textContent=e.name,this.root.appendChild(t);let i={el:t,label:n,ripple:r,video:t.querySelector(`video`),x:0,y:0,fromX:0,fromY:0,toX:0,toY:0,start:0,duration:0,lastTargetAt:0,target:[NaN,NaN],arrived:!1,flipped:!1,labelWidth:0,labelDirty:!0,mouseDown:!1,lastMouseDownAt:-1/0,lastPulseAt:-1/0};return this.nodes.set(e.id,i),i}schedule(){this.frame||=requestAnimationFrame(()=>this.render())}render(){this.frame=0;let e=performance.now(),t=this.options.scale?.()??1,n=this.rightEdge();for(let e of this.nodes.values())!e.arrived&&e.labelDirty&&this.measureLabelWidth(e);let r=!1;for(let i of this.nodes.values()){if(i.arrived)continue;let a=i.duration>0?Math.min(1,(e-i.start)/i.duration):1,o=i.fromX+(i.toX-i.fromX)*a,s=i.fromY+(i.toY-i.fromY)*a;this.place(i,o,s,a>=1,t,n),a<1&&(r=!0)}r&&this.schedule()}};function U(e,t){let n=e?.closest(`.lr-user`);n&&(n.dataset.live=String(t))}var W=(e,n)=>e.type===`admin`&&((e.id===n.you?n.ownFlags:e.flags)&t.focus)!==0,G=(e,t)=>e.camera||W(e,t),le=class{options;room=null;connecting=null;tracks=new Map;stopped=!1;requested=``;wasFocused=!1;focusExitTimer=null;failures=0;retryTimer=null;constructor(e){this.options=e;let{client:t}=e,n=()=>{if(this.stopped)return;let e=[...t.participants.values()],n=e.some(e=>W(e,t)),r=`${e.some(e=>G(e,t))}/${t.me?G(t.me,t):!1}/${n}/${this.warm()}`;r!==this.requested&&(this.requested=r,this.focusExitTimer&&clearTimeout(this.focusExitTimer),this.wasFocused&&!n?this.focusExitTimer=setTimeout(()=>{this.focusExitTimer=null,this.update()},300):this.update(),this.wasFocused=n)};t.on(`snapshot`,n),t.on(`presence`,n),t.on(`cursors`,n),t.on(`flags`,n)}reattach(){for(let[e,t]of this.tracks){let n=this.options.videoFor(e);n&&!t.attachedElements.includes(n)&&t.attach(n);let r=this.options.client.participants.get(e);U(n,!!r&&(G(r,this.options.client)||!!this.focusExitTimer))}}async stop(){this.stopped=!0,this.focusExitTimer&&clearTimeout(this.focusExitTimer),this.focusExitTimer=null,this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=null,await this.room?.disconnect(),this.room=null,this.clearTracks()}warm(){return!!this.options.preconnect&&[...this.options.client.participants.values()].some(e=>e.type===`admin`)}scheduleRetry(){if(this.stopped||this.retryTimer)return;let e=Math.min(1e3*2**this.failures,15e3);this.failures++,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.update()},e)}clearTracks(){for(let e of this.tracks.keys())U(this.options.videoFor(e),!1);this.tracks.clear()}async update(){if(this.stopped)return;let{client:e}=this.options;if((this.warm()||[...e.participants.values()].some(t=>G(t,e)))&&!this.room&&!this.connecting&&e.livekit&&(this.connecting=this.connect().finally(()=>this.connecting=null)),this.connecting&&await this.connecting,!this.stopped){if(!this.warm()&&![...e.participants.values()].some(t=>G(t,e))&&this.room){let e=this.room;this.room=null,this.clearTracks(),await e.disconnect()}else{if(this.room&&this.options.publish){let t=e.me?G(e.me,e):!1;this.room.localParticipant.isCameraEnabled!==t&&await this.room.localParticipant.setCameraEnabled(t).catch(e=>this.options.log?.(`camera`,e))}this.reattach()}}}async connect(){let{client:e}=this.options,{Room:t,RoomEvent:n,Track:r}=await Promise.resolve().then(()=>require("./livekit-client.esm-DiyxitqE.cjs")),i=new t({dynacast:!0,adaptiveStream:!0});i.on(n.TrackSubscribed,(e,t,n)=>{t.source===r.Source.Camera&&(this.tracks.set(n.identity,e),this.reattach())}),i.on(n.TrackUnsubscribed,(e,t,n)=>{this.tracks.delete(n.identity),U(this.options.videoFor(n.identity),!1)}),i.on(n.Disconnected,()=>{this.room===i&&(this.room=null,this.clearTracks(),this.scheduleRetry())});try{if(await i.connect(e.livekit.url,e.livekit.token,{autoSubscribe:!0}),this.stopped)return void i.disconnect();this.room=i,this.failures=0}catch(e){this.options.log?.(`livekit connect failed`,e),this.scheduleRetry()}}},ue=`16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function de(e){return`:host { all: initial !important; display: block !important; font: ${ue} !important; color: #0f172a !important; text-align: left !important; direction: ltr !important; ${e.split(`;`).map(e=>e.trim()).filter(Boolean).map(e=>`${e.replace(/\s*!important$/,``)} !important;`).join(` `)} }`}var fe=`#94A3B8`,pe=`#F59E0B`,me=`#EF4444`,he=3e3,ge=600,_e=1e3,ve=4,ye=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,K=e=>ye.test(e)?e:`#a3a3a3`;function be(e,t){let n=[];for(let r of e)r.type===`admin`&&r.id!==t&&n.push({id:r.id,name:r.name,color:K(r.color),clicks:(r.flags&ve)!==0,pointed:r.cursorAt>0,movedAt:r.cursorAt});return n}function q(e){let t=Se(e.people),n=t.filter(e=>e.pointed),r=n.some(e=>e.clicks),i=e.stopped&&t.length>0,a=n.length>0&&!e.stopped,o=e.quality!==`good`;if(!i&&!a&&!o)return{visible:!1,label:``,button:null,dots:[],dotKind:`host`,quality:null};let s=i&&e.sinceStopMs!==null&&e.sinceStopMs<he,c=i?Ee(t,e.sinceStopMs!==null&&e.sinceStopMs<ge):a?Te(n,r):null,l=o?e.quality===`offline`?`Reconnecting…`:`Unstable connection`:i?we(t,s):Ce(n,r),u=o||i;return{visible:!0,label:l,button:c,dots:o?[e.quality===`offline`?me:pe]:i?[fe]:xe(Y(n),e.dotIds).map(e=>K(e.color)),dotKind:u?`status`:`host`,quality:e.quality===`good`?null:e.quality}}function J(e,t,n){let r=Y(e.filter(e=>e.pointed));if(!n||t-n.at>=1e3)return{at:t,ids:r.slice(0,3).map(e=>e.id)};let i=new Set(r.map(e=>e.id)),a=n.ids.filter(e=>i.has(e));for(let e of r){if(a.length>=3)break;a.includes(e.id)||a.push(e.id)}return{at:n.at,ids:a}}function Y(e){return[...e].sort((e,t)=>t.movedAt-e.movedAt||e.name.localeCompare(t.name)||e.id.localeCompare(t.id))}function xe(e,t){if(!t)return e.slice(0,3);let n=new Map(e.map(e=>[e.id,e])),r=[];for(let e of t){let t=n.get(e);if(t&&(r.push(t),r.length===3))break}return r}function Se(e){return[...e].sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))}function Ce(e,t){if(e.length===1)return t?`${e[0].name} can point and click`:`${e[0].name} is pointing`;if(e.length===2){let n=`${e[0].name} and ${e[1].name}`;return t?`${n} can point and click`:`${n} are pointing`}return t?`${e.length} people can point and click`:`${e.length} people are pointing`}function we(e,t){return t?e.length===1?`You stopped ${e[0].name}'s cursor`:`You stopped ${e.length} cursors`:e.length===1?`${e[0].name}'s cursor is off`:`${e.length} cursors are off`}function Te(e,t){return{text:`Stop`,ariaLabel:e.length===1?t?`Stop ${e[0].name}'s cursor and clicks`:`Stop ${e[0].name}'s cursor`:e.length===2?`Stop ${e[0].name}'s and ${e[1].name}'s cursors`:`Stop all ${e.length} cursors`,disabled:!1,action:`stop`}}function Ee(e,t){if(e.length===1){let n=`Let ${e[0].name} point again`;return{text:n,ariaLabel:n,disabled:t,action:`resume`}}return{text:`Let them point again`,ariaLabel:e.length===2?`Let ${e[0].name} and ${e[1].name} point again`:`Let all ${e.length} point again`,disabled:t,action:`resume`}}var X=`
65
81
  .lr-pill { position: fixed; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 6px;
66
- padding: 4px 4px 4px 6px; border-radius: 9999px; background: rgb(15 23 42 / 85%);
67
- box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%), 0 1px 3px rgb(0 0 0 / 20%);
68
- color: #fff; font: 500 12px/1.5 system-ui, sans-serif; pointer-events: auto; user-select: none;
69
- cursor: grab; opacity: 0; transition: opacity 200ms ease-out, transform 200ms ease-out; z-index: 2; }
82
+ padding: 4px 4px 4px 6px; border-radius: 9999px; background: rgb(14 15 21 / 90%);
83
+ backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
84
+ box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%), 0 6px 18px -6px rgb(0 0 0 / 38%);
85
+ color: #F5F6FB; font: 500 12px/1.5 "Geist", system-ui, -apple-system, sans-serif; pointer-events: auto; user-select: none;
86
+ cursor: grab; opacity: 0; transition: opacity 200ms cubic-bezier(0.22, 1, 0.36, 1), transform 200ms cubic-bezier(0.22, 1, 0.36, 1); z-index: 2; }
70
87
  .lr-pill[data-shown="true"] { opacity: 1; }
71
88
  .lr-pill[hidden] { display: none !important; }
72
89
  .lr-pill[data-button="false"] { padding: 4px 10px 4px 6px; }
73
90
  .lr-grip { width: 6px; height: 10px; flex: none; background: radial-gradient(circle, rgb(255 255 255 / 55%) 1px, transparent 1.2px) 0 0 / 4px 4px; }
74
- .lr-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--dot, #94A3B8); box-shadow: 0 0 0 1px rgb(255 255 255 / 25%); }
91
+ .lr-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; position: relative; background: var(--lr-host-color, #94A3B8); box-shadow: 0 0 0 1.5px rgb(255 255 255 / 92%); }
92
+ .lr-dot[data-kind="status"] { box-shadow: 0 0 0 1px rgb(255 255 255 / 25%); }
75
93
  .lr-dots { display: flex; flex: none; }
76
- .lr-dots .lr-dot { box-shadow: 0 0 0 1.5px rgb(15 23 42); }
94
+ .lr-dots .lr-dot:nth-child(1) { z-index: 3; }
95
+ .lr-dots .lr-dot:nth-child(2) { z-index: 2; }
96
+ .lr-dots .lr-dot:nth-child(3) { z-index: 1; }
77
97
  .lr-dots .lr-dot + .lr-dot { margin-left: -3px; }
78
98
  .lr-label { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
79
99
  .lr-btn { height: 24px; min-width: 44px; max-width: 200px; padding: 0 10px; margin-left: 2px; border: 0; border-radius: 9999px;
@@ -90,16 +110,16 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
90
110
  @media (prefers-reduced-motion: reduce) {
91
111
  .lr-pill, .lr-pill.snapping { animation: none; transition: none; transform: none !important; }
92
112
  }
93
- `,he=class{root;label;dots;button;targets=[];style;shown=!1;hideTimer;qualityTimer;quality=`good`;model={stopped:!1,sinceStopMs:null,people:[]};view=Y({...this.model,quality:`good`});drag=null;handlers;constructor(e,t){this.handlers=t,this.style=document.createElement(`style`),this.style.textContent=me,this.root=document.createElement(`div`),this.root.className=`lr-pill`,this.root.role=`group`,this.root.setAttribute(`aria-label`,`Liveroom`),this.root.hidden=!0,this.root.dataset.shown=`false`;let n=document.createElement(`span`);n.className=`lr-grip`,n.ariaHidden=`true`,this.dots=document.createElement(`span`),this.dots.className=`lr-dots`,this.dots.ariaHidden=`true`,this.label=document.createElement(`span`),this.label.className=`lr-label`,this.label.role=`status`,this.label.ariaLive=`polite`,this.button=document.createElement(`button`),this.button.type=`button`,this.button.className=`lr-btn`,this.button.addEventListener(`click`,e=>{this.button.getAttribute(`aria-disabled`)===`true`?(e.preventDefault(),e.stopPropagation()):this.view.button?.action===`resume`?this.handlers.onResume():this.view.button?.action===`stop`&&this.handlers.onStop()}),this.root.append(n,this.dots,this.label,this.button),this.root.addEventListener(`pointerdown`,e=>this.onPointerDown(e)),e.append(this.style,this.root)}update(e){this.model=e,this.paint()}setQuality(e){window.clearTimeout(this.qualityTimer),e===`good`?(this.quality=`good`,this.paint()):this.qualityTimer=window.setTimeout(()=>{this.quality=e,this.paint()},500)}destroy(){window.clearTimeout(this.hideTimer),window.clearTimeout(this.qualityTimer),this.style.remove(),this.root.remove();for(let e of this.targets)e.remove()}paint(){let e=Y({...this.model,quality:this.quality});this.view=e,e.visible?(this.label.textContent!==e.label&&(this.label.textContent=e.label),this.dots.replaceChildren(...e.dots.map(e=>{let t=document.createElement(`span`);return t.className=`lr-dot`,t.style.setProperty(`--dot`,e),t})),e.quality?this.root.dataset.quality=e.quality:delete this.root.dataset.quality,e.button?(this.button.hidden=!1,this.button.textContent!==e.button.text&&(this.button.textContent=e.button.text),this.button.getAttribute(`aria-label`)!==e.button.ariaLabel&&this.button.setAttribute(`aria-label`,e.button.ariaLabel),e.button.disabled?this.button.setAttribute(`aria-disabled`,`true`):this.button.removeAttribute(`aria-disabled`),this.root.dataset.button=`true`):(this.button.hidden=!0,this.button.removeAttribute(`aria-disabled`),this.root.dataset.button=`false`),this.fadeIn()):this.fadeOut()}fadeIn(){window.clearTimeout(this.hideTimer),this.shown||(this.shown=!0,this.resetCorner(),this.root.hidden=!1,this.root.dataset.shown=`false`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.shown&&(this.root.dataset.shown=`true`)})}))}fadeOut(){this.shown&&(this.shown=!1,this.root.dataset.shown=`false`,window.clearTimeout(this.hideTimer),this.hideTimer=window.setTimeout(()=>{this.shown||(this.root.hidden=!0,this.resetCorner())},200))}resetCorner(){this.root.classList.remove(`dragging`,`snapping`),this.root.style.left=``,this.root.style.top=``,this.root.style.right=``,this.root.style.bottom=``}onPointerDown(e){if(e.button!==0||e.target?.closest?.(`.lr-btn`))return;let t=this.root.getBoundingClientRect();this.drag={pointer:e.pointerId,x:e.clientX,y:e.clientY,left:t.left,top:t.top,moved:!1},this.root.setPointerCapture(e.pointerId);let n=e=>{if(!this.drag||e.pointerId!==this.drag.pointer)return;let t=e.clientX-this.drag.x,n=e.clientY-this.drag.y;!this.drag.moved&&Math.hypot(t,n)<4||(this.drag.moved||(this.drag.moved=!0,this.root.classList.add(`dragging`),this.showTargets()),this.place(this.drag.left+t,this.drag.top+n),this.markNearest())},r=e=>{if(!this.drag||e.pointerId!==this.drag.pointer)return;this.root.removeEventListener(`pointermove`,n),this.root.removeEventListener(`pointerup`,r),this.root.removeEventListener(`pointercancel`,r);let t=this.drag.moved;this.drag=null,this.root.classList.remove(`dragging`),t?this.snap():this.clearTargets()};this.root.addEventListener(`pointermove`,n),this.root.addEventListener(`pointerup`,r),this.root.addEventListener(`pointercancel`,r)}place(e,t){this.root.style.left=`${e}px`,this.root.style.top=`${t}px`,this.root.style.right=`auto`,this.root.style.bottom=`auto`}corners(){let e=this.root.getBoundingClientRect();return[{left:12,top:12},{left:window.innerWidth-e.width-12,top:12},{left:12,top:window.innerHeight-e.height-12},{left:window.innerWidth-e.width-12,top:window.innerHeight-e.height-12}]}showTargets(){this.clearTargets();for(let e of this.corners()){let t=document.createElement(`div`);t.className=`lr-target`;let n=this.root.getBoundingClientRect();t.style.left=`${e.left}px`,t.style.top=`${e.top}px`,t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,this.root.parentElement?.append(t),this.targets.push(t)}this.markNearest()}markNearest(){let e=this.root.getBoundingClientRect(),t=e.left+e.width/2,n=e.top+e.height/2,r=0,i=1/0;this.corners().forEach((a,o)=>{let s=Math.hypot(a.left+e.width/2-t,a.top+e.height/2-n);s<i&&(i=s,r=o)}),this.targets.forEach((e,t)=>{e.dataset.near=String(t===r)})}clearTargets(){for(let e of this.targets)e.remove();this.targets.length=0}snap(){let e=this.root.getBoundingClientRect(),t=e.left+e.width/2,n=e.top+e.height/2,r=this.corners().reduce((r,i)=>{let a=Math.hypot(i.left+e.width/2-t,i.top+e.height/2-n);return a<r.dist?{corner:i,dist:a}:r},{corner:this.corners()[0],dist:1/0}).corner,i=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;this.clearTargets(),i?this.place(r.left,r.top):(this.root.classList.add(`snapping`),requestAnimationFrame(()=>this.place(r.left,r.top)),window.setTimeout(()=>this.root.classList.remove(`snapping`),180))}};function ge(){let e=document.createElement(`style`);return e.textContent=`
113
+ `,De=class{root;label;dots;button;targets=[];style;shown=!1;hideTimer;qualityTimer;quality=`good`;dotOrder=null;orderTimer;paintedDots=``;model={stopped:!1,sinceStopMs:null,people:[]};view=q({...this.model,quality:`good`});drag=null;handlers;constructor(e,t){this.handlers=t,this.style=document.createElement(`style`),this.style.textContent=X,this.root=document.createElement(`div`),this.root.className=`lr-pill`,this.root.role=`group`,this.root.setAttribute(`aria-label`,`Liveroom`),this.root.hidden=!0,this.root.dataset.shown=`false`;let n=document.createElement(`span`);n.className=`lr-grip`,n.ariaHidden=`true`,this.dots=document.createElement(`span`),this.dots.className=`lr-dots`,this.dots.ariaHidden=`true`,this.label=document.createElement(`span`),this.label.className=`lr-label`,this.label.role=`status`,this.label.ariaLive=`polite`,this.button=document.createElement(`button`),this.button.type=`button`,this.button.className=`lr-btn`,this.button.addEventListener(`click`,e=>{this.button.getAttribute(`aria-disabled`)===`true`?(e.preventDefault(),e.stopPropagation()):this.view.button?.action===`resume`?this.handlers.onResume():this.view.button?.action===`stop`&&this.handlers.onStop()}),this.root.append(n,this.dots,this.label,this.button),this.root.addEventListener(`pointerdown`,e=>this.onPointerDown(e)),e.append(this.style,this.root)}update(e){this.model=e,this.paint()}setQuality(e){window.clearTimeout(this.qualityTimer),e===`good`?(this.quality=`good`,this.paint()):this.qualityTimer=window.setTimeout(()=>{this.quality=e,this.paint()},500)}destroy(){window.clearTimeout(this.hideTimer),window.clearTimeout(this.qualityTimer),window.clearTimeout(this.orderTimer),this.style.remove(),this.root.remove();for(let e of this.targets)e.remove()}paint(){let e=performance.now(),t=J(this.model.people,e,this.dotOrder);this.dotOrder=t;let n=q({...this.model,quality:this.quality,dotIds:t.ids});if(this.view=n,this.armOrder(t,e,n),!n.visible){this.dotOrder=null,this.fadeOut();return}this.label.textContent!==n.label&&(this.label.textContent=n.label);let r=`${n.dotKind}:${n.dots.join(`|`)}`;r!==this.paintedDots&&(this.paintedDots=r,this.dots.replaceChildren(...n.dots.map(e=>{let t=document.createElement(`span`);return t.className=`lr-dot`,t.style.setProperty(`--lr-host-color`,e),n.dotKind===`status`&&(t.dataset.kind=`status`),t}))),n.quality?this.root.dataset.quality=n.quality:delete this.root.dataset.quality,n.button?(this.button.hidden=!1,this.button.textContent!==n.button.text&&(this.button.textContent=n.button.text),this.button.getAttribute(`aria-label`)!==n.button.ariaLabel&&this.button.setAttribute(`aria-label`,n.button.ariaLabel),n.button.disabled?this.button.setAttribute(`aria-disabled`,`true`):this.button.removeAttribute(`aria-disabled`),this.root.dataset.button=`true`):(this.button.hidden=!0,this.button.removeAttribute(`aria-disabled`),this.root.dataset.button=`false`),this.fadeIn()}armOrder(e,t,n){if(window.clearTimeout(this.orderTimer),!n.visible||n.dotKind!==`host`)return;let r=J(this.model.people,t,null).ids,i=e.ids;if(r.length===i.length&&r.every((e,t)=>e===i[t]))return;let a=Math.max(0,e.at+_e-t);this.orderTimer=window.setTimeout(()=>this.paint(),a)}fadeIn(){window.clearTimeout(this.hideTimer),this.shown||(this.shown=!0,this.resetCorner(),this.root.hidden=!1,this.root.dataset.shown=`false`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.shown&&(this.root.dataset.shown=`true`)})}))}fadeOut(){this.shown&&(this.shown=!1,this.root.dataset.shown=`false`,window.clearTimeout(this.hideTimer),this.hideTimer=window.setTimeout(()=>{this.shown||(this.root.hidden=!0,this.resetCorner())},200))}resetCorner(){this.root.classList.remove(`dragging`,`snapping`),this.root.style.left=``,this.root.style.top=``,this.root.style.right=``,this.root.style.bottom=``}onPointerDown(e){if(e.button!==0||e.target?.closest?.(`.lr-btn`))return;let t=this.root.getBoundingClientRect();this.drag={pointer:e.pointerId,x:e.clientX,y:e.clientY,left:t.left,top:t.top,moved:!1},this.root.setPointerCapture(e.pointerId);let n=e=>{if(!this.drag||e.pointerId!==this.drag.pointer)return;let t=e.clientX-this.drag.x,n=e.clientY-this.drag.y;!this.drag.moved&&Math.hypot(t,n)<4||(this.drag.moved||(this.drag.moved=!0,this.root.classList.add(`dragging`),this.showTargets()),this.place(this.drag.left+t,this.drag.top+n),this.markNearest())},r=e=>{if(!this.drag||e.pointerId!==this.drag.pointer)return;this.root.removeEventListener(`pointermove`,n),this.root.removeEventListener(`pointerup`,r),this.root.removeEventListener(`pointercancel`,r);let t=this.drag.moved;this.drag=null,this.root.classList.remove(`dragging`),t?this.snap():this.clearTargets()};this.root.addEventListener(`pointermove`,n),this.root.addEventListener(`pointerup`,r),this.root.addEventListener(`pointercancel`,r)}place(e,t){this.root.style.left=`${e}px`,this.root.style.top=`${t}px`,this.root.style.right=`auto`,this.root.style.bottom=`auto`}corners(){let e=this.root.getBoundingClientRect();return[{left:12,top:12},{left:window.innerWidth-e.width-12,top:12},{left:12,top:window.innerHeight-e.height-12},{left:window.innerWidth-e.width-12,top:window.innerHeight-e.height-12}]}showTargets(){this.clearTargets();for(let e of this.corners()){let t=document.createElement(`div`);t.className=`lr-target`;let n=this.root.getBoundingClientRect();t.style.left=`${e.left}px`,t.style.top=`${e.top}px`,t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,this.root.parentElement?.append(t),this.targets.push(t)}this.markNearest()}markNearest(){let e=this.root.getBoundingClientRect(),t=e.left+e.width/2,n=e.top+e.height/2,r=0,i=1/0;this.corners().forEach((a,o)=>{let s=Math.hypot(a.left+e.width/2-t,a.top+e.height/2-n);s<i&&(i=s,r=o)}),this.targets.forEach((e,t)=>{e.dataset.near=String(t===r)})}clearTargets(){for(let e of this.targets)e.remove();this.targets.length=0}snap(){let e=this.root.getBoundingClientRect(),t=e.left+e.width/2,n=e.top+e.height/2,r=this.corners().reduce((r,i)=>{let a=Math.hypot(i.left+e.width/2-t,i.top+e.height/2-n);return a<r.dist?{corner:i,dist:a}:r},{corner:this.corners()[0],dist:1/0}).corner,i=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;this.clearTargets(),i?this.place(r.left,r.top):(this.root.classList.add(`snapping`),requestAnimationFrame(()=>this.place(r.left,r.top)),window.setTimeout(()=>this.root.classList.remove(`snapping`),180))}};function Oe(){let e=document.createElement(`style`);return e.textContent=`
94
114
  * {
95
115
  cursor: crosshair !important;
96
116
  }
97
- `,e}function X(){let e=document.createElement(`style`);return e.textContent=`
117
+ `,e}function ke(){let e=document.createElement(`style`);return e.textContent=`
98
118
  * {
99
119
  pointer-events: none !important;
100
120
  user-select: none !important;
101
121
  }
102
- `,e}function _e(){let e=document.createElement(`style`);return e.textContent=`
122
+ `,e}function Ae(){let e=document.createElement(`style`);return e.textContent=`
103
123
  html { overflow: hidden !important; scrollbar-gutter: stable !important; }
104
124
  * { touch-action: none !important; overscroll-behavior: none !important; }
105
- `,e}var ve=K(`position: fixed; inset: 0; pointer-events: none; z-index: 2147483646; width: auto; height: auto`),Z=class extends HTMLElement{client;layer;cameras;cleanup=[];blockMouseStyle=ge();blockPointerStyle=X();blocked=!1;blockScrollStyle=_e();pointer=[50,50];shift=!1;pill;wantStop=!1;holdUntilCursor=!1;stopClickedAt=null;stopAcked=!1;pillTimers=[];connectedCallback(){if(this.parentElement!==document.body||this.nextSibling!==null){document.body.appendChild(this);return}let t=this.getAttribute(`room_id`),n=this.getAttribute(`room_token`),r=this.getAttribute(`url`)||`wss://liveroom.app/room`;if(!t||!n||this.client)return;console.log(`[Liveroom] Starting in room '${t}'... (v${e.u})`);let i=this.shadowRoot??this.attachShadow({mode:`open`});i.replaceChildren();let a=document.createElement(`style`);a.textContent=ve,i.appendChild(a);let o=document.createElement(`div`);o.id=`liveroom-client-element`,o.style.cssText=`position: fixed; inset: 0; pointer-events: none;`,i.appendChild(o);let s=this.client=new M({url:r,roomId:t,roomToken:n,type:`client`,name:this.getAttribute(`user_name`),color:this.getAttribute(`user_color`),viewport:Q,analytics:{url:location.href,referrer:document.referrer,language:navigator.language,user_agent:navigator.userAgent}});this.layer=new V({container:o,styleRoot:i,map:(e,t)=>({left:e/100*innerWidth,top:t/100*innerHeight})}),this.cameras=new G({preconnect:!0,client:s,publish:!1,videoFor:e=>this.layer?.videoFor(e)});let c=()=>this.render(),l=()=>{let t=s.me;t?.name&&sessionStorage?.setItem(e.l,t.name),t?.color&&sessionStorage?.setItem(e.c,t.color),this.noteServerStop(!!t?.stopped),c(),this.syncPill()};s.on(`snapshot`,l),s.on(`presence`,()=>{l(),this.cameras?.reattach()}),s.on(`cursors`,({ids:e})=>{let t=e.some(e=>s.participants.get(e)?.type===`admin`);t&&this.holdUntilCursor&&!s.me?.stopped&&!this.wantStop&&(this.holdUntilCursor=!1);let n=!1;for(let t of e){let e=s.participants.get(t);e&&!this.hostHidden(e)&&(this.layer.update(e),e.type===`admin`&&(n=!0))}t&&this.syncPill(),n&&this.updateBlocked()}),s.on(`click`,({x:e,y:t})=>{this.stopped()||this.replayClick(e/100,t/100)}),s.on(`wheel`,({x:e,y:t,dx:n,dy:r})=>{this.stopped()||this.replayWheel(e/100,t/100,n,r)}),s.on(`refused`,e=>console.error(`[Liveroom] Refused: ${e}`)),this.pill=new he(i,{onStop:()=>this.stopHosts(),onResume:()=>this.resumeHosts()}),this.cleanup.push(s.on(`quality`,e=>this.pill?.setQuality(e)),()=>this.pill?.destroy()),s.connect();let u=e=>{this.blocked&&(e.preventDefault(),e.stopImmediatePropagation())};this.listen(window,`wheel`,u,{capture:!0,passive:!1}),this.listen(window,`touchmove`,u,{capture:!0,passive:!1}),this.listen(window,`keydown`,e=>{this.pill&&e.composedPath().includes(this.pill.root)||[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(e.key)&&u(e)},{capture:!0}),this.listen(window,`mousemove`,e=>{this.pointer=[e.clientX/innerWidth*100,e.clientY/innerHeight*100],s.move(this.pointer[0],this.pointer[1]),this.shift&&this.renderSelf()}),this.listen(window,`mousedown`,()=>s.setFlag(`mouseDown`,!0)),this.listen(window,`mouseup`,()=>s.setFlag(`mouseDown`,!1)),this.listen(window,`keydown`,e=>{e.key===`Shift`&&!e.repeat&&(this.shift=!0,s.setFlag(`shift`,!0),c())}),this.listen(window,`keyup`,e=>{e.key===`Shift`&&(this.shift=!1,s.setFlag(`shift`,!1),c())});let d;this.listen(window,`resize`,()=>{clearTimeout(d),d=window.setTimeout(()=>{s.setState({viewport:Q()}),this.layer?.relayout()},100)});let f=location.href,p=window.setInterval(()=>{location.href!==f&&s.setState({url:f=location.href})},500);this.cleanup.push(()=>clearInterval(p))}disconnectedCallback(){for(let e of this.cleanup.splice(0))e();this.cameras?.stop(),this.client?.disconnect(),this.layer?.destroy(),this.setBlocked(!1),this.clearPillTimers(),this.client=this.layer=this.cameras=this.pill=void 0}stopped(){return this.wantStop||this.holdUntilCursor||!!this.client?.me?.stopped}hostHidden(e){return e.type===`admin`&&this.stopped()}noteServerStop(e){this.holdUntilCursor?e||(this.wantStop=!1):e?(this.wantStop=!0,this.stopAcked=!0):(this.stopAcked||this.stopClickedAt===null)&&(this.wantStop=!1,this.stopAcked=!1,this.stopClickedAt=null)}people(){let e=[];for(let n of this.client?.participants.values()??[])n.type===`admin`&&n.id!==this.client?.you&&e.push({id:n.id,name:n.name,color:n.color,clicks:(n.flags&t.alt)!==0,pointed:n.cursorAt>0});return e}syncPill(){let e=this.stopClickedAt===null?null:performance.now()-this.stopClickedAt;this.pill?.update({stopped:this.stopped(),sinceStopMs:this.wantStop?e:null,people:this.people()})}stopHosts(){this.wantStop=!0,this.holdUntilCursor=!1,this.stopClickedAt=performance.now(),this.clearPillTimers(),this.pillTimers.push(window.setTimeout(()=>this.syncPill(),620),window.setTimeout(()=>this.syncPill(),3020)),this.setBlocked(!1),this.render(),this.syncPill(),this.client?.stop()}clearPillTimers(){for(let e of this.pillTimers)window.clearTimeout(e);this.pillTimers=[]}resumeHosts(){this.stopClickedAt!==null&&performance.now()-this.stopClickedAt<600||(this.wantStop=!1,this.holdUntilCursor=!0,this.syncPill(),this.client?.resume())}listen(e,t,n,r){e.addEventListener(t,n,r),this.cleanup.push(()=>e.removeEventListener(t,n,r))}updateBlocked(){if(this.stopped()){this.setBlocked(!1);return}let e=[...this.client.participants.values()].filter(e=>e.type===`admin`);this.setBlocked(e.some(e=>(e.flags&(t.block|t.focus))!==0))}render(){let e=this.client;this.updateBlocked();let n=[];for(let r of e.participants.values())r.id===e.you?n.push({...r,self:!0,x:this.pointer[0],y:this.pointer[1],flags:this.shift?t.shift:0}):this.hostHidden(r)||n.push(r);this.layer.sync(n)}renderSelf(){let e=this.client?.me;e&&this.layer?.update({...e,self:!0,x:this.pointer[0],y:this.pointer[1],flags:this.shift?t.shift:0})}setBlocked(e){if(e!==this.blocked){this.blocked=e;for(let t of[this.blockMouseStyle,this.blockPointerStyle,this.blockScrollStyle])e?document.head.appendChild(t):t.remove()}}elementAt(e,t){let n=this.blocked&&this.blockPointerStyle.isConnected;n&&this.blockPointerStyle.remove();let r=document.elementFromPoint(e,t);return n&&document.head.appendChild(this.blockPointerStyle),r}replayClick(e,t){let n=innerWidth*e/100,r=innerHeight*t/100;this.elementAt(n,r)?.dispatchEvent(new MouseEvent(`click`,{view:window,bubbles:!0,cancelable:!0,clientX:n,clientY:r}))}replayWheel(e,t,n,r){let i=this.elementAt(innerWidth*e/100,innerHeight*t/100);if(!(i instanceof HTMLElement||i instanceof SVGElement))return;let a=Math.abs(r)>=Math.abs(n),o=ye(i,a?`vertical`:`horizontal`);$(o)?o.scrollByPoint(a?0:n,a?r:0,0):o.scrollBy({top:a?r:0,left:a?0:n,behavior:`instant`})}};function Q(){return[innerWidth,innerHeight,outerWidth,outerHeight]}function $(e){return e instanceof HTMLElement&&e.tagName===`ION-CONTENT`&&`scrollByPoint`in e}function ye(e,t){for(let n=e;n&&n!==document.body;n=n.parentElement){if($(n))return n;let{overflowY:e,overflowX:r}=getComputedStyle(n);if((t===`vertical`?[`auto`,`scroll`].includes(e)&&n.scrollHeight>n.clientHeight:[`auto`,`scroll`].includes(r)&&n.scrollWidth>n.clientWidth)&&(n instanceof HTMLElement||n instanceof SVGElement))return n}return window}customElements.get(`liveroom-client-element`)||customElements.define(`liveroom-client-element`,Z),exports.LiveroomClientElement=Z;
125
+ `,e}var je=de(`position: fixed; inset: 0; pointer-events: none; z-index: 2147483646; width: auto; height: auto`),Z=class extends HTMLElement{client;layer;cameras;cleanup=[];blockMouseStyle=Oe();blockPointerStyle=ke();blocked=!1;blockScrollStyle=Ae();pointer=[50,50];shift=!1;pill;wantStop=!1;holdUntilCursor=!1;stopClickedAt=null;stopAcked=!1;pillTimers=[];connectedCallback(){if(this.parentElement!==document.body||this.nextSibling!==null){document.body.appendChild(this);return}let t=this.getAttribute(`room_id`),n=this.getAttribute(`room_token`),r=this.getAttribute(`url`)||`wss://liveroom.app/room`;if(!t||!n||this.client)return;console.log(`[Liveroom] Starting in room '${t}'... (v${e.u})`);let i=this.shadowRoot??this.attachShadow({mode:`open`});i.replaceChildren();let a=document.createElement(`style`);a.textContent=je,i.appendChild(a);let o=document.createElement(`div`);o.id=`liveroom-client-element`,o.style.cssText=`position: fixed; inset: 0; pointer-events: none;`,i.appendChild(o);let s=this.client=new se({url:r,roomId:t,roomToken:n,type:`client`,name:this.getAttribute(`user_name`),color:this.getAttribute(`user_color`),viewport:Q,analytics:{url:location.href,referrer:document.referrer,language:navigator.language,user_agent:navigator.userAgent}});this.layer=new H({container:o,styleRoot:i,map:(e,t)=>({left:e/100*innerWidth,top:t/100*innerHeight}),rightEdge:()=>innerWidth}),this.cameras=new le({preconnect:!0,client:s,publish:!1,videoFor:e=>this.layer?.videoFor(e)});let c=()=>this.render(),l=()=>{let t=s.me;t?.name&&sessionStorage?.setItem(e.l,t.name),t?.color&&sessionStorage?.setItem(e.c,t.color),this.noteServerStop(!!t?.stopped),c(),this.syncPill()};s.on(`snapshot`,l),s.on(`presence`,()=>{l(),this.cameras?.reattach()}),s.on(`cursors`,({ids:e})=>{let t=e.some(e=>s.participants.get(e)?.type===`admin`);t&&this.holdUntilCursor&&!s.me?.stopped&&!this.wantStop&&(this.holdUntilCursor=!1);let n=!1;for(let t of e){let e=s.participants.get(t);e&&!this.hostHidden(e)&&(this.layer.update(e),e.type===`admin`&&(n=!0))}t&&this.syncPill(),n&&this.updateBlocked()}),s.on(`click`,({from:e,x:t,y:n})=>{this.stopped()||(this.layer?.pulse(e,{fromClick:!0}),this.replayClick(t/100,n/100))}),s.on(`wheel`,({x:e,y:t,dx:n,dy:r})=>{this.stopped()||this.replayWheel(e/100,t/100,n,r)}),s.on(`refused`,e=>console.error(`[Liveroom] Refused: ${e}`)),this.pill=new De(i,{onStop:()=>this.stopHosts(),onResume:()=>this.resumeHosts()}),this.cleanup.push(s.on(`quality`,e=>this.pill?.setQuality(e)),()=>this.pill?.destroy()),s.connect();let u=e=>{this.blocked&&(e.preventDefault(),e.stopImmediatePropagation())};this.listen(window,`wheel`,u,{capture:!0,passive:!1}),this.listen(window,`touchmove`,u,{capture:!0,passive:!1}),this.listen(window,`keydown`,e=>{this.pill&&e.composedPath().includes(this.pill.root)||[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(e.key)&&u(e)},{capture:!0}),this.listen(window,`mousemove`,e=>{this.pointer=[e.clientX/innerWidth*100,e.clientY/innerHeight*100],s.move(this.pointer[0],this.pointer[1]),this.shift&&this.renderSelf()}),this.listen(window,`mousedown`,()=>s.setFlag(`mouseDown`,!0)),this.listen(window,`mouseup`,()=>s.setFlag(`mouseDown`,!1)),this.listen(window,`keydown`,e=>{e.key===`Shift`&&!e.repeat&&(this.shift=!0,s.setFlag(`shift`,!0),c())}),this.listen(window,`keyup`,e=>{e.key===`Shift`&&(this.shift=!1,s.setFlag(`shift`,!1),c())});let d;this.listen(window,`resize`,()=>{clearTimeout(d),d=window.setTimeout(()=>{s.setState({viewport:Q()}),this.layer?.relayout()},100)});let f=location.href,p=window.setInterval(()=>{location.href!==f&&s.setState({url:f=location.href})},500);this.cleanup.push(()=>clearInterval(p))}disconnectedCallback(){for(let e of this.cleanup.splice(0))e();this.cameras?.stop(),this.client?.disconnect(),this.layer?.destroy(),this.setBlocked(!1),this.clearPillTimers(),this.client=this.layer=this.cameras=this.pill=void 0}stopped(){return this.wantStop||this.holdUntilCursor||!!this.client?.me?.stopped}hostHidden(e){return e.type===`admin`&&this.stopped()}noteServerStop(e){this.holdUntilCursor?e||(this.wantStop=!1):e?(this.wantStop=!0,this.stopAcked=!0):(this.stopAcked||this.stopClickedAt===null)&&(this.wantStop=!1,this.stopAcked=!1,this.stopClickedAt=null)}people(){return be(this.client?.participants.values()??[],this.client?.you??null)}syncPill(){let e=this.stopClickedAt===null?null:performance.now()-this.stopClickedAt;this.pill?.update({stopped:this.stopped(),sinceStopMs:this.wantStop?e:null,people:this.people()})}stopHosts(){this.wantStop=!0,this.holdUntilCursor=!1,this.stopClickedAt=performance.now(),this.clearPillTimers(),this.pillTimers.push(window.setTimeout(()=>this.syncPill(),620),window.setTimeout(()=>this.syncPill(),3020)),this.setBlocked(!1),this.render(),this.syncPill(),this.client?.stop()}clearPillTimers(){for(let e of this.pillTimers)window.clearTimeout(e);this.pillTimers=[]}resumeHosts(){this.stopClickedAt!==null&&performance.now()-this.stopClickedAt<600||(this.wantStop=!1,this.holdUntilCursor=!0,this.syncPill(),this.client?.resume())}listen(e,t,n,r){e.addEventListener(t,n,r),this.cleanup.push(()=>e.removeEventListener(t,n,r))}updateBlocked(){if(this.stopped()){this.setBlocked(!1);return}let e=[...this.client.participants.values()].filter(e=>e.type===`admin`);this.setBlocked(e.some(e=>(e.flags&(t.block|t.focus))!==0))}render(){let e=this.client;this.updateBlocked();let n=[];for(let r of e.participants.values())r.id===e.you?n.push({...r,self:!0,x:this.pointer[0],y:this.pointer[1],flags:this.shift?t.shift:0}):this.hostHidden(r)||n.push(r);this.layer.sync(n)}renderSelf(){let e=this.client?.me;e&&this.layer?.update({...e,self:!0,x:this.pointer[0],y:this.pointer[1],flags:this.shift?t.shift:0})}setBlocked(e){if(e!==this.blocked){this.blocked=e;for(let t of[this.blockMouseStyle,this.blockPointerStyle,this.blockScrollStyle])e?document.head.appendChild(t):t.remove()}}elementAt(e,t){let n=this.blocked&&this.blockPointerStyle.isConnected;n&&this.blockPointerStyle.remove();let r=document.elementFromPoint(e,t);return n&&document.head.appendChild(this.blockPointerStyle),r}replayClick(e,t){let n=innerWidth*e/100,r=innerHeight*t/100;this.elementAt(n,r)?.dispatchEvent(new MouseEvent(`click`,{view:window,bubbles:!0,cancelable:!0,clientX:n,clientY:r}))}replayWheel(e,t,n,r){let i=this.elementAt(innerWidth*e/100,innerHeight*t/100);if(!(i instanceof HTMLElement||i instanceof SVGElement))return;let a=Math.abs(r)>=Math.abs(n),o=Me(i,a?`vertical`:`horizontal`);$(o)?o.scrollByPoint(a?0:n,a?r:0,0):o.scrollBy({top:a?r:0,left:a?0:n,behavior:`instant`})}};function Q(){return[innerWidth,innerHeight,outerWidth,outerHeight]}function $(e){return e instanceof HTMLElement&&e.tagName===`ION-CONTENT`&&`scrollByPoint`in e}function Me(e,t){for(let n=e;n&&n!==document.body;n=n.parentElement){if($(n))return n;let{overflowY:e,overflowX:r}=getComputedStyle(n);if((t===`vertical`?[`auto`,`scroll`].includes(e)&&n.scrollHeight>n.clientHeight:[`auto`,`scroll`].includes(r)&&n.scrollWidth>n.clientWidth)&&(n instanceof HTMLElement||n instanceof SVGElement))return n}return window}customElements.get(`liveroom-client-element`)||customElements.define(`liveroom-client-element`,Z),exports.LiveroomClientElement=Z;
@@ -1,4 +1,4 @@
1
- import { c as e, l as t, u as n } from "./constants-DF3rCCdk.js";
1
+ import { c as e, l as t, u as n } from "./constants-BTUkeFrO.js";
2
2
  // ../packages/core/src/protocol.ts
3
3
  var r = {
4
4
  mouseDown: 1,
@@ -92,7 +92,7 @@ var r = {
92
92
  this.tries += 1, this.callback();
93
93
  }, this.timerCalc(this.tries + 1));
94
94
  }
95
- }, S = class {
95
+ }, ee = class {
96
96
  constructor(e, t, n) {
97
97
  this.state = h.closed, this.topic = e, this.params = o(t || {}), this.socket = n, this.bindings = [], this.bindingRef = 0, this.timeout = this.socket.timeout, this.joinedOnce = !1, this.joinPush = new b(this, g.join, this.params, this.timeout), this.pushBuffer = [], this.stateChangeRefs = [], this.rejoinTimer = new x(() => {
98
98
  this.socket.isConnected() && this.rejoin();
@@ -191,7 +191,7 @@ var r = {
191
191
  isLeaving() {
192
192
  return this.state === h.leaving;
193
193
  }
194
- }, C = class {
194
+ }, S = class {
195
195
  static request(e, t, n, r, i, a, o) {
196
196
  if (l.XDomainRequest) {
197
197
  let n = new l.XDomainRequest();
@@ -249,11 +249,11 @@ var r = {
249
249
  static appendParams(e, t) {
250
250
  return Object.keys(t).length === 0 ? e : `${e}${e.match(/\?/) ? "&" : "?"}${this.serialize(t)}`;
251
251
  }
252
- }, ee = (e) => {
252
+ }, te = (e) => {
253
253
  let t = "", n = new Uint8Array(e), r = n.byteLength;
254
254
  for (let e = 0; e < r; e++) t += String.fromCharCode(n[e]);
255
255
  return btoa(t);
256
- }, w = class {
256
+ }, C = class {
257
257
  constructor(e, t) {
258
258
  t && t.length === 2 && t[1].startsWith(y) && (this.authToken = atob(t[1].slice(y.length))), this.endPoint = null, this.token = null, this.skipHeartbeat = !0, this.reqs = /* @__PURE__ */ new Set(), this.messageTimers = /* @__PURE__ */ new Set(), this.awaitingBatchAck = !1, this.currentBatch = null, this.currentBatchTimer = null, this.batchBuffer = [], this.onopen = function() {}, this.onerror = function() {}, this.onmessage = function() {}, this.onclose = function() {}, this.pollEndpoint = this.normalizeEndpoint(e), this.readyState = d.connecting, setTimeout(() => this.poll(), 0);
259
259
  }
@@ -261,7 +261,7 @@ var r = {
261
261
  return e.replace("ws://", "http://").replace("wss://", "https://").replace(RegExp("(.*)/" + _.websocket), "$1/" + _.longpoll);
262
262
  }
263
263
  endpointURL() {
264
- return C.appendParams(this.pollEndpoint, { token: this.token });
264
+ return S.appendParams(this.pollEndpoint, { token: this.token });
265
265
  }
266
266
  closeAndRetry(e, t, n, r) {
267
267
  this.isActive() && (this.stop(d.connecting), this.onerror(e), this.isActive() && this.emitClose(t, n, r));
@@ -311,7 +311,7 @@ var r = {
311
311
  });
312
312
  }
313
313
  send(e) {
314
- typeof e != "string" && (e = ee(e)), this.currentBatch ? this.currentBatch.push(e) : this.awaitingBatchAck ? this.batchBuffer.push(e) : (this.currentBatch = [e], this.currentBatchTimer = setTimeout(() => {
314
+ typeof e != "string" && (e = te(e)), this.currentBatch ? this.currentBatch.push(e) : this.awaitingBatchAck ? this.batchBuffer.push(e) : (this.currentBatch = [e], this.currentBatchTimer = setTimeout(() => {
315
315
  this.batchSend(this.currentBatch), this.currentBatch = null;
316
316
  }, 0));
317
317
  }
@@ -343,13 +343,13 @@ var r = {
343
343
  }
344
344
  ajax(e, t, n, r, i) {
345
345
  let a = { req: null };
346
- this.reqs.add(a), a.req = C.request(e, this.endpointURL(), t, n, this.timeout, () => {
346
+ this.reqs.add(a), a.req = S.request(e, this.endpointURL(), t, n, this.timeout, () => {
347
347
  this.reqs.delete(a) && r();
348
348
  }, (e) => {
349
349
  this.reqs.delete(a) && i(e);
350
350
  });
351
351
  }
352
- }, T = {
352
+ }, w = {
353
353
  HEADER_LENGTH: 1,
354
354
  META_LENGTH: 4,
355
355
  KINDS: {
@@ -449,7 +449,7 @@ var r = {
449
449
  payload: e.slice(a, e.byteLength)
450
450
  };
451
451
  }
452
- }, E = class {
452
+ }, T = class {
453
453
  constructor(e, t) {
454
454
  this.socket = e, this.transport = t, this.joins = /* @__PURE__ */ new WeakMap(), this.pings = /* @__PURE__ */ new Map(), this.closing = !1, this.ended = !1, this.channelsErrored = !1, this.closeHandled = !1, t.onopen = () => {
455
455
  this.isCurrent() && e.onConnOpen();
@@ -476,14 +476,14 @@ var r = {
476
476
  close(e, t) {
477
477
  this.closing = !0, this.transport.onerror = function() {}, e ? this.transport.close(e, t || "") : this.transport.close();
478
478
  }
479
- }, D = class {
479
+ }, E = class {
480
480
  constructor(e, t = {}) {
481
481
  this.stateChangeCallbacks = {
482
482
  open: [],
483
483
  close: [],
484
484
  error: [],
485
485
  message: []
486
- }, this.channels = [], this.sendBuffer = [], this.ref = 0, this.fallbackRef = null, this.fallbackErrorRef = null, this.timeout = t.timeout || p, this.transport = t.transport || l.WebSocket || w, this.primaryPassedHealthCheck = !1, this.longPollFallbackMs = t.longPollFallbackMs, this.fallbackTimer = null, this.sessionStore = t.sessionStorage || l && l.sessionStorage, this.establishedConnections = 0, this.defaultEncoder = T.encode.bind(T), this.defaultDecoder = T.decode.bind(T), this.closeWasClean = !0, this.binaryType = t.binaryType || "arraybuffer", this.connection = null, this.connectClock = 1, this.visibilityConnection = null, this.transport === w ? (this.encode = this.defaultEncoder, this.decode = this.defaultDecoder) : (this.encode = t.encode || this.defaultEncoder, this.decode = t.decode || this.defaultDecoder);
486
+ }, this.channels = [], this.sendBuffer = [], this.ref = 0, this.fallbackRef = null, this.fallbackErrorRef = null, this.timeout = t.timeout || p, this.transport = t.transport || l.WebSocket || C, this.primaryPassedHealthCheck = !1, this.longPollFallbackMs = t.longPollFallbackMs, this.fallbackTimer = null, this.sessionStore = t.sessionStorage || l && l.sessionStorage, this.establishedConnections = 0, this.defaultEncoder = w.encode.bind(w), this.defaultDecoder = w.decode.bind(w), this.closeWasClean = !0, this.binaryType = t.binaryType || "arraybuffer", this.connection = null, this.connectClock = 1, this.visibilityConnection = null, this.transport === C ? (this.encode = this.defaultEncoder, this.decode = this.defaultDecoder) : (this.encode = t.encode || this.defaultEncoder, this.decode = t.decode || this.defaultDecoder);
487
487
  let n = null;
488
488
  c && c.addEventListener && (c.addEventListener("pagehide", (e) => {
489
489
  this.connection && !this.connection.ended && (this.disconnect(), n = this.connectClock);
@@ -530,7 +530,7 @@ var r = {
530
530
  }));
531
531
  }
532
532
  getLongPollTransport() {
533
- return w;
533
+ return C;
534
534
  }
535
535
  replaceTransport(e) {
536
536
  let t = ++this.connectClock;
@@ -546,14 +546,14 @@ var r = {
546
546
  return location.protocol.match(/^https/) ? "wss" : "ws";
547
547
  }
548
548
  endPointURL() {
549
- let e = C.appendParams(C.appendParams(this.endPoint, this.params()), { vsn: this.vsn });
549
+ let e = S.appendParams(S.appendParams(this.endPoint, this.params()), { vsn: this.vsn });
550
550
  return e.charAt(0) === "/" ? e.charAt(1) === "/" ? `${this.protocol()}:${e}` : `${this.protocol()}://${location.host}${e}` : e;
551
551
  }
552
552
  disconnect(e, t, n) {
553
553
  this.connectClock++, this.closeWasClean = !0, clearTimeout(this.fallbackTimer), this.reconnectTimer.reset(), this.connection && (this.connection.ended = !0), this.teardown(e, t, n);
554
554
  }
555
555
  connect(e) {
556
- e && (console && console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"), this.params = o(e)), (!this.connection || this.connection.ended) && (this.longPollFallbackMs && this.transport !== w ? this.connectWithFallback(w, this.longPollFallbackMs) : this.transportConnect());
556
+ e && (console && console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"), this.params = o(e)), (!this.connection || this.connection.ended) && (this.longPollFallbackMs && this.transport !== C ? this.connectWithFallback(C, this.longPollFallbackMs) : this.transportConnect());
557
557
  }
558
558
  log(e, t, n) {
559
559
  this.logger && this.logger(e, t, n);
@@ -589,7 +589,7 @@ var r = {
589
589
  }
590
590
  transportName(e) {
591
591
  switch (e) {
592
- case w: return "LongPoll";
592
+ case C: return "LongPoll";
593
593
  default: return e.name;
594
594
  }
595
595
  }
@@ -599,7 +599,7 @@ var r = {
599
599
  let t;
600
600
  this.authToken && (t = ["phoenix", `${y}${btoa(this.authToken()).replace(/=/g, "")}`]);
601
601
  let n = new this.transport(this.endPointURL(), t);
602
- n.binaryType = this.binaryType, n.timeout = this.longpollerTimeout, this.connection = new E(this, n), e && e.isOpen() && this.triggerChanError("connection_closed", e);
602
+ n.binaryType = this.binaryType, n.timeout = this.longpollerTimeout, this.connection = new T(this, n), e && e.isOpen() && this.triggerChanError("connection_closed", e);
603
603
  }
604
604
  getSession(e) {
605
605
  return this.sessionStore && this.sessionStore.getItem(e);
@@ -718,7 +718,7 @@ var r = {
718
718
  for (let t in this.stateChangeCallbacks) this.stateChangeCallbacks[t] = this.stateChangeCallbacks[t].filter(([t]) => e.indexOf(t) === -1);
719
719
  }
720
720
  channel(e, t = {}) {
721
- let n = new S(e, t, this);
721
+ let n = new ee(e, t, this);
722
722
  return this.channels.push(n), n;
723
723
  }
724
724
  push(e, t) {
@@ -778,7 +778,7 @@ var r = {
778
778
  let t = this.channels.find((t) => t.topic === e && (t.isJoined() || t.isJoining()));
779
779
  t && (this.hasLogger() && this.log("transport", `leaving duplicate topic "${e}"`), t.leave());
780
780
  }
781
- }, O = 1e3, k = 1e3, A = 150, te = 2, ne = 3e4, re = 1e4, ie = 60, ae = class {
781
+ }, ne = 1e3, re = 1e3, D = 150, ie = 2, ae = 3e4, oe = 1e4, se = 60, ce = class {
782
782
  probe;
783
783
  onChange;
784
784
  now;
@@ -814,8 +814,8 @@ var r = {
814
814
  let e = this.now(), t = e - this.lastTick;
815
815
  this.lastTick = e, this.quality === "unstable" && (this.unstableMs += t), this.quality === "offline" && (this.offlineMs += t);
816
816
  let n = this.probe.online();
817
- n && !this.wasOnline && (this.everOnline && this.reconnects++, this.everOnline = !0), !n && this.wasOnline && this.endStall(e), this.wasOnline = n, n ? (this.pingSentAt !== null && this.stallSince === null && e - this.pingSentAt >= k && (this.stallSince = this.pingSentAt), this.pingSentAt === null && e - this.lastPingAt >= O && this.sendPing(e)) : this.pingSentAt = null;
818
- let r = n ? this.stallSince !== null || e - this.lastIssueAt < re || this.recentSlow(e) >= te ? "unstable" : "good" : this.everOnline ? "offline" : "good";
817
+ n && !this.wasOnline && (this.everOnline && this.reconnects++, this.everOnline = !0), !n && this.wasOnline && this.endStall(e), this.wasOnline = n, n ? (this.pingSentAt !== null && this.stallSince === null && e - this.pingSentAt >= re && (this.stallSince = this.pingSentAt), this.pingSentAt === null && e - this.lastPingAt >= ne && this.sendPing(e)) : this.pingSentAt = null;
818
+ let r = n ? this.stallSince !== null || e - this.lastIssueAt < oe || this.recentSlow(e) >= ie ? "unstable" : "good" : this.everOnline ? "offline" : "good";
819
819
  r !== this.quality && (this.quality = r, this.onChange(r));
820
820
  }
821
821
  report() {
@@ -840,13 +840,13 @@ var r = {
840
840
  this.lastPingAt = e, this.probe.ping((t) => {
841
841
  if (this.pingSentAt !== e) return;
842
842
  let n = this.now();
843
- this.pingSentAt = null, this.pings++, this.rtt = t, this.rtts.push(t), this.rtts.length > ie && this.rtts.shift();
843
+ this.pingSentAt = null, this.pings++, this.rtt = t, this.rtts.push(t), this.rtts.length > se && this.rtts.shift();
844
844
  let [r, i, a] = this.rtts.slice(-3);
845
- a !== void 0 && i >= r + A && i >= a + A && this.slowAt.push(n), this.endStall(n), this.tick();
845
+ a !== void 0 && i >= r + D && i >= a + D && this.slowAt.push(n), this.endStall(n), this.tick();
846
846
  }) && (this.pingSentAt = e);
847
847
  }
848
848
  recentSlow(e) {
849
- for (; this.slowAt.length && e - this.slowAt[0] >= ne;) this.slowAt.shift();
849
+ for (; this.slowAt.length && e - this.slowAt[0] >= ae;) this.slowAt.shift();
850
850
  return this.slowAt.length;
851
851
  }
852
852
  endStall(e) {
@@ -854,19 +854,19 @@ var r = {
854
854
  let t = e - this.stallSince;
855
855
  this.stalls++, this.stallMs += t, this.maxStallMs = Math.max(this.maxStallMs, t), this.stallSince = null, this.lastIssueAt = e;
856
856
  }
857
- }, j = [
857
+ }, O = [
858
858
  80,
859
859
  160,
860
860
  320,
861
861
  640,
862
862
  1e3
863
863
  ];
864
- function M(e, t = Math.random) {
865
- let n = j[Math.min(Math.max(e, 1), j.length) - 1], r = Math.round(n * .2), i = Math.min(Math.max(t(), 0), .999999);
864
+ function le(e, t = Math.random) {
865
+ let n = O[Math.min(Math.max(e, 1), O.length) - 1], r = Math.round(n * .2), i = Math.min(Math.max(t(), 0), .999999);
866
866
  return n - r + Math.floor(i * (r * 2 + 1));
867
867
  }
868
868
  // ../packages/core/src/room-client.ts
869
- var N = class {
869
+ var ue = class {
870
870
  options;
871
871
  participants = /* @__PURE__ */ new Map();
872
872
  status = "connecting";
@@ -909,10 +909,10 @@ var N = class {
909
909
  }
910
910
  connect() {
911
911
  let e = this.options, t = () => this.reportNet();
912
- window.addEventListener("pagehide", t), this.offPageHide = () => window.removeEventListener("pagehide", t), this.socket = new D(e.url, {
912
+ window.addEventListener("pagehide", t), this.offPageHide = () => window.removeEventListener("pagehide", t), this.socket = new E(e.url, {
913
913
  params: e.apiToken ? { api_token: e.apiToken } : {},
914
914
  heartbeatIntervalMs: e.heartbeatMs ?? 5e3,
915
- reconnectAfterMs: (e) => M(e),
915
+ reconnectAfterMs: (e) => le(e),
916
916
  rejoinAfterMs: (e) => [
917
917
  100,
918
918
  500,
@@ -922,7 +922,7 @@ var N = class {
922
922
  logger: e.logger
923
923
  }), this.socket.onClose(() => this.setStatus("disconnected")), this.socket.connect();
924
924
  let n = this.socket;
925
- this.monitor = new ae({
925
+ this.monitor = new ce({
926
926
  ping: (e) => n.ping(e),
927
927
  online: () => n.isConnected() && this.status === "joined"
928
928
  }, (e) => {
@@ -987,7 +987,7 @@ var N = class {
987
987
  }
988
988
  joinParams() {
989
989
  let e = this.options;
990
- return I({
990
+ return j({
991
991
  v: 2,
992
992
  room_token: e.roomToken,
993
993
  type: e.type,
@@ -1079,7 +1079,7 @@ var N = class {
1079
1079
  setState(e) {
1080
1080
  e.url && (e = {
1081
1081
  ...e,
1082
- url: F(e.url)
1082
+ url: A(e.url)
1083
1083
  }), Object.assign(this.localState, e), this.push("s", e);
1084
1084
  }
1085
1085
  stop() {
@@ -1136,15 +1136,15 @@ var N = class {
1136
1136
  setFollow(e) {
1137
1137
  e === this.follow || Array.isArray(e) && Array.isArray(this.follow) && e.length === this.follow.length && e.every((e, t) => e === this.follow[t]) || (this.follow = e, this.push("follow", e));
1138
1138
  }
1139
- }, P = 2048;
1140
- function F(e) {
1141
- return e.length > 2048 ? e.slice(0, P) : e;
1139
+ }, k = 2048;
1140
+ function A(e) {
1141
+ return e.length > 2048 ? e.slice(0, k) : e;
1142
1142
  }
1143
- function I(e) {
1144
- return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, typeof t == "string" ? F(t) : t]));
1143
+ function j(e) {
1144
+ return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, typeof t == "string" ? A(t) : t]));
1145
1145
  }
1146
1146
  // ../packages/core/src/cursor-layer.ts
1147
- var L = "\n.lr-cursors { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2147483646; }\n.lr-user { position: absolute; top: 0; left: 0; user-select: none; will-change: transform; transform-origin: 0 0; }\n.lr-user[data-hidden=\"true\"] { display: none; }\n.lr-cursor { position: absolute; top: 0; left: 0; color: var(--color); transform-origin: top left; transform: rotate(6deg);\n filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.2)); overflow: visible; }\n/* Guests are light pastels: the dark contour keeps the arrow visible on white pages.\n Hosts are deep fills: a white ring keeps the arrow visible on dark pages and Meet.\n Role is the participant type already on the wire. The path touches the viewBox's\n top edge, hence the svg's visible overflow. */\n.lr-cursor path { stroke: rgb(0 0 0 / 0.6); stroke-width: 3; stroke-linejoin: round; paint-order: stroke fill; }\n.lr-user[data-type=\"admin\"] .lr-cursor path { stroke: rgb(255 255 255/.92); }\n.lr-label { position: absolute; top: 18px; left: 14px; font: 600 12px/1.6 system-ui, sans-serif; color: black;\n background: var(--color); border-radius: 9999px; padding: 0 8px; white-space: nowrap;\n box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12), 0 1px 2px rgb(0 0 0 / 0.08);\n display: flex; flex-direction: column; align-items: center; overflow: hidden; max-width: 200px; text-overflow: ellipsis; }\n.lr-user[data-type=\"admin\"] .lr-label { color: white; }\n.lr-user[data-type=\"admin\"]:not([data-live=\"true\"]):not([data-focus-motion=\"true\"]) .lr-label {\n box-shadow: 0 0 0 1.5px rgb(255 255 255/.92), 0 1px 3px rgb(0 0 0/.2); }\n.lr-user[data-type=\"admin\"][data-live=\"true\"] .lr-label > span,\n.lr-user[data-type=\"admin\"][data-focus-motion=\"true\"] .lr-label > span {\n box-shadow: 0 0 0 1.5px rgb(255 255 255/.92), 0 1px 3px rgb(0 0 0/.2); }\n.lr-label video { display: none; width: 170.6667px; height: 96px; object-fit: cover; margin: 0; }\n/* Keep the same 16:9 video surface. The small bubble is a circular crop. */\n.lr-user[data-live=\"true\"] .lr-label, .lr-user[data-focus-motion=\"true\"] .lr-label {\n padding: 0; border-radius: 0; top: 10px; left: -31.3333px; width: 170.6667px; height: 96px;\n background: transparent; box-shadow: none; overflow: visible;\n}\n.lr-user[data-live=\"true\"] .lr-label video, .lr-user[data-focus-motion=\"true\"] .lr-label video {\n display: block; clip-path: inset(0 37.3333px round 48px);\n transition: clip-path 250ms cubic-bezier(0.77, 0, 0.175, 1);\n}\n.lr-user[data-live=\"true\"] .lr-label > span, .lr-user[data-focus-motion=\"true\"] .lr-label > span {\n position: absolute; top: calc(100% + 2px); left: 50%; padding: 2px 8px; border-radius: 9999px;\n background: var(--color); opacity: 0; visibility: hidden;\n transform: translateX(-50%) scale(calc(1 / var(--focus-scale, 1))); transform-origin: top center;\n transition: opacity 200ms ease, visibility 200ms ease;\n}\n.lr-halo { position: absolute; top: -60px; left: -60px; width: 120px; height: 120px; border-radius: 9999px; z-index: -1;\n border: 1px solid color-mix(in srgb, var(--color) 75%, transparent); background: color-mix(in srgb, var(--color) 25%, transparent);\n transform: scale(0); transition: transform 200ms ease-in-out; }\n.lr-user[data-halo=\"true\"] .lr-halo { transform: scale(1); }\n.lr-user[data-self=\"true\"] .lr-cursor, .lr-user[data-self=\"true\"] .lr-label { display: none; }\n.lr-cursors::before { content: \"\"; position: absolute; inset: 0; background: rgb(39 39 42 / 25%); backdrop-filter: blur(6px); opacity: 0; transition: opacity 200ms ease; }\n.lr-cursors[data-focus=\"true\"]::before { opacity: 1; }\n.lr-user[data-focus-motion=\"true\"] { transition: transform 250ms cubic-bezier(0.77, 0, 0.175, 1); }\n.lr-user[data-focus=\"true\"] { transform: translate3d(calc(50vw - 54px * var(--focus-scale)), calc(50vh - 58px * var(--focus-scale)), 0) scale(var(--focus-scale)) !important; z-index: 1; }\n.lr-user[data-focus=\"true\"] .lr-label video { clip-path: inset(0 round 4px); }\n.lr-user[data-focus=\"true\"] .lr-label > span { opacity: 1; visibility: visible; }\n.lr-user[data-focus=\"true\"]:not([data-live=\"true\"]) .lr-label { background: #18181b; border-radius: 4px; }\n.lr-user[data-focus=\"true\"] .lr-cursor, .lr-user[data-focus=\"true\"] .lr-halo { opacity: 0; }\n@media (prefers-reduced-motion: reduce) {\n .lr-user[data-focus-motion=\"true\"], .lr-label video { transition: none !important; }\n .lr-cursors::before, .lr-label > span { transition-duration: 100ms; }\n .lr-user[data-net] .lr-label span::before { animation: none; }\n .lr-halo { transition: none !important; }\n}\n.lr-user[data-blocked=\"true\"] { opacity: 0.4; }\n/* On a bad network: a pulsing dot before the name (its cursor may freeze). */\n.lr-user[data-net=\"unstable\"] .lr-label span::before { content: \"\"; display: inline-block; width: 6px; height: 6px; margin: 0 5px 1px 0;\n border-radius: 50%; background: #d97706; box-shadow: 0 0 0 1px rgb(255 255 255 / 70%); animation: lr-pulse 1.2s ease-in-out infinite; }\n@keyframes lr-pulse { 50% { opacity: 0.3; } }\n", R = "<svg width=\"23\" viewBox=\"0 0 27 24\" fill=\"currentColor\" aria-hidden=\"true\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M2.27 0.06L25.43 8.06C25.66 8.13 25.83 8.26 25.95 8.43C26.07 8.59 26.14 8.79 26.14 8.99C26.14 9.2 26.07 9.4 25.95 9.56C25.83 9.73 25.66 9.86 25.46 9.93L15.35 13.77L11.31 23.37C11.23 23.56 11.1 23.72 10.92 23.83C10.75 23.94 10.54 24 10.33 24C10.12 24 9.91 23.94 9.73 23.82C9.55 23.7 9.42 23.53 9.34 23.34L0.92 1.34C0.86 1.16 0.84 0.97 0.89 0.78C0.93 0.6 1.03 0.43 1.17 0.29C1.31 0.16 1.49 0.07 1.68 0.02C1.88 -0.02 2.08 -0.01 2.27 0.06Z\"/></svg>", z = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i, B = (e) => z.test(e) ? e : "#a3a3a3";
1147
+ var M = "\n.lr-cursors { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2147483646; }\n.lr-user { position: absolute; top: 0; left: 0; user-select: none; will-change: transform; transform-origin: 0 0; }\n.lr-user[data-hidden=\"true\"] { display: none; }\n.lr-cursor { position: absolute; top: 0; left: 0; color: var(--color); transform-origin: top left; rotate: 6deg;\n transition: rotate 200ms cubic-bezier(0.22, 1, 0.36, 1);\n filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.2)); overflow: visible; }\n.lr-user[data-flip=\"true\"]:not([data-live=\"true\"]):not([data-focus=\"true\"]):not([data-focus-motion=\"true\"]) .lr-cursor { rotate: 88deg; }\n/* Guests are light pastels: the dark contour keeps the arrow visible on white pages.\n Hosts are deep fills: a white ring keeps the arrow visible on dark pages and Meet.\n Role is the participant type already on the wire. The path touches the viewBox's\n top edge, hence the svg's visible overflow. */\n.lr-cursor path { stroke: rgb(0 0 0 / 0.6); stroke-width: 3; stroke-linejoin: round; paint-order: stroke fill; }\n.lr-user[data-type=\"admin\"] .lr-cursor path { stroke: rgb(255 255 255/.92); }\n.lr-label { position: absolute; top: 18px; left: 0; translate: 14px 0;\n transition: translate 200ms cubic-bezier(0.22, 1, 0.36, 1);\n font: 600 12px/1.6 \"Geist\", system-ui, sans-serif; color: black;\n background: var(--color); border-radius: 9999px; padding: 0 8px; white-space: nowrap;\n box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12), 0 1px 2px rgb(0 0 0 / 0.08);\n display: flex; flex-direction: column; align-items: center; overflow: hidden; max-width: 200px; text-overflow: ellipsis; }\n.lr-user[data-flip=\"true\"]:not([data-live=\"true\"]):not([data-focus=\"true\"]):not([data-focus-motion=\"true\"]) .lr-label {\n translate: calc(-100% - 14px) 0; }\n.lr-user[data-type=\"admin\"] .lr-label { color: white; }\n.lr-user[data-type=\"admin\"]:not([data-live=\"true\"]):not([data-focus-motion=\"true\"]) .lr-label {\n box-shadow: 0 0 0 1.5px rgb(255 255 255/.92), 0 1px 3px rgb(0 0 0/.2); }\n.lr-user[data-type=\"admin\"][data-live=\"true\"] .lr-label > span,\n.lr-user[data-type=\"admin\"][data-focus-motion=\"true\"] .lr-label > span {\n box-shadow: 0 0 0 1.5px rgb(255 255 255/.92), 0 1px 3px rgb(0 0 0/.2); }\n.lr-label video { display: none; width: 170.6667px; height: 96px; object-fit: cover; margin: 0; }\n/* Keep the same 16:9 video surface. The small bubble is a circular crop. */\n.lr-user[data-live=\"true\"] .lr-label, .lr-user[data-focus-motion=\"true\"] .lr-label {\n padding: 0; border-radius: 0; top: 10px; left: -31.3333px; translate: none; transition: none; width: 170.6667px; height: 96px;\n background: transparent; box-shadow: none; overflow: visible;\n}\n.lr-user[data-live=\"true\"] .lr-label video, .lr-user[data-focus-motion=\"true\"] .lr-label video {\n display: block; clip-path: inset(0 37.3333px round 48px);\n transition: clip-path 250ms cubic-bezier(0.77, 0, 0.175, 1);\n}\n.lr-user[data-live=\"true\"] .lr-label > span, .lr-user[data-focus-motion=\"true\"] .lr-label > span {\n position: absolute; top: calc(100% + 2px); left: 50%; padding: 2px 8px; border-radius: 9999px;\n background: var(--color); opacity: 0; visibility: hidden;\n transform: translateX(-50%) scale(calc(1 / var(--focus-scale, 1))); transform-origin: top center;\n transition: opacity 200ms ease, visibility 200ms ease;\n}\n.lr-ripple { position: absolute; top: -12px; left: -12px; width: 24px; height: 24px; border-radius: 9999px;\n background: var(--color); opacity: 0; z-index: -1; pointer-events: none; }\n/* Two identical keyframes let us restart the animation by alternating data-anim\n between \"a\" and \"b\" without forcing a synchronous reflow. */\n.lr-ripple[data-anim=\"a\"] { animation: lr-click-a 450ms ease-out; }\n.lr-ripple[data-anim=\"b\"] { animation: lr-click-b 450ms ease-out; }\n@keyframes lr-click-a { 0% { opacity: 0.55; transform: scale(0.4); } 100% { opacity: 0; transform: scale(1.65); } }\n@keyframes lr-click-b { 0% { opacity: 0.55; transform: scale(0.4); } 100% { opacity: 0; transform: scale(1.65); } }\n.lr-halo { position: absolute; top: -60px; left: -60px; width: 120px; height: 120px; border-radius: 9999px; z-index: -1;\n border: 1px solid color-mix(in srgb, var(--color) 75%, transparent); background: color-mix(in srgb, var(--color) 25%, transparent);\n transform: scale(0); transition: transform 200ms ease-in-out; }\n.lr-user[data-halo=\"true\"] .lr-halo { transform: scale(1); }\n.lr-user[data-self=\"true\"] .lr-cursor, .lr-user[data-self=\"true\"] .lr-label, .lr-user[data-self=\"true\"] .lr-ripple { display: none; }\n.lr-cursors::before { content: \"\"; position: absolute; inset: 0; background: rgb(39 39 42 / 25%); backdrop-filter: blur(6px); opacity: 0; transition: opacity 200ms ease; }\n.lr-cursors[data-focus=\"true\"]::before { opacity: 1; }\n.lr-user[data-focus-motion=\"true\"] { transition: transform 250ms cubic-bezier(0.77, 0, 0.175, 1); }\n.lr-user[data-focus=\"true\"] { transform: translate3d(calc(50vw - 54px * var(--focus-scale)), calc(50vh - 58px * var(--focus-scale)), 0) scale(var(--focus-scale)) !important; z-index: 1; }\n.lr-user[data-focus=\"true\"] .lr-label video { clip-path: inset(0 round 4px); }\n.lr-user[data-focus=\"true\"] .lr-label > span { opacity: 1; visibility: visible; }\n.lr-user[data-focus=\"true\"]:not([data-live=\"true\"]) .lr-label { background: #18181b; border-radius: 4px; }\n.lr-user[data-focus=\"true\"] .lr-cursor, .lr-user[data-focus=\"true\"] .lr-halo, .lr-user[data-focus=\"true\"] .lr-ripple { opacity: 0; }\n@media (prefers-reduced-motion: reduce) {\n .lr-user[data-focus-motion=\"true\"], .lr-label video { transition: none !important; }\n .lr-cursor, .lr-label { transition: none !important; }\n .lr-ripple { animation: none !important; }\n .lr-cursors::before, .lr-label > span { transition-duration: 100ms; }\n .lr-user[data-net] .lr-label span::before { animation: none; }\n .lr-halo { transition: none !important; }\n}\n.lr-user[data-blocked=\"true\"] { opacity: 0.4; }\n/* On a bad network: a pulsing dot before the name (its cursor may freeze). */\n.lr-user[data-net=\"unstable\"] .lr-label span::before { content: \"\"; display: inline-block; width: 6px; height: 6px; margin: 0 5px 1px 0;\n border-radius: 50%; background: #d97706; box-shadow: 0 0 0 1px rgb(255 255 255 / 70%); animation: lr-pulse 1.2s ease-in-out infinite; }\n@keyframes lr-pulse { 50% { opacity: 0.3; } }\n", N = "<svg width=\"23\" viewBox=\"0 0 27 24\" fill=\"currentColor\" aria-hidden=\"true\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M2.27 0.06L25.43 8.06C25.66 8.13 25.83 8.26 25.95 8.43C26.07 8.59 26.14 8.79 26.14 8.99C26.14 9.2 26.07 9.4 25.95 9.56C25.83 9.73 25.66 9.86 25.46 9.93L15.35 13.77L11.31 23.37C11.23 23.56 11.1 23.72 10.92 23.83C10.75 23.94 10.54 24 10.33 24C10.12 24 9.91 23.94 9.73 23.82C9.55 23.7 9.42 23.53 9.34 23.34L0.92 1.34C0.86 1.16 0.84 0.97 0.89 0.78C0.93 0.6 1.03 0.43 1.17 0.29C1.31 0.16 1.49 0.07 1.68 0.02C1.88 -0.02 2.08 -0.01 2.27 0.06Z\"/></svg>", P = 120, F = 600, I = 22, L = 24, R = 64, z = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i, B = (e) => z.test(e) ? e : "#a3a3a3";
1148
1148
  function V(e, t, n) {
1149
1149
  e.dataset[t] !== n && (e.dataset[t] = n);
1150
1150
  }
@@ -1163,7 +1163,7 @@ var H = class {
1163
1163
  ...e
1164
1164
  };
1165
1165
  let t = e.container.ownerDocument;
1166
- this.style = t.createElement("style"), this.style.textContent = L, (e.styleRoot.nodeType === 9 ? e.styleRoot.head : e.styleRoot).appendChild(this.style), this.trace = t.documentElement.hasAttribute("data-liveroom-trace"), this.root = t.createElement("div"), this.root.className = "lr-cursors", e.container.appendChild(this.root);
1166
+ this.style = t.createElement("style"), this.style.textContent = M, (e.styleRoot.nodeType === 9 ? e.styleRoot.head : e.styleRoot).appendChild(this.style), this.trace = t.documentElement.hasAttribute("data-liveroom-trace"), this.root = t.createElement("div"), this.root.className = "lr-cursors", e.container.appendChild(this.root);
1167
1167
  }
1168
1168
  destroy() {
1169
1169
  cancelAnimationFrame(this.frame), this.root.remove(), this.style.remove();
@@ -1173,6 +1173,12 @@ var H = class {
1173
1173
  videoFor(e) {
1174
1174
  return this.nodes.get(e)?.video;
1175
1175
  }
1176
+ pulse(e, t) {
1177
+ let n = this.nodes.get(e);
1178
+ if (!n || n.el.dataset.self === "true") return;
1179
+ let r = performance.now();
1180
+ t?.fromClick && (n.mouseDown || r - n.lastMouseDownAt < F) || r - n.lastPulseAt < P || (n.lastPulseAt = r, n.ripple.dataset.anim = n.ripple.dataset.anim === "a" ? "b" : "a");
1181
+ }
1176
1182
  sync(e) {
1177
1183
  let t = /* @__PURE__ */ new Set();
1178
1184
  for (let n of e) t.add(n.id), this.update(n);
@@ -1188,11 +1194,17 @@ var H = class {
1188
1194
  }
1189
1195
  update(e) {
1190
1196
  let t = this.nodes.get(e.id) ?? this.create(e), n = t.el, i = B(e.color);
1191
- n.style.getPropertyValue("--color") !== i && n.style.setProperty("--color", i), t.label.firstChild.textContent !== e.name && (t.label.firstChild.textContent = e.name), t.video.getAttribute("aria-label") !== e.name && t.video.setAttribute("aria-label", e.name), V(n, "type", e.type === "admin" ? "admin" : "client"), V(n, "self", String(!!e.self)), V(n, "camera", String((e.camera || e.type === "admin" && (e.flags & r.focus) !== 0) && !e.self));
1192
- let a = String(e.type === "admin" && !e.self && (e.flags & r.focus) !== 0);
1193
- n.dataset.focus !== a && (clearTimeout(t.focusExitTimer), (n.dataset.focus !== void 0 || a === "true") && V(n, "focusMotion", "true"), this.setFocusScale(n), V(n, "focus", a), a === "false" && n.dataset.focusMotion === "true" && (t.focusExitTimer = setTimeout(() => {
1194
- V(n, "focusMotion", "false");
1195
- }, 300)), this.updateFocus()), V(n, "blocked", String(!!e.blocked)), V(n, "net", e.net ?? "good"), V(n, "halo", String((e.flags & r.shift) !== 0 || !e.self && (e.flags & r.mouseDown) !== 0)), this.setTarget(e.id, e.x, e.y);
1197
+ n.style.getPropertyValue("--color") !== i && n.style.setProperty("--color", i), t.label.firstChild.textContent !== e.name && (t.label.firstChild.textContent = e.name, t.labelDirty = !0), t.video.getAttribute("aria-label") !== e.name && t.video.setAttribute("aria-label", e.name), V(n, "type", e.type === "admin" ? "admin" : "client"), V(n, "self", String(!!e.self));
1198
+ let a = String((e.camera || e.type === "admin" && (e.flags & r.focus) !== 0) && !e.self);
1199
+ n.dataset.camera !== a && (V(n, "camera", a), t.labelDirty = !0);
1200
+ let o = String(e.type === "admin" && !e.self && (e.flags & r.focus) !== 0);
1201
+ n.dataset.focus !== o && (clearTimeout(t.focusExitTimer), (n.dataset.focus !== void 0 || o === "true") && V(n, "focusMotion", "true"), this.setFocusScale(n), V(n, "focus", o), o === "false" && n.dataset.focusMotion === "true" && (t.focusExitTimer = setTimeout(() => {
1202
+ V(n, "focusMotion", "false"), t.labelDirty = !0;
1203
+ }, 300)), this.updateFocus()), V(n, "blocked", String(!!e.blocked));
1204
+ let s = e.net ?? "good";
1205
+ n.dataset.net !== s && (V(n, "net", s), t.labelDirty = !0);
1206
+ let c = !e.self && (e.flags & r.mouseDown) !== 0;
1207
+ c && !t.mouseDown && (t.lastMouseDownAt = performance.now(), this.pulse(e.id)), t.mouseDown = c, V(n, "halo", String((e.flags & r.shift) !== 0 || c)), this.setTarget(e.id, e.x, e.y);
1196
1208
  }
1197
1209
  setTarget(e, t, n, r = !1) {
1198
1210
  let i = this.nodes.get(e);
@@ -1204,20 +1216,37 @@ var H = class {
1204
1216
  let s = i.lastTargetAt === 0 ? 0 : o - i.lastTargetAt;
1205
1217
  i.duration = this.options.smooth && s >= this.options.minSmoothGapMs ? Math.min(s, this.options.maxSmoothMs) : 0, i.lastTargetAt = o, i.duration === 0 ? this.place(i, i.toX, i.toY, !0) : this.schedule();
1206
1218
  }
1207
- place(e, t, n, r, i = this.options.scale?.() ?? 1) {
1208
- e.x = t, e.y = n, e.el.style.transform = `translate3d(${t}px, ${n}px, 0) scale(${i})`, r && (e.arrived = !0, this.trace && (e.el.dataset.x = e.target[0].toFixed(2), e.el.dataset.y = e.target[1].toFixed(2)));
1219
+ rightEdge() {
1220
+ return this.options.rightEdge ? this.options.rightEdge() : this.root.clientWidth || this.root.ownerDocument.defaultView?.innerWidth || 0;
1221
+ }
1222
+ measureLabelWidth(e) {
1223
+ return e.labelDirty && (e.labelDirty = !1, e.labelWidth = e.label.offsetWidth), e.labelWidth || R;
1224
+ }
1225
+ updateFlip(e, t, n, r) {
1226
+ if (r <= 0) return;
1227
+ let i = (this.measureLabelWidth(e) + I) * n, a = L * n;
1228
+ !e.flipped && r - t < i ? e.flipped = !0 : e.flipped && r - t > i + a && (e.flipped = !1), V(e.el, "flip", String(e.flipped));
1229
+ }
1230
+ place(e, t, n, r, i = this.options.scale?.() ?? 1, a = this.rightEdge()) {
1231
+ e.x = t, e.y = n, e.el.style.transform = `translate3d(${t}px, ${n}px, 0) scale(${i})`, this.updateFlip(e, t, i, a), r && (e.arrived = !0, this.trace && (e.el.dataset.x = e.target[0].toFixed(2), e.el.dataset.y = e.target[1].toFixed(2)));
1209
1232
  }
1210
1233
  relayout() {
1211
- for (let [e, t] of this.nodes) t.el.dataset.focus === "true" && this.setFocusScale(t.el), t.arrived = !1, t.lastTargetAt = 0, this.setTarget(e, t.target[0], t.target[1], !0);
1234
+ let e = this.options.scale?.() ?? 1, t = this.rightEdge(), n = [];
1235
+ for (let e of this.nodes.values()) e.labelDirty = !0, this.measureLabelWidth(e), n.push({
1236
+ node: e,
1237
+ px: this.options.map(e.target[0], e.target[1])
1238
+ });
1239
+ for (let { node: r, px: i } of n) r.el.dataset.focus === "true" && this.setFocusScale(r.el), r.arrived = !1, r.lastTargetAt = 0, r.el.dataset.hidden = String(!i), i && (r.fromX = r.x, r.fromY = r.y, r.toX = i.left, r.toY = i.top, r.duration = 0, this.place(r, i.left, i.top, !0, e, t));
1212
1240
  }
1213
1241
  create(e) {
1214
1242
  let t = this.root.ownerDocument.createElement("div");
1215
- t.className = "lr-user", t.id = `user-${e.id}`, t.innerHTML = `${R.replace("<svg", "<svg class=\"lr-cursor\"")}<div class="lr-label"><span></span><video autoplay muted playsinline></video></div><div class="lr-halo"></div>`;
1216
- let n = t.querySelector(".lr-label");
1243
+ t.className = "lr-user", t.id = `user-${e.id}`, t.innerHTML = `<div class="lr-ripple"></div>${N.replace("<svg", "<svg class=\"lr-cursor\"")}<div class="lr-label"><span></span><video autoplay muted playsinline></video></div><div class="lr-halo"></div>`;
1244
+ let n = t.querySelector(".lr-label"), r = t.querySelector(".lr-ripple");
1217
1245
  n.firstElementChild.textContent = e.name, this.root.appendChild(t);
1218
- let r = {
1246
+ let i = {
1219
1247
  el: t,
1220
1248
  label: n,
1249
+ ripple: r,
1221
1250
  video: t.querySelector("video"),
1222
1251
  x: 0,
1223
1252
  y: 0,
@@ -1229,22 +1258,30 @@ var H = class {
1229
1258
  duration: 0,
1230
1259
  lastTargetAt: 0,
1231
1260
  target: [NaN, NaN],
1232
- arrived: !1
1261
+ arrived: !1,
1262
+ flipped: !1,
1263
+ labelWidth: 0,
1264
+ labelDirty: !0,
1265
+ mouseDown: !1,
1266
+ lastMouseDownAt: -Infinity,
1267
+ lastPulseAt: -Infinity
1233
1268
  };
1234
- return this.nodes.set(e.id, r), r;
1269
+ return this.nodes.set(e.id, i), i;
1235
1270
  }
1236
1271
  schedule() {
1237
1272
  this.frame ||= requestAnimationFrame(() => this.render());
1238
1273
  }
1239
1274
  render() {
1240
1275
  this.frame = 0;
1241
- let e = performance.now(), t = this.options.scale?.() ?? 1, n = !1;
1242
- for (let r of this.nodes.values()) {
1243
- if (r.arrived) continue;
1244
- let i = r.duration > 0 ? Math.min(1, (e - r.start) / r.duration) : 1, a = r.fromX + (r.toX - r.fromX) * i, o = r.fromY + (r.toY - r.fromY) * i;
1245
- this.place(r, a, o, i >= 1, t), i < 1 && (n = !0);
1276
+ let e = performance.now(), t = this.options.scale?.() ?? 1, n = this.rightEdge();
1277
+ for (let e of this.nodes.values()) !e.arrived && e.labelDirty && this.measureLabelWidth(e);
1278
+ let r = !1;
1279
+ for (let i of this.nodes.values()) {
1280
+ if (i.arrived) continue;
1281
+ let a = i.duration > 0 ? Math.min(1, (e - i.start) / i.duration) : 1, o = i.fromX + (i.toX - i.fromX) * a, s = i.fromY + (i.toY - i.fromY) * a;
1282
+ this.place(i, o, s, a >= 1, t, n), a < 1 && (r = !0);
1246
1283
  }
1247
- n && this.schedule();
1284
+ r && this.schedule();
1248
1285
  }
1249
1286
  };
1250
1287
  // ../packages/core/src/cameras.ts
@@ -1252,7 +1289,7 @@ function U(e, t) {
1252
1289
  let n = e?.closest(".lr-user");
1253
1290
  n && (n.dataset.live = String(t));
1254
1291
  }
1255
- var W = (e, t) => e.type === "admin" && ((e.id === t.you ? t.ownFlags : e.flags) & r.focus) !== 0, G = (e, t) => e.camera || W(e, t), K = class {
1292
+ var W = (e, t) => e.type === "admin" && ((e.id === t.you ? t.ownFlags : e.flags) & r.focus) !== 0, G = (e, t) => e.camera || W(e, t), de = class {
1256
1293
  options;
1257
1294
  room = null;
1258
1295
  connecting = null;
@@ -1334,34 +1371,76 @@ var W = (e, t) => e.type === "admin" && ((e.id === t.you ? t.ownFlags : e.flags)
1334
1371
  this.options.log?.("livekit connect failed", e), this.scheduleRetry();
1335
1372
  }
1336
1373
  }
1337
- }, q = "16px/1.5 system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
1338
- function J(e) {
1339
- return `:host { all: initial !important; display: block !important; font: ${q} !important; color: #0f172a !important; text-align: left !important; direction: ltr !important; ${e.split(";").map((e) => e.trim()).filter(Boolean).map((e) => `${e.replace(/\s*!important$/, "")} !important;`).join(" ")} }`;
1374
+ }, fe = "16px/1.5 system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
1375
+ function pe(e) {
1376
+ return `:host { all: initial !important; display: block !important; font: ${fe} !important; color: #0f172a !important; text-align: left !important; direction: ltr !important; ${e.split(";").map((e) => e.trim()).filter(Boolean).map((e) => `${e.replace(/\s*!important$/, "")} !important;`).join(" ")} }`;
1340
1377
  }
1341
1378
  // src/pill.ts
1342
- var oe = "#94A3B8", se = "#F59E0B", ce = "#EF4444", le = 3e3, ue = 600;
1343
- function Y(e) {
1344
- let t = de(e.people), n = t.filter((e) => e.pointed), r = n.some((e) => e.clicks), i = e.stopped && t.length > 0, a = n.length > 0 && !e.stopped, o = e.quality !== "good";
1379
+ var me = "#94A3B8", he = "#F59E0B", ge = "#EF4444", _e = 3e3, ve = 600, ye = 1e3, be = 4, xe = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i, K = (e) => xe.test(e) ? e : "#a3a3a3";
1380
+ function Se(e, t) {
1381
+ let n = [];
1382
+ for (let r of e) r.type === "admin" && r.id !== t && n.push({
1383
+ id: r.id,
1384
+ name: r.name,
1385
+ color: K(r.color),
1386
+ clicks: (r.flags & be) !== 0,
1387
+ pointed: r.cursorAt > 0,
1388
+ movedAt: r.cursorAt
1389
+ });
1390
+ return n;
1391
+ }
1392
+ function q(e) {
1393
+ let t = we(e.people), n = t.filter((e) => e.pointed), r = n.some((e) => e.clicks), i = e.stopped && t.length > 0, a = n.length > 0 && !e.stopped, o = e.quality !== "good";
1345
1394
  if (!i && !a && !o) return {
1346
1395
  visible: !1,
1347
1396
  label: "",
1348
1397
  button: null,
1349
1398
  dots: [],
1399
+ dotKind: "host",
1350
1400
  quality: null
1351
1401
  };
1352
- let s = i && e.sinceStopMs !== null && e.sinceStopMs < le, c = i ? he(t, e.sinceStopMs !== null && e.sinceStopMs < ue) : a ? me(n, r) : null;
1402
+ let s = i && e.sinceStopMs !== null && e.sinceStopMs < _e, c = i ? Oe(t, e.sinceStopMs !== null && e.sinceStopMs < ve) : a ? De(n, r) : null, l = o ? e.quality === "offline" ? "Reconnecting…" : "Unstable connection" : i ? Ee(t, s) : Te(n, r), u = o || i;
1353
1403
  return {
1354
1404
  visible: !0,
1355
- label: o ? e.quality === "offline" ? "Reconnecting…" : "Unstable connection" : i ? pe(t, s) : fe(n, r),
1405
+ label: l,
1356
1406
  button: c,
1357
- dots: o ? [e.quality === "offline" ? ce : se] : i ? [oe] : n.slice(0, 3).map((e) => e.color),
1407
+ dots: o ? [e.quality === "offline" ? ge : he] : i ? [me] : Ce(Y(n), e.dotIds).map((e) => K(e.color)),
1408
+ dotKind: u ? "status" : "host",
1358
1409
  quality: e.quality === "good" ? null : e.quality
1359
1410
  };
1360
1411
  }
1361
- function de(e) {
1412
+ function J(e, t, n) {
1413
+ let r = Y(e.filter((e) => e.pointed));
1414
+ if (!n || t - n.at >= 1e3) return {
1415
+ at: t,
1416
+ ids: r.slice(0, 3).map((e) => e.id)
1417
+ };
1418
+ let i = new Set(r.map((e) => e.id)), a = n.ids.filter((e) => i.has(e));
1419
+ for (let e of r) {
1420
+ if (a.length >= 3) break;
1421
+ a.includes(e.id) || a.push(e.id);
1422
+ }
1423
+ return {
1424
+ at: n.at,
1425
+ ids: a
1426
+ };
1427
+ }
1428
+ function Y(e) {
1429
+ return [...e].sort((e, t) => t.movedAt - e.movedAt || e.name.localeCompare(t.name) || e.id.localeCompare(t.id));
1430
+ }
1431
+ function Ce(e, t) {
1432
+ if (!t) return e.slice(0, 3);
1433
+ let n = new Map(e.map((e) => [e.id, e])), r = [];
1434
+ for (let e of t) {
1435
+ let t = n.get(e);
1436
+ if (t && (r.push(t), r.length === 3)) break;
1437
+ }
1438
+ return r;
1439
+ }
1440
+ function we(e) {
1362
1441
  return [...e].sort((e, t) => e.name.localeCompare(t.name) || e.id.localeCompare(t.id));
1363
1442
  }
1364
- function fe(e, t) {
1443
+ function Te(e, t) {
1365
1444
  if (e.length === 1) return t ? `${e[0].name} can point and click` : `${e[0].name} is pointing`;
1366
1445
  if (e.length === 2) {
1367
1446
  let n = `${e[0].name} and ${e[1].name}`;
@@ -1369,10 +1448,10 @@ function fe(e, t) {
1369
1448
  }
1370
1449
  return t ? `${e.length} people can point and click` : `${e.length} people are pointing`;
1371
1450
  }
1372
- function pe(e, t) {
1451
+ function Ee(e, t) {
1373
1452
  return t ? e.length === 1 ? `You stopped ${e[0].name}'s cursor` : `You stopped ${e.length} cursors` : e.length === 1 ? `${e[0].name}'s cursor is off` : `${e.length} cursors are off`;
1374
1453
  }
1375
- function me(e, t) {
1454
+ function De(e, t) {
1376
1455
  return {
1377
1456
  text: "Stop",
1378
1457
  ariaLabel: e.length === 1 ? t ? `Stop ${e[0].name}'s cursor and clicks` : `Stop ${e[0].name}'s cursor` : e.length === 2 ? `Stop ${e[0].name}'s and ${e[1].name}'s cursors` : `Stop all ${e.length} cursors`,
@@ -1380,7 +1459,7 @@ function me(e, t) {
1380
1459
  action: "stop"
1381
1460
  };
1382
1461
  }
1383
- function he(e, t) {
1462
+ function Oe(e, t) {
1384
1463
  if (e.length === 1) {
1385
1464
  let n = `Let ${e[0].name} point again`;
1386
1465
  return {
@@ -1397,7 +1476,7 @@ function he(e, t) {
1397
1476
  action: "resume"
1398
1477
  };
1399
1478
  }
1400
- var ge = "\n.lr-pill { position: fixed; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 6px;\n padding: 4px 4px 4px 6px; border-radius: 9999px; background: rgb(15 23 42 / 85%);\n box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%), 0 1px 3px rgb(0 0 0 / 20%);\n color: #fff; font: 500 12px/1.5 system-ui, sans-serif; pointer-events: auto; user-select: none;\n cursor: grab; opacity: 0; transition: opacity 200ms ease-out, transform 200ms ease-out; z-index: 2; }\n.lr-pill[data-shown=\"true\"] { opacity: 1; }\n.lr-pill[hidden] { display: none !important; }\n.lr-pill[data-button=\"false\"] { padding: 4px 10px 4px 6px; }\n.lr-grip { width: 6px; height: 10px; flex: none; background: radial-gradient(circle, rgb(255 255 255 / 55%) 1px, transparent 1.2px) 0 0 / 4px 4px; }\n.lr-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--dot, #94A3B8); box-shadow: 0 0 0 1px rgb(255 255 255 / 25%); }\n.lr-dots { display: flex; flex: none; }\n.lr-dots .lr-dot { box-shadow: 0 0 0 1.5px rgb(15 23 42); }\n.lr-dots .lr-dot + .lr-dot { margin-left: -3px; }\n.lr-label { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.lr-btn { height: 24px; min-width: 44px; max-width: 200px; padding: 0 10px; margin-left: 2px; border: 0; border-radius: 9999px;\n background: rgb(255 255 255 / 14%); color: #fff; font: 600 12px/24px system-ui, sans-serif; cursor: pointer;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.lr-btn:hover { background: rgb(255 255 255 / 22%); }\n.lr-btn:active { background: rgb(255 255 255 / 28%); }\n.lr-btn[aria-disabled=\"true\"] { color: rgb(255 255 255 / 55%); cursor: default; }\n.lr-btn:focus-visible { outline: 2px solid #818CF8; outline-offset: 2px; }\n.lr-pill.dragging { cursor: grabbing; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%), 0 6px 16px -4px rgb(0 0 0 / 35%); }\n.lr-pill.snapping { transition: left 160ms cubic-bezier(.2,.8,.2,1), top 160ms cubic-bezier(.2,.8,.2,1), opacity 200ms ease-out; }\n.lr-target { position: fixed; border: 1.5px dashed rgb(129 140 248 / 70%); border-radius: 12px; pointer-events: none; box-sizing: border-box; }\n.lr-target[data-near=\"true\"] { background: rgb(129 140 248 / 15%); }\n@media (prefers-reduced-motion: reduce) {\n .lr-pill, .lr-pill.snapping { animation: none; transition: none; transform: none !important; }\n}\n", X = class {
1479
+ var ke = "\n.lr-pill { position: fixed; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 6px;\n padding: 4px 4px 4px 6px; border-radius: 9999px; background: rgb(14 15 21 / 90%);\n backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);\n box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%), 0 6px 18px -6px rgb(0 0 0 / 38%);\n color: #F5F6FB; font: 500 12px/1.5 \"Geist\", system-ui, -apple-system, sans-serif; pointer-events: auto; user-select: none;\n cursor: grab; opacity: 0; transition: opacity 200ms cubic-bezier(0.22, 1, 0.36, 1), transform 200ms cubic-bezier(0.22, 1, 0.36, 1); z-index: 2; }\n.lr-pill[data-shown=\"true\"] { opacity: 1; }\n.lr-pill[hidden] { display: none !important; }\n.lr-pill[data-button=\"false\"] { padding: 4px 10px 4px 6px; }\n.lr-grip { width: 6px; height: 10px; flex: none; background: radial-gradient(circle, rgb(255 255 255 / 55%) 1px, transparent 1.2px) 0 0 / 4px 4px; }\n.lr-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; position: relative; background: var(--lr-host-color, #94A3B8); box-shadow: 0 0 0 1.5px rgb(255 255 255 / 92%); }\n.lr-dot[data-kind=\"status\"] { box-shadow: 0 0 0 1px rgb(255 255 255 / 25%); }\n.lr-dots { display: flex; flex: none; }\n.lr-dots .lr-dot:nth-child(1) { z-index: 3; }\n.lr-dots .lr-dot:nth-child(2) { z-index: 2; }\n.lr-dots .lr-dot:nth-child(3) { z-index: 1; }\n.lr-dots .lr-dot + .lr-dot { margin-left: -3px; }\n.lr-label { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.lr-btn { height: 24px; min-width: 44px; max-width: 200px; padding: 0 10px; margin-left: 2px; border: 0; border-radius: 9999px;\n background: rgb(255 255 255 / 14%); color: #fff; font: 600 12px/24px system-ui, sans-serif; cursor: pointer;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.lr-btn:hover { background: rgb(255 255 255 / 22%); }\n.lr-btn:active { background: rgb(255 255 255 / 28%); }\n.lr-btn[aria-disabled=\"true\"] { color: rgb(255 255 255 / 55%); cursor: default; }\n.lr-btn:focus-visible { outline: 2px solid #818CF8; outline-offset: 2px; }\n.lr-pill.dragging { cursor: grabbing; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%), 0 6px 16px -4px rgb(0 0 0 / 35%); }\n.lr-pill.snapping { transition: left 160ms cubic-bezier(.2,.8,.2,1), top 160ms cubic-bezier(.2,.8,.2,1), opacity 200ms ease-out; }\n.lr-target { position: fixed; border: 1.5px dashed rgb(129 140 248 / 70%); border-radius: 12px; pointer-events: none; box-sizing: border-box; }\n.lr-target[data-near=\"true\"] { background: rgb(129 140 248 / 15%); }\n@media (prefers-reduced-motion: reduce) {\n .lr-pill, .lr-pill.snapping { animation: none; transition: none; transform: none !important; }\n}\n", Ae = class {
1401
1480
  root;
1402
1481
  label;
1403
1482
  dots;
@@ -1408,19 +1487,22 @@ var ge = "\n.lr-pill { position: fixed; left: 12px; bottom: 12px; display: flex;
1408
1487
  hideTimer;
1409
1488
  qualityTimer;
1410
1489
  quality = "good";
1490
+ dotOrder = null;
1491
+ orderTimer;
1492
+ paintedDots = "";
1411
1493
  model = {
1412
1494
  stopped: !1,
1413
1495
  sinceStopMs: null,
1414
1496
  people: []
1415
1497
  };
1416
- view = Y({
1498
+ view = q({
1417
1499
  ...this.model,
1418
1500
  quality: "good"
1419
1501
  });
1420
1502
  drag = null;
1421
1503
  handlers;
1422
1504
  constructor(e, t) {
1423
- this.handlers = t, this.style = document.createElement("style"), this.style.textContent = ge, this.root = document.createElement("div"), this.root.className = "lr-pill", this.root.role = "group", this.root.setAttribute("aria-label", "Liveroom"), this.root.hidden = !0, this.root.dataset.shown = "false";
1505
+ this.handlers = t, this.style = document.createElement("style"), this.style.textContent = ke, this.root = document.createElement("div"), this.root.className = "lr-pill", this.root.role = "group", this.root.setAttribute("aria-label", "Liveroom"), this.root.hidden = !0, this.root.dataset.shown = "false";
1424
1506
  let n = document.createElement("span");
1425
1507
  n.className = "lr-grip", n.ariaHidden = "true", this.dots = document.createElement("span"), this.dots.className = "lr-dots", this.dots.ariaHidden = "true", this.label = document.createElement("span"), this.label.className = "lr-label", this.label.role = "status", this.label.ariaLive = "polite", this.button = document.createElement("button"), this.button.type = "button", this.button.className = "lr-btn", this.button.addEventListener("click", (e) => {
1426
1508
  this.button.getAttribute("aria-disabled") === "true" ? (e.preventDefault(), e.stopPropagation()) : this.view.button?.action === "resume" ? this.handlers.onResume() : this.view.button?.action === "stop" && this.handlers.onStop();
@@ -1435,18 +1517,34 @@ var ge = "\n.lr-pill { position: fixed; left: 12px; bottom: 12px; display: flex;
1435
1517
  }, 500);
1436
1518
  }
1437
1519
  destroy() {
1438
- window.clearTimeout(this.hideTimer), window.clearTimeout(this.qualityTimer), this.style.remove(), this.root.remove();
1520
+ window.clearTimeout(this.hideTimer), window.clearTimeout(this.qualityTimer), window.clearTimeout(this.orderTimer), this.style.remove(), this.root.remove();
1439
1521
  for (let e of this.targets) e.remove();
1440
1522
  }
1441
1523
  paint() {
1442
- let e = Y({
1524
+ let e = performance.now(), t = J(this.model.people, e, this.dotOrder);
1525
+ this.dotOrder = t;
1526
+ let n = q({
1443
1527
  ...this.model,
1444
- quality: this.quality
1528
+ quality: this.quality,
1529
+ dotIds: t.ids
1445
1530
  });
1446
- this.view = e, e.visible ? (this.label.textContent !== e.label && (this.label.textContent = e.label), this.dots.replaceChildren(...e.dots.map((e) => {
1531
+ if (this.view = n, this.armOrder(t, e, n), !n.visible) {
1532
+ this.dotOrder = null, this.fadeOut();
1533
+ return;
1534
+ }
1535
+ this.label.textContent !== n.label && (this.label.textContent = n.label);
1536
+ let r = `${n.dotKind}:${n.dots.join("|")}`;
1537
+ r !== this.paintedDots && (this.paintedDots = r, this.dots.replaceChildren(...n.dots.map((e) => {
1447
1538
  let t = document.createElement("span");
1448
- return t.className = "lr-dot", t.style.setProperty("--dot", e), t;
1449
- })), e.quality ? this.root.dataset.quality = e.quality : delete this.root.dataset.quality, e.button ? (this.button.hidden = !1, this.button.textContent !== e.button.text && (this.button.textContent = e.button.text), this.button.getAttribute("aria-label") !== e.button.ariaLabel && this.button.setAttribute("aria-label", e.button.ariaLabel), e.button.disabled ? this.button.setAttribute("aria-disabled", "true") : this.button.removeAttribute("aria-disabled"), this.root.dataset.button = "true") : (this.button.hidden = !0, this.button.removeAttribute("aria-disabled"), this.root.dataset.button = "false"), this.fadeIn()) : this.fadeOut();
1539
+ return t.className = "lr-dot", t.style.setProperty("--lr-host-color", e), n.dotKind === "status" && (t.dataset.kind = "status"), t;
1540
+ }))), n.quality ? this.root.dataset.quality = n.quality : delete this.root.dataset.quality, n.button ? (this.button.hidden = !1, this.button.textContent !== n.button.text && (this.button.textContent = n.button.text), this.button.getAttribute("aria-label") !== n.button.ariaLabel && this.button.setAttribute("aria-label", n.button.ariaLabel), n.button.disabled ? this.button.setAttribute("aria-disabled", "true") : this.button.removeAttribute("aria-disabled"), this.root.dataset.button = "true") : (this.button.hidden = !0, this.button.removeAttribute("aria-disabled"), this.root.dataset.button = "false"), this.fadeIn();
1541
+ }
1542
+ armOrder(e, t, n) {
1543
+ if (window.clearTimeout(this.orderTimer), !n.visible || n.dotKind !== "host") return;
1544
+ let r = J(this.model.people, t, null).ids, i = e.ids;
1545
+ if (r.length === i.length && r.every((e, t) => e === i[t])) return;
1546
+ let a = Math.max(0, e.at + ye - t);
1547
+ this.orderTimer = window.setTimeout(() => this.paint(), a);
1450
1548
  }
1451
1549
  fadeIn() {
1452
1550
  window.clearTimeout(this.hideTimer), this.shown || (this.shown = !0, this.resetCorner(), this.root.hidden = !1, this.root.dataset.shown = "false", requestAnimationFrame(() => {
@@ -1548,28 +1646,28 @@ var ge = "\n.lr-pill { position: fixed; left: 12px; bottom: 12px; display: flex;
1548
1646
  }
1549
1647
  };
1550
1648
  // src/stylesheets.ts
1551
- function _e() {
1649
+ function X() {
1552
1650
  let e = document.createElement("style");
1553
1651
  return e.textContent = "\n * {\n cursor: crosshair !important;\n }\n ", e;
1554
1652
  }
1555
- function ve() {
1653
+ function je() {
1556
1654
  let e = document.createElement("style");
1557
1655
  return e.textContent = "\n * {\n pointer-events: none !important;\n user-select: none !important;\n }\n ", e;
1558
1656
  }
1559
- function ye() {
1657
+ function Me() {
1560
1658
  let e = document.createElement("style");
1561
1659
  return e.textContent = "\n html { overflow: hidden !important; scrollbar-gutter: stable !important; }\n * { touch-action: none !important; overscroll-behavior: none !important; }\n ", e;
1562
1660
  }
1563
1661
  // src/element.ts
1564
- var be = J("position: fixed; inset: 0; pointer-events: none; z-index: 2147483646; width: auto; height: auto"), Z = class extends HTMLElement {
1662
+ var Ne = pe("position: fixed; inset: 0; pointer-events: none; z-index: 2147483646; width: auto; height: auto"), Z = class extends HTMLElement {
1565
1663
  client;
1566
1664
  layer;
1567
1665
  cameras;
1568
1666
  cleanup = [];
1569
- blockMouseStyle = _e();
1570
- blockPointerStyle = ve();
1667
+ blockMouseStyle = X();
1668
+ blockPointerStyle = je();
1571
1669
  blocked = !1;
1572
- blockScrollStyle = ye();
1670
+ blockScrollStyle = Me();
1573
1671
  pointer = [50, 50];
1574
1672
  shift = !1;
1575
1673
  pill;
@@ -1589,10 +1687,10 @@ var be = J("position: fixed; inset: 0; pointer-events: none; z-index: 2147483646
1589
1687
  let o = this.shadowRoot ?? this.attachShadow({ mode: "open" });
1590
1688
  o.replaceChildren();
1591
1689
  let s = document.createElement("style");
1592
- s.textContent = be, o.appendChild(s);
1690
+ s.textContent = Ne, o.appendChild(s);
1593
1691
  let c = document.createElement("div");
1594
1692
  c.id = "liveroom-client-element", c.style.cssText = "position: fixed; inset: 0; pointer-events: none;", o.appendChild(c);
1595
- let l = this.client = new N({
1693
+ let l = this.client = new ue({
1596
1694
  url: a,
1597
1695
  roomId: r,
1598
1696
  roomToken: i,
@@ -1613,8 +1711,9 @@ var be = J("position: fixed; inset: 0; pointer-events: none; z-index: 2147483646
1613
1711
  map: (e, t) => ({
1614
1712
  left: e / 100 * innerWidth,
1615
1713
  top: t / 100 * innerHeight
1616
- })
1617
- }), this.cameras = new K({
1714
+ }),
1715
+ rightEdge: () => innerWidth
1716
+ }), this.cameras = new de({
1618
1717
  preconnect: !0,
1619
1718
  client: l,
1620
1719
  publish: !1,
@@ -1635,11 +1734,11 @@ var be = J("position: fixed; inset: 0; pointer-events: none; z-index: 2147483646
1635
1734
  e && !this.hostHidden(e) && (this.layer.update(e), e.type === "admin" && (n = !0));
1636
1735
  }
1637
1736
  t && this.syncPill(), n && this.updateBlocked();
1638
- }), l.on("click", ({ x: e, y: t }) => {
1639
- this.stopped() || this.replayClick(e / 100, t / 100);
1737
+ }), l.on("click", ({ from: e, x: t, y: n }) => {
1738
+ this.stopped() || (this.layer?.pulse(e, { fromClick: !0 }), this.replayClick(t / 100, n / 100));
1640
1739
  }), l.on("wheel", ({ x: e, y: t, dx: n, dy: r }) => {
1641
1740
  this.stopped() || this.replayWheel(e / 100, t / 100, n, r);
1642
- }), l.on("refused", (e) => console.error(`[Liveroom] Refused: ${e}`)), this.pill = new X(o, {
1741
+ }), l.on("refused", (e) => console.error(`[Liveroom] Refused: ${e}`)), this.pill = new Ae(o, {
1643
1742
  onStop: () => this.stopHosts(),
1644
1743
  onResume: () => this.resumeHosts()
1645
1744
  }), this.cleanup.push(l.on("quality", (e) => this.pill?.setQuality(e)), () => this.pill?.destroy()), l.connect();
@@ -1696,15 +1795,7 @@ var be = J("position: fixed; inset: 0; pointer-events: none; z-index: 2147483646
1696
1795
  this.holdUntilCursor ? e || (this.wantStop = !1) : e ? (this.wantStop = !0, this.stopAcked = !0) : (this.stopAcked || this.stopClickedAt === null) && (this.wantStop = !1, this.stopAcked = !1, this.stopClickedAt = null);
1697
1796
  }
1698
1797
  people() {
1699
- let e = [];
1700
- for (let t of this.client?.participants.values() ?? []) t.type === "admin" && t.id !== this.client?.you && e.push({
1701
- id: t.id,
1702
- name: t.name,
1703
- color: t.color,
1704
- clicks: (t.flags & r.alt) !== 0,
1705
- pointed: t.cursorAt > 0
1706
- });
1707
- return e;
1798
+ return Se(this.client?.participants.values() ?? [], this.client?.you ?? null);
1708
1799
  }
1709
1800
  syncPill() {
1710
1801
  let e = this.stopClickedAt === null ? null : performance.now() - this.stopClickedAt;
@@ -1787,7 +1878,7 @@ var be = J("position: fixed; inset: 0; pointer-events: none; z-index: 2147483646
1787
1878
  replayWheel(e, t, n, r) {
1788
1879
  let i = this.elementAt(innerWidth * e / 100, innerHeight * t / 100);
1789
1880
  if (!(i instanceof HTMLElement || i instanceof SVGElement)) return;
1790
- let a = Math.abs(r) >= Math.abs(n), o = xe(i, a ? "vertical" : "horizontal");
1881
+ let a = Math.abs(r) >= Math.abs(n), o = Pe(i, a ? "vertical" : "horizontal");
1791
1882
  $(o) ? o.scrollByPoint(a ? 0 : n, a ? r : 0, 0) : o.scrollBy({
1792
1883
  top: a ? r : 0,
1793
1884
  left: a ? 0 : n,
@@ -1806,7 +1897,7 @@ function Q() {
1806
1897
  function $(e) {
1807
1898
  return e instanceof HTMLElement && e.tagName === "ION-CONTENT" && "scrollByPoint" in e;
1808
1899
  }
1809
- function xe(e, t) {
1900
+ function Pe(e, t) {
1810
1901
  for (let n = e; n && n !== document.body; n = n.parentElement) {
1811
1902
  if ($(n)) return n;
1812
1903
  let { overflowY: e, overflowX: r } = getComputedStyle(n);
package/dist/main.cjs CHANGED
@@ -1 +1 @@
1
- const e=require("./constants-DkKqHYud.cjs");var t,n,r;a(),i();function i(){window.addEventListener(`popstate`,a)}async function a(){let i=document.querySelector(`script[src*='/liveroom-client-element']`);i?.setAttribute(`version`,e.u);let{roomId:a,roomToken:s}=l(i);if(a&&s&&(a!=t||s!=n)){t=a,n=s,sessionStorage?.setItem(e.o,t),sessionStorage?.setItem(e.s,n),r&&=(r.remove(),void 0);let c=i?.getAttribute(`data-url`);await o(c||`wss://liveroom.app/room`,t,n)}}async function o(t,n,i){if(!n||!i)return!1;await Promise.resolve().then(()=>require("./liveroom-client-element.cjs")),console.log(`[Liveroom] Installed successfully (v${e.u})`),r=document.createElement(e.t),r.setAttribute(`url`,t),r.setAttribute(`version`,e.u),n&&r.setAttribute(`room_id`,n),n&&r.setAttribute(`room_token`,i);let a=s();a&&r.setAttribute(`user_name`,a);let o=c();return o&&r.setAttribute(`user_color`,o),document.body.appendChild(r),console.log(`[Liveroom] Injected successfully`),!0}function s(){let t=new URLSearchParams(window.location.search).get(e.a),n=sessionStorage?.getItem(e.l);return t||n||null}function c(){let t=new URLSearchParams(window.location.search).get(e.i),n=sessionStorage?.getItem(e.c);return t||n||null}function l(t){let n=new URLSearchParams(window.location.search),r=n.get(e.n),i=n.get(e.r),a=sessionStorage?.getItem(e.o),o=sessionStorage?.getItem(e.s),s=t?.getAttribute(`data-roomid`)||null,c=t?.getAttribute(`data-roomtoken`)||null;return{roomId:u(r||s||a),roomToken:i||c||o}}function u(e){let t=e?.split(`https://meet.google.com/`),n=t?.[1];return(n?n.split(`?`)[0]:t?.[0])||null}
1
+ const e=require("./constants-D2391gVh.cjs");var t,n,r;a(),i();function i(){window.addEventListener(`popstate`,a)}async function a(){let i=document.querySelector(`script[src*='/liveroom-client-element']`);i?.setAttribute(`version`,e.u);let{roomId:a,roomToken:s}=l(i);if(a&&s&&(a!=t||s!=n)){t=a,n=s,sessionStorage?.setItem(e.o,t),sessionStorage?.setItem(e.s,n),r&&=(r.remove(),void 0);let c=i?.getAttribute(`data-url`);await o(c||`wss://liveroom.app/room`,t,n)}}async function o(t,n,i){if(!n||!i)return!1;await Promise.resolve().then(()=>require("./liveroom-client-element.cjs")),console.log(`[Liveroom] Installed successfully (v${e.u})`),r=document.createElement(e.t),r.setAttribute(`url`,t),r.setAttribute(`version`,e.u),n&&r.setAttribute(`room_id`,n),n&&r.setAttribute(`room_token`,i);let a=s();a&&r.setAttribute(`user_name`,a);let o=c();return o&&r.setAttribute(`user_color`,o),document.body.appendChild(r),console.log(`[Liveroom] Injected successfully`),!0}function s(){let t=new URLSearchParams(window.location.search).get(e.a),n=sessionStorage?.getItem(e.l);return t||n||null}function c(){let t=new URLSearchParams(window.location.search).get(e.i),n=sessionStorage?.getItem(e.c);return t||n||null}function l(t){let n=new URLSearchParams(window.location.search),r=n.get(e.n),i=n.get(e.r),a=sessionStorage?.getItem(e.o),o=sessionStorage?.getItem(e.s),s=t?.getAttribute(`data-roomid`)||null,c=t?.getAttribute(`data-roomtoken`)||null;return{roomId:u(r||s||a),roomToken:i||c||o}}function u(e){let t=e?.split(`https://meet.google.com/`),n=t?.[1];return(n?n.split(`?`)[0]:t?.[0])||null}
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./constants-DF3rCCdk.js";
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./constants-BTUkeFrO.js";
2
2
  // src/main.ts
3
3
  var u, d, f;
4
4
  m(), p();
package/dist/main.min.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./constants-DF3rCCdk.js";var u,d,f;m(),p();function p(){window.addEventListener(`popstate`,m)}async function m(){let e=document.querySelector(`script[src*='/liveroom-client-element']`);e?.setAttribute(`version`,l);let{roomId:t,roomToken:n}=v(e);if(t&&n&&(t!=u||n!=d)){u=t,d=n,sessionStorage?.setItem(a,u),sessionStorage?.setItem(s,d),f&&=(f.remove(),void 0);let r=e?.getAttribute(`data-url`);await h(r||`wss://liveroom.app/room`,u,d)}}async function h(e,t,n){if(!t||!n)return!1;await import(`./liveroom-client-element.js`),console.log(`[Liveroom] Installed successfully (v${l})`),f=document.createElement(c),f.setAttribute(`url`,e),f.setAttribute(`version`,l),t&&f.setAttribute(`room_id`,t),t&&f.setAttribute(`room_token`,n);let r=g();r&&f.setAttribute(`user_name`,r);let i=_();return i&&f.setAttribute(`user_color`,i),document.body.appendChild(f),console.log(`[Liveroom] Injected successfully`),!0}function g(){let t=new URLSearchParams(window.location.search).get(e),n=sessionStorage?.getItem(r);return t||n||null}function _(){let e=new URLSearchParams(window.location.search).get(n),r=sessionStorage?.getItem(t);return e||r||null}function v(e){let t=new URLSearchParams(window.location.search),n=t.get(i),r=t.get(o),c=sessionStorage?.getItem(a),l=sessionStorage?.getItem(s),u=e?.getAttribute(`data-roomid`)||null,d=e?.getAttribute(`data-roomtoken`)||null;return{roomId:y(n||u||c),roomToken:r||d||l}}function y(e){let t=e?.split(`https://meet.google.com/`),n=t?.[1];return(n?n.split(`?`)[0]:t?.[0])||null}
1
+ import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./constants-BTUkeFrO.js";var u,d,f;m(),p();function p(){window.addEventListener(`popstate`,m)}async function m(){let e=document.querySelector(`script[src*='/liveroom-client-element']`);e?.setAttribute(`version`,l);let{roomId:t,roomToken:n}=v(e);if(t&&n&&(t!=u||n!=d)){u=t,d=n,sessionStorage?.setItem(a,u),sessionStorage?.setItem(s,d),f&&=(f.remove(),void 0);let r=e?.getAttribute(`data-url`);await h(r||`wss://liveroom.app/room`,u,d)}}async function h(e,t,n){if(!t||!n)return!1;await import(`./liveroom-client-element.js`),console.log(`[Liveroom] Installed successfully (v${l})`),f=document.createElement(c),f.setAttribute(`url`,e),f.setAttribute(`version`,l),t&&f.setAttribute(`room_id`,t),t&&f.setAttribute(`room_token`,n);let r=g();r&&f.setAttribute(`user_name`,r);let i=_();return i&&f.setAttribute(`user_color`,i),document.body.appendChild(f),console.log(`[Liveroom] Injected successfully`),!0}function g(){let t=new URLSearchParams(window.location.search).get(e),n=sessionStorage?.getItem(r);return t||n||null}function _(){let e=new URLSearchParams(window.location.search).get(n),r=sessionStorage?.getItem(t);return e||r||null}function v(e){let t=new URLSearchParams(window.location.search),n=t.get(i),r=t.get(o),c=sessionStorage?.getItem(a),l=sessionStorage?.getItem(s),u=e?.getAttribute(`data-roomid`)||null,d=e?.getAttribute(`data-roomtoken`)||null;return{roomId:y(n||u||c),roomToken:r||d||l}}function y(e){let t=e?.split(`https://meet.google.com/`),n=t?.[1];return(n?n.split(`?`)[0]:t?.[0])||null}
2
2
  //# sourceMappingURL=main.min.js.map
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAS,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,EAAG,KAAK,EAAG,KAAK,MAAS,0BAE1F,IAAI,EAAG,EAAG,EACV,EAAE,EAAG,EAAE,EACP,SAAS,GAAI,CACZ,OAAO,iBAAiB,WAAY,CAAC,CACtC,CACA,eAAe,GAAI,CAClB,IAAI,EAAI,SAAS,cAAc,yCAAyC,EACxE,GAAG,aAAa,UAAW,CAAC,EAC5B,GAAI,CAAE,OAAQ,EAAG,UAAW,GAAM,EAAE,CAAC,EACrC,GAAI,GAAK,IAAM,GAAK,GAAK,GAAK,GAAI,CACjC,EAAI,EAAG,EAAI,EAAG,gBAAgB,QAAQ,EAAG,CAAC,EAAG,gBAAgB,QAAQ,EAAG,CAAC,EAAG,KAAO,EAAE,OAAO,EAAG,IAAK,IACpG,IAAI,EAAI,GAAG,aAAa,UAAU,EAClC,MAAM,EAAE,GAAK,0BAA2B,EAAG,CAAC,CAC7C,CACD,CACA,eAAe,EAAE,EAAG,EAAG,EAAG,CACzB,GAAI,CAAC,GAAK,CAAC,EAAG,MAAO,CAAC,EACtB,MAAM,OAAO,gCAAiC,QAAQ,IAAI,uCAAuC,EAAE,EAAE,EAAG,EAAI,SAAS,cAAc,CAAC,EAAG,EAAE,aAAa,MAAO,CAAC,EAAG,EAAE,aAAa,UAAW,CAAC,EAAG,GAAK,EAAE,aAAa,UAAW,CAAC,EAAG,GAAK,EAAE,aAAa,aAAc,CAAC,EACrQ,IAAI,EAAI,EAAE,EACV,GAAK,EAAE,aAAa,YAAa,CAAC,EAClC,IAAI,EAAI,EAAE,EACV,OAAO,GAAK,EAAE,aAAa,aAAc,CAAC,EAAG,SAAS,KAAK,YAAY,CAAC,EAAG,QAAQ,IAAI,kCAAkC,EAAG,CAAC,CAC9H,CACA,SAAS,GAAI,CACZ,IAAI,EAAI,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAAI,CAAC,EAAG,EAAI,gBAAgB,QAAQ,CAAC,EACzF,OAAO,GAAK,GAAK,IAClB,CACA,SAAS,GAAI,CACZ,IAAI,EAAI,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAAI,CAAC,EAAG,EAAI,gBAAgB,QAAQ,CAAC,EACzF,OAAO,GAAK,GAAK,IAClB,CACA,SAAS,EAAE,EAAG,CACb,IAAI,EAAI,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAG,EAAI,EAAE,IAAI,CAAC,EAAG,EAAI,EAAE,IAAI,CAAC,EAAG,EAAI,gBAAgB,QAAQ,CAAC,EAAG,EAAI,gBAAgB,QAAQ,CAAC,EAAG,EAAI,GAAG,aAAa,aAAa,GAAK,KAAM,EAAI,GAAG,aAAa,gBAAgB,GAAK,KACtO,MAAO,CACN,OAAQ,EAAE,GAAK,GAAK,CAAC,EACrB,UAAW,GAAK,GAAK,CACtB,CACD,CACA,SAAS,EAAE,EAAG,CACb,IAAI,EAAI,GAAG,MAAM,0BAA0B,EAAG,EAAI,IAAI,GACtD,OAAQ,EAAI,EAAE,MAAM,GAAG,CAAC,CAAC,GAAK,IAAI,KAAO,IAC1C","names":[],"sources":["main.js"],"version":3,"sourcesContent":["import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from \"./constants-DF3rCCdk.js\";\n// src/main.ts\nvar u, d, f;\nm(), p();\nfunction p() {\n\twindow.addEventListener(\"popstate\", m);\n}\nasync function m() {\n\tlet e = document.querySelector(\"script[src*='/liveroom-client-element']\");\n\te?.setAttribute(\"version\", l);\n\tlet { roomId: t, roomToken: n } = v(e);\n\tif (t && n && (t != u || n != d)) {\n\t\tu = t, d = n, sessionStorage?.setItem(a, u), sessionStorage?.setItem(s, d), f &&= (f.remove(), void 0);\n\t\tlet r = e?.getAttribute(\"data-url\");\n\t\tawait h(r || \"wss://liveroom.app/room\", u, d);\n\t}\n}\nasync function h(e, t, n) {\n\tif (!t || !n) return !1;\n\tawait import(\"./liveroom-client-element.js\"), console.log(`[Liveroom] Installed successfully (v${l})`), f = document.createElement(c), f.setAttribute(\"url\", e), f.setAttribute(\"version\", l), t && f.setAttribute(\"room_id\", t), t && f.setAttribute(\"room_token\", n);\n\tlet r = g();\n\tr && f.setAttribute(\"user_name\", r);\n\tlet i = _();\n\treturn i && f.setAttribute(\"user_color\", i), document.body.appendChild(f), console.log(\"[Liveroom] Injected successfully\"), !0;\n}\nfunction g() {\n\tlet t = new URLSearchParams(window.location.search).get(e), n = sessionStorage?.getItem(r);\n\treturn t || n || null;\n}\nfunction _() {\n\tlet e = new URLSearchParams(window.location.search).get(n), r = sessionStorage?.getItem(t);\n\treturn e || r || null;\n}\nfunction v(e) {\n\tlet t = new URLSearchParams(window.location.search), n = t.get(i), r = t.get(o), c = sessionStorage?.getItem(a), l = sessionStorage?.getItem(s), u = e?.getAttribute(\"data-roomid\") || null, d = e?.getAttribute(\"data-roomtoken\") || null;\n\treturn {\n\t\troomId: y(n || u || c),\n\t\troomToken: r || d || l\n\t};\n}\nfunction y(e) {\n\tlet t = e?.split(\"https://meet.google.com/\"), n = t?.[1];\n\treturn (n ? n.split(\"?\")[0] : t?.[0]) || null;\n}\n"],"file":"main.min.js"}
1
+ {"mappings":"AAAA,OAAS,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,EAAG,KAAK,EAAG,KAAK,MAAS,0BAE1F,IAAI,EAAG,EAAG,EACV,EAAE,EAAG,EAAE,EACP,SAAS,GAAI,CACZ,OAAO,iBAAiB,WAAY,CAAC,CACtC,CACA,eAAe,GAAI,CAClB,IAAI,EAAI,SAAS,cAAc,yCAAyC,EACxE,GAAG,aAAa,UAAW,CAAC,EAC5B,GAAI,CAAE,OAAQ,EAAG,UAAW,GAAM,EAAE,CAAC,EACrC,GAAI,GAAK,IAAM,GAAK,GAAK,GAAK,GAAI,CACjC,EAAI,EAAG,EAAI,EAAG,gBAAgB,QAAQ,EAAG,CAAC,EAAG,gBAAgB,QAAQ,EAAG,CAAC,EAAG,KAAO,EAAE,OAAO,EAAG,IAAK,IACpG,IAAI,EAAI,GAAG,aAAa,UAAU,EAClC,MAAM,EAAE,GAAK,0BAA2B,EAAG,CAAC,CAC7C,CACD,CACA,eAAe,EAAE,EAAG,EAAG,EAAG,CACzB,GAAI,CAAC,GAAK,CAAC,EAAG,MAAO,CAAC,EACtB,MAAM,OAAO,gCAAiC,QAAQ,IAAI,uCAAuC,EAAE,EAAE,EAAG,EAAI,SAAS,cAAc,CAAC,EAAG,EAAE,aAAa,MAAO,CAAC,EAAG,EAAE,aAAa,UAAW,CAAC,EAAG,GAAK,EAAE,aAAa,UAAW,CAAC,EAAG,GAAK,EAAE,aAAa,aAAc,CAAC,EACrQ,IAAI,EAAI,EAAE,EACV,GAAK,EAAE,aAAa,YAAa,CAAC,EAClC,IAAI,EAAI,EAAE,EACV,OAAO,GAAK,EAAE,aAAa,aAAc,CAAC,EAAG,SAAS,KAAK,YAAY,CAAC,EAAG,QAAQ,IAAI,kCAAkC,EAAG,CAAC,CAC9H,CACA,SAAS,GAAI,CACZ,IAAI,EAAI,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAAI,CAAC,EAAG,EAAI,gBAAgB,QAAQ,CAAC,EACzF,OAAO,GAAK,GAAK,IAClB,CACA,SAAS,GAAI,CACZ,IAAI,EAAI,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAAI,CAAC,EAAG,EAAI,gBAAgB,QAAQ,CAAC,EACzF,OAAO,GAAK,GAAK,IAClB,CACA,SAAS,EAAE,EAAG,CACb,IAAI,EAAI,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAG,EAAI,EAAE,IAAI,CAAC,EAAG,EAAI,EAAE,IAAI,CAAC,EAAG,EAAI,gBAAgB,QAAQ,CAAC,EAAG,EAAI,gBAAgB,QAAQ,CAAC,EAAG,EAAI,GAAG,aAAa,aAAa,GAAK,KAAM,EAAI,GAAG,aAAa,gBAAgB,GAAK,KACtO,MAAO,CACN,OAAQ,EAAE,GAAK,GAAK,CAAC,EACrB,UAAW,GAAK,GAAK,CACtB,CACD,CACA,SAAS,EAAE,EAAG,CACb,IAAI,EAAI,GAAG,MAAM,0BAA0B,EAAG,EAAI,IAAI,GACtD,OAAQ,EAAI,EAAE,MAAM,GAAG,CAAC,CAAC,GAAK,IAAI,KAAO,IAC1C","names":[],"sources":["main.js"],"version":3,"sourcesContent":["import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from \"./constants-BTUkeFrO.js\";\n// src/main.ts\nvar u, d, f;\nm(), p();\nfunction p() {\n\twindow.addEventListener(\"popstate\", m);\n}\nasync function m() {\n\tlet e = document.querySelector(\"script[src*='/liveroom-client-element']\");\n\te?.setAttribute(\"version\", l);\n\tlet { roomId: t, roomToken: n } = v(e);\n\tif (t && n && (t != u || n != d)) {\n\t\tu = t, d = n, sessionStorage?.setItem(a, u), sessionStorage?.setItem(s, d), f &&= (f.remove(), void 0);\n\t\tlet r = e?.getAttribute(\"data-url\");\n\t\tawait h(r || \"wss://liveroom.app/room\", u, d);\n\t}\n}\nasync function h(e, t, n) {\n\tif (!t || !n) return !1;\n\tawait import(\"./liveroom-client-element.js\"), console.log(`[Liveroom] Installed successfully (v${l})`), f = document.createElement(c), f.setAttribute(\"url\", e), f.setAttribute(\"version\", l), t && f.setAttribute(\"room_id\", t), t && f.setAttribute(\"room_token\", n);\n\tlet r = g();\n\tr && f.setAttribute(\"user_name\", r);\n\tlet i = _();\n\treturn i && f.setAttribute(\"user_color\", i), document.body.appendChild(f), console.log(\"[Liveroom] Injected successfully\"), !0;\n}\nfunction g() {\n\tlet t = new URLSearchParams(window.location.search).get(e), n = sessionStorage?.getItem(r);\n\treturn t || n || null;\n}\nfunction _() {\n\tlet e = new URLSearchParams(window.location.search).get(n), r = sessionStorage?.getItem(t);\n\treturn e || r || null;\n}\nfunction v(e) {\n\tlet t = new URLSearchParams(window.location.search), n = t.get(i), r = t.get(o), c = sessionStorage?.getItem(a), l = sessionStorage?.getItem(s), u = e?.getAttribute(\"data-roomid\") || null, d = e?.getAttribute(\"data-roomtoken\") || null;\n\treturn {\n\t\troomId: y(n || u || c),\n\t\troomToken: r || d || l\n\t};\n}\nfunction y(e) {\n\tlet t = e?.split(\"https://meet.google.com/\"), n = t?.[1];\n\treturn (n ? n.split(\"?\")[0] : t?.[0]) || null;\n}\n"],"file":"main.min.js"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "liveroom-client-element",
3
3
  "private": false,
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/liveroom-app/liveroom.git",