@gamention/pulse-elements 0.1.2 → 0.1.4

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.
@@ -2,7 +2,7 @@
2
2
  * @license
3
3
  * Copyright 2021 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
- */let rt=class extends Event{constructor(e,t,i,s){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t,this.callback=i,this.subscribe=s??!1}};/**
5
+ */let dt=class extends Event{constructor(e,t,i,s){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t,this.callback=i,this.subscribe=s??!1}};/**
6
6
  * @license
7
7
  * Copyright 2021 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
@@ -10,53 +10,53 @@
10
10
  * @license
11
11
  * Copyright 2021 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */let Re=class{constructor(e,t,i,s){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(r,o)=>{this.unsubscribe&&(this.unsubscribe!==o&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=r,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(r,o)),this.unsubscribe=o},this.host=e,t.context!==void 0){const r=t;this.context=r.context,this.callback=r.callback,this.subscribe=r.subscribe??!1}else this.context=t,this.callback=i,this.subscribe=s??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new rt(this.context,this.host,this.t,this.subscribe))}};/**
13
+ */let Ue=class{constructor(e,t,i,s){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(r,o)=>{this.unsubscribe&&(this.unsubscribe!==o&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=r,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(r,o)),this.unsubscribe=o},this.host=e,t.context!==void 0){const r=t;this.context=r.context,this.callback=r.callback,this.subscribe=r.subscribe??!1}else this.context=t,this.callback=i,this.subscribe=s??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new dt(this.context,this.host,this.t,this.subscribe))}};/**
14
14
  * @license
15
15
  * Copyright 2021 Google LLC
16
16
  * SPDX-License-Identifier: BSD-3-Clause
17
- */let vt=class{get value(){return this.o}set value(e){this.setValue(e)}setValue(e,t=!1){const i=t||!Object.is(e,this.o);this.o=e,i&&this.updateObservers()}constructor(e){this.subscriptions=new Map,this.updateObservers=()=>{for(const[t,{disposer:i}]of this.subscriptions)t(this.o,i)},e!==void 0&&(this.value=e)}addCallback(e,t,i){if(!i)return void e(this.value);this.subscriptions.has(e)||this.subscriptions.set(e,{disposer:()=>{this.subscriptions.delete(e)},consumerHost:t});const{disposer:s}=this.subscriptions.get(e);e(this.value,s)}clearCallbacks(){this.subscriptions.clear()}};/**
17
+ */let $t=class{get value(){return this.o}set value(e){this.setValue(e)}setValue(e,t=!1){const i=t||!Object.is(e,this.o);this.o=e,i&&this.updateObservers()}constructor(e){this.subscriptions=new Map,this.updateObservers=()=>{for(const[t,{disposer:i}]of this.subscriptions)t(this.o,i)},e!==void 0&&(this.value=e)}addCallback(e,t,i){if(!i)return void e(this.value);this.subscriptions.has(e)||this.subscriptions.set(e,{disposer:()=>{this.subscriptions.delete(e)},consumerHost:t});const{disposer:s}=this.subscriptions.get(e);e(this.value,s)}clearCallbacks(){this.subscriptions.clear()}};/**
18
18
  * @license
19
19
  * Copyright 2021 Google LLC
20
20
  * SPDX-License-Identifier: BSD-3-Clause
21
- */let xt=class extends Event{constructor(e,t){super("context-provider",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t}},ze=class extends vt{constructor(e,t,i){var s,r;super(t.context!==void 0?t.initialValue:i),this.onContextRequest=o=>{if(o.context!==this.context)return;const l=o.contextTarget??o.composedPath()[0];l!==this.host&&(o.stopPropagation(),this.addCallback(o.callback,l,o.subscribe))},this.onProviderRequest=o=>{if(o.context!==this.context||(o.contextTarget??o.composedPath()[0])===this.host)return;const l=new Set;for(const[a,{consumerHost:c}]of this.subscriptions)l.has(a)||(l.add(a),c.dispatchEvent(new rt(this.context,c,a,!0)));o.stopPropagation()},this.host=e,t.context!==void 0?this.context=t.context:this.context=t,this.attachListeners(),(r=(s=this.host).addController)==null||r.call(s,this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new xt(this.context,this.host))}};/**
21
+ */let kt=class extends Event{constructor(e,t){super("context-provider",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t}},De=class extends $t{constructor(e,t,i){var s,r;super(t.context!==void 0?t.initialValue:i),this.onContextRequest=o=>{if(o.context!==this.context)return;const l=o.contextTarget??o.composedPath()[0];l!==this.host&&(o.stopPropagation(),this.addCallback(o.callback,l,o.subscribe))},this.onProviderRequest=o=>{if(o.context!==this.context||(o.contextTarget??o.composedPath()[0])===this.host)return;const l=new Set;for(const[a,{consumerHost:c}]of this.subscriptions)l.has(a)||(l.add(a),c.dispatchEvent(new dt(this.context,c,a,!0)));o.stopPropagation()},this.host=e,t.context!==void 0?this.context=t.context:this.context=t,this.attachListeners(),(r=(s=this.host).addController)==null||r.call(s,this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new kt(this.context,this.host))}};/**
22
22
  * @license
23
23
  * Copyright 2017 Google LLC
24
24
  * SPDX-License-Identifier: BSD-3-Clause
25
- */function yt({context:n}){return(e,t)=>{const i=new WeakMap;if(typeof t=="object")return{get(){return e.get.call(this)},set(s){return i.get(this).setValue(s),e.set.call(this,s)},init(s){return i.set(this,new ze(this,{context:n,initialValue:s})),s}};{e.constructor.addInitializer((o=>{i.set(o,new ze(o,{context:n}))}));const s=Object.getOwnPropertyDescriptor(e,t);let r;if(s===void 0){const o=new WeakMap;r={get(){return o.get(this)},set(l){i.get(this).setValue(l),o.set(this,l)},configurable:!0,enumerable:!0}}else{const o=s.set;r={...s,set(l){i.get(this).setValue(l),o==null||o.call(this,l)}}}return void Object.defineProperty(e,t,r)}}}/**
25
+ */function Ct({context:n}){return(e,t)=>{const i=new WeakMap;if(typeof t=="object")return{get(){return e.get.call(this)},set(s){return i.get(this).setValue(s),e.set.call(this,s)},init(s){return i.set(this,new De(this,{context:n,initialValue:s})),s}};{e.constructor.addInitializer((o=>{i.set(o,new De(o,{context:n}))}));const s=Object.getOwnPropertyDescriptor(e,t);let r;if(s===void 0){const o=new WeakMap;r={get(){return o.get(this)},set(l){i.get(this).setValue(l),o.set(this,l)},configurable:!0,enumerable:!0}}else{const o=s.set;r={...s,set(l){i.get(this).setValue(l),o==null||o.call(this,l)}}}return void Object.defineProperty(e,t,r)}}}/**
26
26
  * @license
27
27
  * Copyright 2022 Google LLC
28
28
  * SPDX-License-Identifier: BSD-3-Clause
29
- */function ne({context:n,subscribe:e}){return(t,i)=>{typeof i=="object"?i.addInitializer((function(){new Re(this,{context:n,callback:s=>{t.set.call(this,s)},subscribe:e})})):t.constructor.addInitializer((s=>{new Re(s,{context:n,callback:r=>{s[i]=r},subscribe:e})}))}}var wt=Object.defineProperty,$t=(n,e,t)=>e in n?wt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,x=(n,e,t)=>$t(n,typeof e!="symbol"?e+"":e,t);const kt="ws://localhost:4567";let _e=class{constructor(){x(this,"handlers",new Map)}on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set);const i=this.handlers.get(e);return i.add(t),()=>i.delete(t)}off(e,t){var i;(i=this.handlers.get(e))==null||i.delete(t)}emit(e,t){var i;(i=this.handlers.get(e))==null||i.forEach(s=>s(t))}removeAll(){this.handlers.clear()}},Ct=class extends _e{constructor(e){super(),x(this,"ws",null),x(this,"endpoint"),x(this,"reconnectAttempt",0),x(this,"reconnectTimer",null),x(this,"_state","disconnected"),this.endpoint=e??kt}get state(){return this._state}connect(){this.ws||(this._state="connecting",this.emit("state",this._state),this.ws=new WebSocket(this.endpoint),this.ws.addEventListener("open",()=>{this._state="connected",this.reconnectAttempt=0,this.emit("state",this._state)}),this.ws.addEventListener("message",e=>{const t=JSON.parse(e.data);this.emit("message",t)}),this.ws.addEventListener("close",()=>{this.ws=null,this._state="disconnected",this.emit("state",this._state),this.scheduleReconnect()}),this.ws.addEventListener("error",()=>{var e;(e=this.ws)==null||e.close()}))}disconnect(){var e;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectAttempt=0,(e=this.ws)==null||e.close(),this.ws=null,this._state="disconnected",this.emit("state",this._state)}send(e){var t;((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}scheduleReconnect(){const e=Math.min(1e3*2**this.reconnectAttempt,3e4);this.reconnectAttempt++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}},Pt=class extends _e{constructor(){super(...arguments),x(this,"_user",null),x(this,"_users",new Map),x(this,"_presence",new Map),x(this,"_threads",new Map),x(this,"_reactions",new Map),x(this,"_notifications",[]),x(this,"_activityLogs",[]),x(this,"_typing",new Map),x(this,"_viewports",new Map),x(this,"_selections",new Map)}get user(){return this._user}get presence(){return[...this._presence.values()]}get threads(){return[...this._threads.values()]}get notifications(){return this._notifications}get unreadCount(){return this._notifications.filter(e=>!e.read).length}get activityLogs(){return this._activityLogs}getUser(e){return this._users.get(e)}getReactions(e){return this._reactions.get(e)??[]}getTypingUsers(e){const t=this._typing.get(e);if(!t)return[];const i=Date.now(),s=[];for(const[r,o]of t)i-o<3e3&&s.push(r);return s}get viewports(){return this._viewports}getViewport(e){return this._viewports.get(e)}get selections(){return this._selections}handleMessage(e){switch(e.type){case"auth:ok":this._user=e.user,this._users.clear();for(const t of e.users)this._users.set(t.id,t);this._presence.clear();for(const t of e.presence)this._presence.set(t.user.id,t),this._users.set(t.user.id,t.user);this._users.set(e.user.id,e.user),this._threads.clear();for(const t of e.threads)this._threads.set(t.id,t);this._notifications=e.notifications,this._reactions.clear();for(const t of e.reactions){const i=this._reactions.get(t.targetId)??[];i.push(t),this._reactions.set(t.targetId,i)}this._activityLogs=[...e.activityLogs],this.emit("auth",e.user),this.emit("presence",this.presence),this.emit("threads",this.threads),this.emit("notifications",this._notifications),this.emit("reactions",null),this.emit("activity-logs",this._activityLogs);break;case"presence:join":this._presence.set(e.user.user.id,e.user),this._users.set(e.user.user.id,e.user.user),this.emit("presence",this.presence);break;case"presence:leave":this._presence.delete(e.userId),this._viewports.delete(e.userId),this._selections.delete(e.userId);for(const t of this._typing.values())t.delete(e.userId);this.emit("presence",this.presence);break;case"presence:update":{const t=this._presence.get(e.userId);t&&(t.status=e.status,this.emit("presence",this.presence));break}case"cursor:move":this.emit("cursor",{userId:e.userId,position:e.position});break;case"click:perform":this.emit("click",{userId:e.userId,position:e.position});break;case"thread:created":this._threads.set(e.thread.id,e.thread),this.emit("threads",this.threads);break;case"comment:created":{const t=this._threads.get(e.threadId);t&&(t.comments.push(e.comment),t.updatedAt=e.comment.createdAt,this.emit("threads",this.threads));break}case"comment:edited":{const t=this._threads.get(e.threadId);if(t){const i=t.comments.findIndex(s=>s.id===e.comment.id);i!==-1&&(t.comments[i]=e.comment),this.emit("threads",this.threads)}break}case"comment:deleted":{const t=this._threads.get(e.threadId);t&&(t.comments=t.comments.filter(i=>i.id!==e.commentId),t.comments.length===0&&this._threads.delete(e.threadId),this.emit("threads",this.threads));break}case"thread:resolved":{const t=this._threads.get(e.threadId);t&&(t.resolved=e.resolved,this.emit("threads",this.threads));break}case"thread:deleted":this._threads.delete(e.threadId),this.emit("threads",this.threads);break;case"reaction:added":{const t=this._reactions.get(e.reaction.targetId)??[];t.push(e.reaction),this._reactions.set(e.reaction.targetId,t),this.emit("reactions",{targetId:e.reaction.targetId,reactions:t});break}case"reaction:removed":{const t=this._reactions.get(e.targetId);if(t){const i=t.filter(s=>s.id!==e.reactionId);this._reactions.set(e.targetId,i),this.emit("reactions",{targetId:e.targetId,reactions:i})}break}case"notification":this._notifications.unshift(e.notification),this.emit("notifications",this._notifications);break;case"typing:indicator":{this._typing.has(e.threadId)||this._typing.set(e.threadId,new Map),this._typing.get(e.threadId).set(e.userId,Date.now()),this.emit("typing",{threadId:e.threadId,userId:e.userId});break}case"viewport:update":{this._viewports.set(e.userId,{scrollX:e.scrollX,scrollY:e.scrollY,viewportWidth:e.viewportWidth,viewportHeight:e.viewportHeight,pageWidth:e.pageWidth,pageHeight:e.pageHeight}),this.emit("viewport",{userId:e.userId});break}case"selection:update":this._selections.set(e.userId,e.selection),this.emit("selection",{userId:e.userId,selection:e.selection});break;case"emoji:drop":this.emit("emoji-drop",{userId:e.userId,emoji:e.emoji,position:e.position});break;case"draw:stroke":this.emit("draw-stroke",{userId:e.userId,points:e.points,color:e.color,width:e.width});break;case"draw:clear":this.emit("draw-clear",{userId:e.userId});break;case"activity:logged":this._activityLogs.unshift(e.activityLog),this._activityLogs.length>100&&(this._activityLogs=this._activityLogs.slice(0,100)),this.emit("activity-logs",this._activityLogs);break;case"error":this.emit("error",e);break}}reset(){this._user=null,this._users.clear(),this._presence.clear(),this._threads.clear(),this._reactions.clear(),this._notifications=[],this._activityLogs=[],this._typing.clear(),this._viewports.clear(),this._selections.clear()}},at=class extends _e{constructor(e){var t;super(),x(this,"state"),x(this,"connection"),x(this,"config"),x(this,"heartbeatTimer",null),x(this,"lastCursorSend",0),x(this,"pendingCursor",null),x(this,"cursorTimer",null),this.config=e,this.state=new Pt;const i=((t=e.endpoint)==null?void 0:t.replace(/^http/,"ws"))??void 0;this.connection=new Ct(i),this.connection.on("message",s=>{this.state.handleMessage(s),this.emit(s.type,s)}),this.connection.on("state",s=>{this.emit("connection",s),s==="connected"?(this.authenticate(),this.startHeartbeat()):s==="disconnected"&&this.stopHeartbeat()})}get connectionState(){return this.connection.state}connect(){this.connection.connect()}disconnect(){this.stopHeartbeat(),this.connection.disconnect(),this.state.reset()}authenticate(){this.send({type:"auth",apiKey:this.config.apiKey,token:this.config.token,room:this.config.room})}send(e){this.connection.send(e)}moveCursor(e){const t=Date.now();this.pendingCursor=e,t-this.lastCursorSend>=50?this.flushCursor():this.cursorTimer||(this.cursorTimer=setTimeout(()=>{this.cursorTimer=null,this.flushCursor()},50))}flushCursor(){this.pendingCursor&&(this.send({type:"cursor:move",position:this.pendingCursor}),this.lastCursorSend=Date.now(),this.pendingCursor=null)}updatePresence(e){this.send({type:"presence:update",status:e})}startHeartbeat(){this.heartbeatTimer=setInterval(()=>{this.send({type:"presence:update",status:"online"})},3e4)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}createThread(e,t={}){const i=crypto.randomUUID();return this.send({type:"thread:create",id:i,body:e,mentions:t.mentions??[],position:t.position??null}),i}reply(e,t,i=[]){const s=crypto.randomUUID();return this.send({type:"comment:create",threadId:e,id:s,body:t,mentions:i}),s}editComment(e,t,i=[]){this.send({type:"comment:edit",commentId:e,body:t,mentions:i})}deleteComment(e){this.send({type:"comment:delete",commentId:e})}resolveThread(e,t=!0){this.send({type:"thread:resolve",threadId:e,resolved:t})}addReaction(e,t,i){this.send({type:"reaction:add",targetId:e,targetType:t,emoji:i})}removeReaction(e){this.send({type:"reaction:remove",reactionId:e})}markRead(e){this.send({type:"notification:read",notificationId:e})}markAllRead(){this.send({type:"notification:read-all"})}performClick(e){this.send({type:"click:perform",position:e})}sendTyping(e){this.send({type:"typing:start",threadId:e})}updateViewport(e){this.send({type:"viewport:update",...e})}updateSelection(e){this.send({type:"selection:update",selection:e})}dropEmoji(e,t){this.send({type:"emoji:drop",emoji:e,position:t})}drawStroke(e,t,i){this.send({type:"draw:stroke",points:e,color:t,width:i})}clearDrawing(){this.send({type:"draw:clear"})}async uploadFile(e){const t=this.config.endpoint??window.location.origin,i=new FormData;i.append("file",e);const s=await fetch(`${t}/api/v1/upload`,{method:"POST",headers:{Authorization:`Bearer ${this.config.apiKey}`},body:i});if(!s.ok){const r=await s.json().catch(()=>({error:"Upload failed"}));throw new Error(r.error??"Upload failed")}return s.json()}setAppearOffline(e){e?(this.stopHeartbeat(),this.send({type:"presence:update",status:"idle"})):(this.startHeartbeat(),this.send({type:"presence:update",status:"online"}))}};/**
29
+ */function ne({context:n,subscribe:e}){return(t,i)=>{typeof i=="object"?i.addInitializer((function(){new Ue(this,{context:n,callback:s=>{t.set.call(this,s)},subscribe:e})})):t.constructor.addInitializer((s=>{new Ue(s,{context:n,callback:r=>{s[i]=r},subscribe:e})}))}}var Et=Object.defineProperty,Pt=(n,e,t)=>e in n?Et(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,w=(n,e,t)=>Pt(n,typeof e!="symbol"?e+"":e,t);const _t="ws://localhost:4567";let Te=class{constructor(){w(this,"handlers",new Map)}on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set);const i=this.handlers.get(e);return i.add(t),()=>i.delete(t)}off(e,t){var i;(i=this.handlers.get(e))==null||i.delete(t)}emit(e,t){var i;(i=this.handlers.get(e))==null||i.forEach(s=>s(t))}removeAll(){this.handlers.clear()}},Tt=class extends Te{constructor(e){super(),w(this,"ws",null),w(this,"endpoint"),w(this,"reconnectAttempt",0),w(this,"reconnectTimer",null),w(this,"_state","disconnected"),this.endpoint=e??_t}get state(){return this._state}connect(){this.ws||(this._state="connecting",this.emit("state",this._state),this.ws=new WebSocket(this.endpoint),this.ws.addEventListener("open",()=>{this._state="connected",this.reconnectAttempt=0,this.emit("state",this._state)}),this.ws.addEventListener("message",e=>{const t=JSON.parse(e.data);this.emit("message",t)}),this.ws.addEventListener("close",()=>{this.ws=null,this._state="disconnected",this.emit("state",this._state),this.scheduleReconnect()}),this.ws.addEventListener("error",()=>{var e;(e=this.ws)==null||e.close()}))}disconnect(){var e;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectAttempt=0,(e=this.ws)==null||e.close(),this.ws=null,this._state="disconnected",this.emit("state",this._state)}send(e){var t;((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}scheduleReconnect(){const e=Math.min(1e3*2**this.reconnectAttempt,3e4);this.reconnectAttempt++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}},St=class extends Te{constructor(){super(...arguments),w(this,"_user",null),w(this,"_users",new Map),w(this,"_presence",new Map),w(this,"_threads",new Map),w(this,"_reactions",new Map),w(this,"_notifications",[]),w(this,"_activityLogs",[]),w(this,"_typing",new Map),w(this,"_viewports",new Map),w(this,"_selections",new Map)}get user(){return this._user}get presence(){return[...this._presence.values()]}get threads(){return[...this._threads.values()]}get notifications(){return this._notifications}get unreadCount(){return this._notifications.filter(e=>!e.read).length}get activityLogs(){return this._activityLogs}getUser(e){return this._users.get(e)}getReactions(e){return this._reactions.get(e)??[]}getTypingUsers(e){const t=this._typing.get(e);if(!t)return[];const i=Date.now(),s=[];for(const[r,o]of t)i-o<3e3&&s.push(r);return s}get viewports(){return this._viewports}getViewport(e){return this._viewports.get(e)}get selections(){return this._selections}handleMessage(e){switch(e.type){case"auth:ok":this._user=e.user,this._users.clear();for(const t of e.users)this._users.set(t.id,t);this._presence.clear();for(const t of e.presence)this._presence.set(t.user.id,t),this._users.set(t.user.id,t.user);this._users.set(e.user.id,e.user),this._threads.clear();for(const t of e.threads)this._threads.set(t.id,t);this._notifications=e.notifications,this._reactions.clear();for(const t of e.reactions){const i=this._reactions.get(t.targetId)??[];i.push(t),this._reactions.set(t.targetId,i)}this._activityLogs=[...e.activityLogs],this.emit("auth",e.user),this.emit("presence",this.presence),this.emit("threads",this.threads),this.emit("notifications",this._notifications),this.emit("reactions",null),this.emit("activity-logs",this._activityLogs);break;case"presence:join":this._presence.set(e.user.user.id,e.user),this._users.set(e.user.user.id,e.user.user),this.emit("presence",this.presence);break;case"presence:leave":this._presence.delete(e.userId),this._viewports.delete(e.userId),this._selections.delete(e.userId);for(const t of this._typing.values())t.delete(e.userId);this.emit("presence",this.presence);break;case"presence:update":{const t=this._presence.get(e.userId);t&&(t.status=e.status,this.emit("presence",this.presence));break}case"cursor:move":this.emit("cursor",{userId:e.userId,position:e.position});break;case"click:perform":this.emit("click",{userId:e.userId,position:e.position});break;case"thread:created":this._threads.set(e.thread.id,e.thread),this.emit("threads",this.threads);break;case"comment:created":{const t=this._threads.get(e.threadId);t&&(t.comments.push(e.comment),t.updatedAt=e.comment.createdAt,this.emit("threads",this.threads));break}case"comment:edited":{const t=this._threads.get(e.threadId);if(t){const i=t.comments.findIndex(s=>s.id===e.comment.id);i!==-1&&(t.comments[i]=e.comment),this.emit("threads",this.threads)}break}case"comment:deleted":{const t=this._threads.get(e.threadId);t&&(t.comments=t.comments.filter(i=>i.id!==e.commentId),t.comments.length===0&&this._threads.delete(e.threadId),this.emit("threads",this.threads));break}case"thread:resolved":{const t=this._threads.get(e.threadId);t&&(t.resolved=e.resolved,this.emit("threads",this.threads));break}case"thread:deleted":this._threads.delete(e.threadId),this.emit("threads",this.threads);break;case"reaction:added":{const t=this._reactions.get(e.reaction.targetId)??[];t.push(e.reaction),this._reactions.set(e.reaction.targetId,t),this.emit("reactions",{targetId:e.reaction.targetId,reactions:t});break}case"reaction:removed":{const t=this._reactions.get(e.targetId);if(t){const i=t.filter(s=>s.id!==e.reactionId);this._reactions.set(e.targetId,i),this.emit("reactions",{targetId:e.targetId,reactions:i})}break}case"notification":this._notifications.unshift(e.notification),this.emit("notifications",this._notifications);break;case"typing:indicator":{this._typing.has(e.threadId)||this._typing.set(e.threadId,new Map),this._typing.get(e.threadId).set(e.userId,Date.now()),this.emit("typing",{threadId:e.threadId,userId:e.userId});break}case"viewport:update":{this._viewports.set(e.userId,{scrollX:e.scrollX,scrollY:e.scrollY,viewportWidth:e.viewportWidth,viewportHeight:e.viewportHeight,pageWidth:e.pageWidth,pageHeight:e.pageHeight}),this.emit("viewport",{userId:e.userId});break}case"selection:update":this._selections.set(e.userId,e.selection),this.emit("selection",{userId:e.userId,selection:e.selection});break;case"emoji:drop":this.emit("emoji-drop",{userId:e.userId,emoji:e.emoji,position:e.position});break;case"draw:stroke":this.emit("draw-stroke",{userId:e.userId,points:e.points,color:e.color,width:e.width});break;case"draw:clear":this.emit("draw-clear",{userId:e.userId});break;case"activity:logged":this._activityLogs.unshift(e.activityLog),this._activityLogs.length>100&&(this._activityLogs=this._activityLogs.slice(0,100)),this.emit("activity-logs",this._activityLogs);break;case"error":this.emit("error",e);break}}reset(){this._user=null,this._users.clear(),this._presence.clear(),this._threads.clear(),this._reactions.clear(),this._notifications=[],this._activityLogs=[],this._typing.clear(),this._viewports.clear(),this._selections.clear()}},ht=class extends Te{constructor(e){var t;super(),w(this,"state"),w(this,"connection"),w(this,"config"),w(this,"heartbeatTimer",null),w(this,"lastCursorSend",0),w(this,"pendingCursor",null),w(this,"cursorTimer",null),this.config=e,this.state=new St;const i=((t=e.endpoint)==null?void 0:t.replace(/^http/,"ws"))??void 0;this.connection=new Tt(i),this.connection.on("message",s=>{this.state.handleMessage(s),this.emit(s.type,s)}),this.connection.on("state",s=>{this.emit("connection",s),s==="connected"?(this.authenticate(),this.startHeartbeat()):s==="disconnected"&&this.stopHeartbeat()})}get connectionState(){return this.connection.state}connect(){this.connection.connect()}disconnect(){this.stopHeartbeat(),this.connection.disconnect(),this.state.reset()}authenticate(){this.send({type:"auth",apiKey:this.config.apiKey,token:this.config.token,room:this.config.room})}send(e){this.connection.send(e)}moveCursor(e){const t=Date.now();this.pendingCursor=e,t-this.lastCursorSend>=50?this.flushCursor():this.cursorTimer||(this.cursorTimer=setTimeout(()=>{this.cursorTimer=null,this.flushCursor()},50))}flushCursor(){this.pendingCursor&&(this.send({type:"cursor:move",position:this.pendingCursor}),this.lastCursorSend=Date.now(),this.pendingCursor=null)}updatePresence(e){this.send({type:"presence:update",status:e})}startHeartbeat(){this.heartbeatTimer=setInterval(()=>{this.send({type:"presence:update",status:"online"})},3e4)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}createThread(e,t={}){const i=crypto.randomUUID();return this.send({type:"thread:create",id:i,body:e,mentions:t.mentions??[],position:t.position??null}),i}reply(e,t,i=[]){const s=crypto.randomUUID();return this.send({type:"comment:create",threadId:e,id:s,body:t,mentions:i}),s}editComment(e,t,i=[]){this.send({type:"comment:edit",commentId:e,body:t,mentions:i})}deleteComment(e){this.send({type:"comment:delete",commentId:e})}resolveThread(e,t=!0){this.send({type:"thread:resolve",threadId:e,resolved:t})}addReaction(e,t,i){this.send({type:"reaction:add",targetId:e,targetType:t,emoji:i})}removeReaction(e){this.send({type:"reaction:remove",reactionId:e})}markRead(e){this.send({type:"notification:read",notificationId:e})}markAllRead(){this.send({type:"notification:read-all"})}performClick(e){this.send({type:"click:perform",position:e})}sendTyping(e){this.send({type:"typing:start",threadId:e})}updateViewport(e){this.send({type:"viewport:update",...e})}updateSelection(e){this.send({type:"selection:update",selection:e})}dropEmoji(e,t){this.send({type:"emoji:drop",emoji:e,position:t})}drawStroke(e,t,i){this.send({type:"draw:stroke",points:e,color:t,width:i})}clearDrawing(){this.send({type:"draw:clear"})}async uploadFile(e){const t=this.config.endpoint??window.location.origin,i=new FormData;i.append("file",e);const s=await fetch(`${t}/api/v1/upload`,{method:"POST",headers:{Authorization:`Bearer ${this.config.apiKey}`},body:i});if(!s.ok){const r=await s.json().catch(()=>({error:"Upload failed"}));throw new Error(r.error??"Upload failed")}return s.json()}setAppearOffline(e){e?(this.stopHeartbeat(),this.send({type:"presence:update",status:"idle"})):(this.startHeartbeat(),this.send({type:"presence:update",status:"online"}))}};/**
30
30
  * @license
31
31
  * Copyright 2019 Google LLC
32
32
  * SPDX-License-Identifier: BSD-3-Clause
33
- */const de=globalThis,Ee=de.ShadowRoot&&(de.ShadyCSS===void 0||de.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Te=Symbol(),De=new WeakMap;let lt=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Te)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Ee&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=De.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&De.set(t,e))}return e}toString(){return this.cssText}};const _t=n=>new lt(typeof n=="string"?n:n+"",void 0,Te),S=(n,...e)=>{const t=n.length===1?n[0]:e.reduce((i,s,r)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[r+1],n[0]);return new lt(t,n,Te)},Et=(n,e)=>{if(Ee)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),s=de.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,n.appendChild(i)}},Ue=Ee?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return _t(t)})(n):n;/**
33
+ */const de=globalThis,Se=de.ShadowRoot&&(de.ShadyCSS===void 0||de.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ae=Symbol(),Ne=new WeakMap;let pt=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Ae)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Se&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Ne.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Ne.set(t,e))}return e}toString(){return this.cssText}};const At=n=>new pt(typeof n=="string"?n:n+"",void 0,Ae),A=(n,...e)=>{const t=n.length===1?n[0]:e.reduce((i,s,r)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[r+1],n[0]);return new pt(t,n,Ae)},Mt=(n,e)=>{if(Se)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),s=de.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,n.appendChild(i)}},He=Se?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return At(t)})(n):n;/**
34
34
  * @license
35
35
  * Copyright 2017 Google LLC
36
36
  * SPDX-License-Identifier: BSD-3-Clause
37
- */const{is:Tt,defineProperty:St,getOwnPropertyDescriptor:At,getOwnPropertyNames:Mt,getOwnPropertySymbols:Ot,getPrototypeOf:It}=Object,z=globalThis,He=z.trustedTypes,jt=He?He.emptyScript:"",xe=z.reactiveElementPolyfillSupport,J=(n,e)=>n,ue={toAttribute(n,e){switch(e){case Boolean:n=n?jt:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},Se=(n,e)=>!Tt(n,e),Ne={attribute:!0,type:String,converter:ue,reflect:!1,useDefault:!1,hasChanged:Se};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),z.litPropertyMetadata??(z.litPropertyMetadata=new WeakMap);let W=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Ne){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&St(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:r}=At(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:s,set(o){const l=s==null?void 0:s.call(this);r==null||r.call(this,o),this.requestUpdate(e,l,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Ne}static _$Ei(){if(this.hasOwnProperty(J("elementProperties")))return;const e=It(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(J("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(J("properties"))){const t=this.properties,i=[...Mt(t),...Ot(t)];for(const s of i)this.createProperty(s,t[s])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const s of i)t.unshift(Ue(s))}else e!==void 0&&t.push(Ue(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Et(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){var r;const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){const o=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:ue).toAttribute(t,i.type);this._$Em=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){var r,o;const i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const l=i.getPropertyOptions(s),a=typeof l.converter=="function"?{fromAttribute:l.converter}:((r=l.converter)==null?void 0:r.fromAttribute)!==void 0?l.converter:ue;this._$Em=s;const c=a.fromAttribute(t,l.type);this[s]=c??((o=this._$Ej)==null?void 0:o.get(s))??c,this._$Em=null}}requestUpdate(e,t,i,s=!1,r){var o;if(e!==void 0){const l=this.constructor;if(s===!1&&(r=this[e]),i??(i=l.getPropertyOptions(e)),!((i.hasChanged??Se)(r,t)||i.useDefault&&i.reflect&&r===((o=this._$Ej)==null?void 0:o.get(e))&&!this.hasAttribute(l._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:r},o){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??t??this[e]),r!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s){const{wrapped:l}=o,a=this[r];l!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};W.elementStyles=[],W.shadowRootOptions={mode:"open"},W[J("elementProperties")]=new Map,W[J("finalized")]=new Map,xe==null||xe({ReactiveElement:W}),(z.reactiveElementVersions??(z.reactiveElementVersions=[])).push("2.1.2");/**
37
+ */const{is:It,defineProperty:Ot,getOwnPropertyDescriptor:Rt,getOwnPropertyNames:Lt,getOwnPropertySymbols:jt,getPrototypeOf:zt}=Object,z=globalThis,Be=z.trustedTypes,Ut=Be?Be.emptyScript:"",ye=z.reactiveElementPolyfillSupport,J=(n,e)=>n,ue={toAttribute(n,e){switch(e){case Boolean:n=n?Ut:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},Me=(n,e)=>!It(n,e),Fe={attribute:!0,type:String,converter:ue,reflect:!1,useDefault:!1,hasChanged:Me};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),z.litPropertyMetadata??(z.litPropertyMetadata=new WeakMap);let W=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Fe){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&Ot(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:r}=Rt(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:s,set(o){const l=s==null?void 0:s.call(this);r==null||r.call(this,o),this.requestUpdate(e,l,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Fe}static _$Ei(){if(this.hasOwnProperty(J("elementProperties")))return;const e=zt(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(J("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(J("properties"))){const t=this.properties,i=[...Lt(t),...jt(t)];for(const s of i)this.createProperty(s,t[s])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const s of i)t.unshift(He(s))}else e!==void 0&&t.push(He(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Mt(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){var r;const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){const o=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:ue).toAttribute(t,i.type);this._$Em=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){var r,o;const i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const l=i.getPropertyOptions(s),a=typeof l.converter=="function"?{fromAttribute:l.converter}:((r=l.converter)==null?void 0:r.fromAttribute)!==void 0?l.converter:ue;this._$Em=s;const c=a.fromAttribute(t,l.type);this[s]=c??((o=this._$Ej)==null?void 0:o.get(s))??c,this._$Em=null}}requestUpdate(e,t,i,s=!1,r){var o;if(e!==void 0){const l=this.constructor;if(s===!1&&(r=this[e]),i??(i=l.getPropertyOptions(e)),!((i.hasChanged??Me)(r,t)||i.useDefault&&i.reflect&&r===((o=this._$Ej)==null?void 0:o.get(e))&&!this.hasAttribute(l._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:r},o){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??t??this[e]),r!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s){const{wrapped:l}=o,a=this[r];l!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};W.elementStyles=[],W.shadowRootOptions={mode:"open"},W[J("elementProperties")]=new Map,W[J("finalized")]=new Map,ye==null||ye({ReactiveElement:W}),(z.reactiveElementVersions??(z.reactiveElementVersions=[])).push("2.1.2");/**
38
38
  * @license
39
39
  * Copyright 2017 Google LLC
40
40
  * SPDX-License-Identifier: BSD-3-Clause
41
- */const Z=globalThis,Be=n=>n,fe=Z.trustedTypes,Fe=fe?fe.createPolicy("lit-html",{createHTML:n=>n}):void 0,ct="$lit$",R=`lit$${Math.random().toFixed(9).slice(2)}$`,dt="?"+R,Lt=`<${dt}>`,N=document,Q=()=>N.createComment(""),ee=n=>n===null||typeof n!="object"&&typeof n!="function",Ae=Array.isArray,Rt=n=>Ae(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",ye=`[
42
- \f\r]`,G=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,We=/-->/g,qe=/>/g,D=RegExp(`>|${ye}(?:([^\\s"'>=/]+)(${ye}*=${ye}*(?:[^
43
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Ve=/'/g,Ye=/"/g,pt=/^(?:script|style|textarea|title)$/i,ht=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),d=ht(1),zt=ht(2),B=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),Xe=new WeakMap,U=N.createTreeWalker(N,129);function ut(n,e){if(!Ae(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Fe!==void 0?Fe.createHTML(e):e}const Dt=(n,e)=>{const t=n.length-1,i=[];let s,r=e===2?"<svg>":e===3?"<math>":"",o=G;for(let l=0;l<t;l++){const a=n[l];let c,p,h=-1,f=0;for(;f<a.length&&(o.lastIndex=f,p=o.exec(a),p!==null);)f=o.lastIndex,o===G?p[1]==="!--"?o=We:p[1]!==void 0?o=qe:p[2]!==void 0?(pt.test(p[2])&&(s=RegExp("</"+p[2],"g")),o=D):p[3]!==void 0&&(o=D):o===D?p[0]===">"?(o=s??G,h=-1):p[1]===void 0?h=-2:(h=o.lastIndex-p[2].length,c=p[1],o=p[3]===void 0?D:p[3]==='"'?Ye:Ve):o===Ye||o===Ve?o=D:o===We||o===qe?o=G:(o=D,s=void 0);const g=o===D&&n[l+1].startsWith("/>")?" ":"";r+=o===G?a+Lt:h>=0?(i.push(c),a.slice(0,h)+ct+a.slice(h)+R+g):a+R+(h===-2?l:g)}return[ut(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class te{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,o=0;const l=e.length-1,a=this.parts,[c,p]=Dt(e,t);if(this.el=te.createElement(c,i),U.currentNode=this.el.content,t===2||t===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(s=U.nextNode())!==null&&a.length<l;){if(s.nodeType===1){if(s.hasAttributes())for(const h of s.getAttributeNames())if(h.endsWith(ct)){const f=p[o++],g=s.getAttribute(h).split(R),$=/([.?@])?(.*)/.exec(f);a.push({type:1,index:r,name:$[2],strings:g,ctor:$[1]==="."?Ht:$[1]==="?"?Nt:$[1]==="@"?Bt:ge}),s.removeAttribute(h)}else h.startsWith(R)&&(a.push({type:6,index:r}),s.removeAttribute(h));if(pt.test(s.tagName)){const h=s.textContent.split(R),f=h.length-1;if(f>0){s.textContent=fe?fe.emptyScript:"";for(let g=0;g<f;g++)s.append(h[g],Q()),U.nextNode(),a.push({type:2,index:++r});s.append(h[f],Q())}}}else if(s.nodeType===8)if(s.data===dt)a.push({type:2,index:r});else{let h=-1;for(;(h=s.data.indexOf(R,h+1))!==-1;)a.push({type:7,index:r}),h+=R.length-1}r++}}static createElement(e,t){const i=N.createElement("template");return i.innerHTML=e,i}}function q(n,e,t=n,i){var o,l;if(e===B)return e;let s=i!==void 0?(o=t._$Co)==null?void 0:o[i]:t._$Cl;const r=ee(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((l=s==null?void 0:s._$AO)==null||l.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=q(n,s._$AS(n,e.values),s,i)),e}class Ut{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??N).importNode(t,!0);U.currentNode=s;let r=U.nextNode(),o=0,l=0,a=i[0];for(;a!==void 0;){if(o===a.index){let c;a.type===2?c=new oe(r,r.nextSibling,this,e):a.type===1?c=new a.ctor(r,a.name,a.strings,this,e):a.type===6&&(c=new Ft(r,this,e)),this._$AV.push(c),a=i[++l]}o!==(a==null?void 0:a.index)&&(r=U.nextNode(),o++)}return U.currentNode=N,s}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class oe{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=u,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=q(this,e,t),ee(e)?e===u||e==null||e===""?(this._$AH!==u&&this._$AR(),this._$AH=u):e!==this._$AH&&e!==B&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Rt(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==u&&ee(this._$AH)?this._$AA.nextSibling.data=e:this.T(N.createTextNode(e)),this._$AH=e}$(e){var r;const{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=te.createElement(ut(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(t);else{const o=new Ut(s,this),l=o.u(this.options);o.p(t),this.T(l),this._$AH=o}}_$AC(e){let t=Xe.get(e.strings);return t===void 0&&Xe.set(e.strings,t=new te(e)),t}k(e){Ae(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const r of e)s===t.length?t.push(i=new oe(this.O(Q()),this.O(Q()),this,this.options)):i=t[s],i._$AI(r),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e!==this._$AB;){const s=Be(e).nextSibling;Be(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class ge{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=u,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=u}_$AI(e,t=this,i,s){const r=this.strings;let o=!1;if(r===void 0)e=q(this,e,t,0),o=!ee(e)||e!==this._$AH&&e!==B,o&&(this._$AH=e);else{const l=e;let a,c;for(e=r[0],a=0;a<r.length-1;a++)c=q(this,l[i+a],t,a),c===B&&(c=this._$AH[a]),o||(o=!ee(c)||c!==this._$AH[a]),c===u?e=u:e!==u&&(e+=(c??"")+r[a+1]),this._$AH[a]=c}o&&!s&&this.j(e)}j(e){e===u?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Ht extends ge{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===u?void 0:e}}class Nt extends ge{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==u)}}class Bt extends ge{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=q(this,e,t,0)??u)===B)return;const i=this._$AH,s=e===u&&i!==u||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==u&&(i===u||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class Ft{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){q(this,e)}}const we=Z.litHtmlPolyfillSupport;we==null||we(te,oe),(Z.litHtmlVersions??(Z.litHtmlVersions=[])).push("3.3.2");const Wt=(n,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let s=i._$litPart$;if(s===void 0){const r=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new oe(e.insertBefore(Q(),r),r,void 0,t??{})}return s._$AI(n),s};/**
41
+ */const Z=globalThis,We=n=>n,fe=Z.trustedTypes,qe=fe?fe.createPolicy("lit-html",{createHTML:n=>n}):void 0,ut="$lit$",j=`lit$${Math.random().toFixed(9).slice(2)}$`,ft="?"+j,Dt=`<${ft}>`,H=document,Q=()=>H.createComment(""),ee=n=>n===null||typeof n!="object"&&typeof n!="function",Ie=Array.isArray,Nt=n=>Ie(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",we=`[
42
+ \f\r]`,G=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ve=/-->/g,Xe=/>/g,U=RegExp(`>|${we}(?:([^\\s"'>=/]+)(${we}*=${we}*(?:[^
43
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Ye=/'/g,Ke=/"/g,mt=/^(?:script|style|textarea|title)$/i,gt=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),d=gt(1),Ht=gt(2),B=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),Ge=new WeakMap,D=H.createTreeWalker(H,129);function bt(n,e){if(!Ie(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return qe!==void 0?qe.createHTML(e):e}const Bt=(n,e)=>{const t=n.length-1,i=[];let s,r=e===2?"<svg>":e===3?"<math>":"",o=G;for(let l=0;l<t;l++){const a=n[l];let c,h,p=-1,m=0;for(;m<a.length&&(o.lastIndex=m,h=o.exec(a),h!==null);)m=o.lastIndex,o===G?h[1]==="!--"?o=Ve:h[1]!==void 0?o=Xe:h[2]!==void 0?(mt.test(h[2])&&(s=RegExp("</"+h[2],"g")),o=U):h[3]!==void 0&&(o=U):o===U?h[0]===">"?(o=s??G,p=-1):h[1]===void 0?p=-2:(p=o.lastIndex-h[2].length,c=h[1],o=h[3]===void 0?U:h[3]==='"'?Ke:Ye):o===Ke||o===Ye?o=U:o===Ve||o===Xe?o=G:(o=U,s=void 0);const f=o===U&&n[l+1].startsWith("/>")?" ":"";r+=o===G?a+Dt:p>=0?(i.push(c),a.slice(0,p)+ut+a.slice(p)+j+f):a+j+(p===-2?l:f)}return[bt(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class te{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,o=0;const l=e.length-1,a=this.parts,[c,h]=Bt(e,t);if(this.el=te.createElement(c,i),D.currentNode=this.el.content,t===2||t===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=D.nextNode())!==null&&a.length<l;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(ut)){const m=h[o++],f=s.getAttribute(p).split(j),b=/([.?@])?(.*)/.exec(m);a.push({type:1,index:r,name:b[2],strings:f,ctor:b[1]==="."?Wt:b[1]==="?"?qt:b[1]==="@"?Vt:be}),s.removeAttribute(p)}else p.startsWith(j)&&(a.push({type:6,index:r}),s.removeAttribute(p));if(mt.test(s.tagName)){const p=s.textContent.split(j),m=p.length-1;if(m>0){s.textContent=fe?fe.emptyScript:"";for(let f=0;f<m;f++)s.append(p[f],Q()),D.nextNode(),a.push({type:2,index:++r});s.append(p[m],Q())}}}else if(s.nodeType===8)if(s.data===ft)a.push({type:2,index:r});else{let p=-1;for(;(p=s.data.indexOf(j,p+1))!==-1;)a.push({type:7,index:r}),p+=j.length-1}r++}}static createElement(e,t){const i=H.createElement("template");return i.innerHTML=e,i}}function q(n,e,t=n,i){var o,l;if(e===B)return e;let s=i!==void 0?(o=t._$Co)==null?void 0:o[i]:t._$Cl;const r=ee(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((l=s==null?void 0:s._$AO)==null||l.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=q(n,s._$AS(n,e.values),s,i)),e}class Ft{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??H).importNode(t,!0);D.currentNode=s;let r=D.nextNode(),o=0,l=0,a=i[0];for(;a!==void 0;){if(o===a.index){let c;a.type===2?c=new oe(r,r.nextSibling,this,e):a.type===1?c=new a.ctor(r,a.name,a.strings,this,e):a.type===6&&(c=new Xt(r,this,e)),this._$AV.push(c),a=i[++l]}o!==(a==null?void 0:a.index)&&(r=D.nextNode(),o++)}return D.currentNode=H,s}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class oe{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=u,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=q(this,e,t),ee(e)?e===u||e==null||e===""?(this._$AH!==u&&this._$AR(),this._$AH=u):e!==this._$AH&&e!==B&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Nt(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==u&&ee(this._$AH)?this._$AA.nextSibling.data=e:this.T(H.createTextNode(e)),this._$AH=e}$(e){var r;const{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=te.createElement(bt(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(t);else{const o=new Ft(s,this),l=o.u(this.options);o.p(t),this.T(l),this._$AH=o}}_$AC(e){let t=Ge.get(e.strings);return t===void 0&&Ge.set(e.strings,t=new te(e)),t}k(e){Ie(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const r of e)s===t.length?t.push(i=new oe(this.O(Q()),this.O(Q()),this,this.options)):i=t[s],i._$AI(r),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e!==this._$AB;){const s=We(e).nextSibling;We(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class be{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=u,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=u}_$AI(e,t=this,i,s){const r=this.strings;let o=!1;if(r===void 0)e=q(this,e,t,0),o=!ee(e)||e!==this._$AH&&e!==B,o&&(this._$AH=e);else{const l=e;let a,c;for(e=r[0],a=0;a<r.length-1;a++)c=q(this,l[i+a],t,a),c===B&&(c=this._$AH[a]),o||(o=!ee(c)||c!==this._$AH[a]),c===u?e=u:e!==u&&(e+=(c??"")+r[a+1]),this._$AH[a]=c}o&&!s&&this.j(e)}j(e){e===u?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Wt extends be{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===u?void 0:e}}class qt extends be{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==u)}}class Vt extends be{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=q(this,e,t,0)??u)===B)return;const i=this._$AH,s=e===u&&i!==u||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==u&&(i===u||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class Xt{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){q(this,e)}}const $e=Z.litHtmlPolyfillSupport;$e==null||$e(te,oe),(Z.litHtmlVersions??(Z.litHtmlVersions=[])).push("3.3.2");const Yt=(n,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let s=i._$litPart$;if(s===void 0){const r=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new oe(e.insertBefore(Q(),r),r,void 0,t??{})}return s._$AI(n),s};/**
44
44
  * @license
45
45
  * Copyright 2017 Google LLC
46
46
  * SPDX-License-Identifier: BSD-3-Clause
47
- */const H=globalThis;let P=class extends W{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Wt(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return B}};var ot;P._$litElement$=!0,P.finalized=!0,(ot=H.litElementHydrateSupport)==null||ot.call(H,{LitElement:P});const $e=H.litElementPolyfillSupport;$e==null||$e({LitElement:P});(H.litElementVersions??(H.litElementVersions=[])).push("4.2.2");/**
47
+ */const N=globalThis;let _=class extends W{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Yt(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return B}};var ct;_._$litElement$=!0,_.finalized=!0,(ct=N.litElementHydrateSupport)==null||ct.call(N,{LitElement:_});const ke=N.litElementPolyfillSupport;ke==null||ke({LitElement:_});(N.litElementVersions??(N.litElementVersions=[])).push("4.2.2");/**
48
48
  * @license
49
49
  * Copyright 2017 Google LLC
50
50
  * SPDX-License-Identifier: BSD-3-Clause
51
- */const I=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};/**
51
+ */const O=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};/**
52
52
  * @license
53
53
  * Copyright 2017 Google LLC
54
54
  * SPDX-License-Identifier: BSD-3-Clause
55
- */const qt={attribute:!0,type:String,converter:ue,reflect:!1,hasChanged:Se},Vt=(n=qt,e,t)=>{const{kind:i,metadata:s}=t;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((n=Object.create(n)).wrapped=!0),r.set(t.name,n),i==="accessor"){const{name:o}=t;return{set(l){const a=e.get.call(this);e.set.call(this,l),this.requestUpdate(o,a,n,!0,l)},init(l){return l!==void 0&&this.C(o,void 0,n,l),l}}}if(i==="setter"){const{name:o}=t;return function(l){const a=this[o];e.call(this,l),this.requestUpdate(o,a,n,!0,l)}}throw Error("Unsupported decorator location: "+i)};function m(n){return(e,t)=>typeof t=="object"?Vt(n,e,t):((i,s,r)=>{const o=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),o?Object.getOwnPropertyDescriptor(s,r):void 0})(n,e,t)}/**
55
+ */const Kt={attribute:!0,type:String,converter:ue,reflect:!1,hasChanged:Me},Gt=(n=Kt,e,t)=>{const{kind:i,metadata:s}=t;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((n=Object.create(n)).wrapped=!0),r.set(t.name,n),i==="accessor"){const{name:o}=t;return{set(l){const a=e.get.call(this);e.set.call(this,l),this.requestUpdate(o,a,n,!0,l)},init(l){return l!==void 0&&this.C(o,void 0,n,l),l}}}if(i==="setter"){const{name:o}=t;return function(l){const a=this[o];e.call(this,l),this.requestUpdate(o,a,n,!0,l)}}throw Error("Unsupported decorator location: "+i)};function g(n){return(e,t)=>typeof t=="object"?Gt(n,e,t):((i,s,r)=>{const o=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),o?Object.getOwnPropertyDescriptor(s,r):void 0})(n,e,t)}/**
56
56
  * @license
57
57
  * Copyright 2017 Google LLC
58
58
  * SPDX-License-Identifier: BSD-3-Clause
59
- */function b(n){return m({...n,state:!0,attribute:!1})}const V="pulse-client";var Yt=Object.defineProperty,Xt=Object.getOwnPropertyDescriptor,Y=(n,e,t,i)=>{for(var s=i>1?void 0:i?Xt(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yt(e,t,s),s};exports.PulseProvider=class extends P{constructor(){super(...arguments),this.apiKey="",this.token="",this.room=""}connectedCallback(){super.connectedCallback();const e={apiKey:this.apiKey,token:this.token,room:this.room,endpoint:this.endpoint};this.client=new at(e),this.client.connect()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.client)==null||e.disconnect()}render(){return d`<slot></slot>`}};Y([m({attribute:"api-key"})],exports.PulseProvider.prototype,"apiKey",2);Y([m()],exports.PulseProvider.prototype,"token",2);Y([m()],exports.PulseProvider.prototype,"room",2);Y([m()],exports.PulseProvider.prototype,"endpoint",2);Y([yt({context:V})],exports.PulseProvider.prototype,"client",2);exports.PulseProvider=Y([I("pulse-provider")],exports.PulseProvider);var Kt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,be=(n,e,t,i)=>{for(var s=i>1?void 0:i?Gt(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Kt(e,t,s),s};exports.PulsePresence=class extends P{constructor(){super(...arguments),this.maxVisible=5,this.users=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.users=this.client.state.presence,this.unsub=this.client.state.on("presence",e=>{this.users=e}))}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}render(){const e=this.users.slice(0,this.maxVisible),t=this.users.length-this.maxVisible;return d`
59
+ */function v(n){return g({...n,state:!0,attribute:!1})}const V="pulse-client";var Jt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,X=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zt(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Jt(e,t,s),s};exports.PulseProvider=class extends _{constructor(){super(...arguments),this.apiKey="",this.token="",this.room=""}connectedCallback(){super.connectedCallback();const e={apiKey:this.apiKey,token:this.token,room:this.room,endpoint:this.endpoint};this.client=new ht(e),this.client.connect()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.client)==null||e.disconnect()}render(){return d`<slot></slot>`}};X([g({attribute:"api-key"})],exports.PulseProvider.prototype,"apiKey",2);X([g()],exports.PulseProvider.prototype,"token",2);X([g()],exports.PulseProvider.prototype,"room",2);X([g()],exports.PulseProvider.prototype,"endpoint",2);X([Ct({context:V})],exports.PulseProvider.prototype,"client",2);exports.PulseProvider=X([O("pulse-provider")],exports.PulseProvider);var Qt=Object.defineProperty,ei=Object.getOwnPropertyDescriptor,ve=(n,e,t,i)=>{for(var s=i>1?void 0:i?ei(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Qt(e,t,s),s};exports.PulsePresence=class extends _{constructor(){super(...arguments),this.maxVisible=5,this.users=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.users=this.client.state.presence,this.unsub=this.client.state.on("presence",e=>{this.users=e}))}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}render(){const e=this.users.slice(0,this.maxVisible),t=this.users.length-this.maxVisible;return d`
60
60
  <div class="avatars">
61
61
  ${t>0?d`<div class="overflow">+${t}</div>`:null}
62
62
  ${e.map(i=>d`
@@ -70,7 +70,7 @@
70
70
  </div>
71
71
  `)}
72
72
  </div>
73
- `}};exports.PulsePresence.styles=S`
73
+ `}};exports.PulsePresence.styles=A`
74
74
  :host {
75
75
  display: inline-flex;
76
76
  align-items: center;
@@ -173,7 +173,7 @@
173
173
  .avatar:hover .tooltip {
174
174
  opacity: 1;
175
175
  }
176
- `;be([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulsePresence.prototype,"client",2);be([m({type:Number,attribute:"max-visible"})],exports.PulsePresence.prototype,"maxVisible",2);be([b()],exports.PulsePresence.prototype,"users",2);exports.PulsePresence=be([I("pulse-presence")],exports.PulsePresence);var Jt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Me=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zt(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Jt(e,t,s),s};exports.PulseCursors=class extends P{constructor(){super(...arguments),this.cursors=new Map,this.unsubs=[],this.handleLocalCursor=e=>{var t;(t=this.client)==null||t.moveCursor({x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY})}}connectedCallback(){super.connectedCallback(),this.setupListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unsubs.forEach(e=>e()),this.unsubs=[],document.removeEventListener("mousemove",this.handleLocalCursor)}updated(e){e.has("client")&&this.client&&(this.unsubs.forEach(t=>t()),this.unsubs=[],this.setupListeners())}setupListeners(){this.client&&(this.unsubs.push(this.client.state.on("cursor",({userId:e,position:t})=>{const i=this.cursors.get(e);if(i)i.position=t;else{const s=this.client.state.presence.find(r=>r.user.id===e);s&&this.cursors.set(e,{userId:e,name:s.user.name,color:s.user.color,position:t})}this.requestUpdate()})),this.unsubs.push(this.client.state.on("presence",e=>{const t=new Set(e.map(i=>i.user.id));for(const i of this.cursors.keys())t.has(i)||this.cursors.delete(i);this.requestUpdate()})),document.addEventListener("mousemove",this.handleLocalCursor))}render(){const e=[...this.cursors.values()];return d`
176
+ `;ve([ne({context:V,subscribe:!0}),g({attribute:!1})],exports.PulsePresence.prototype,"client",2);ve([g({type:Number,attribute:"max-visible"})],exports.PulsePresence.prototype,"maxVisible",2);ve([v()],exports.PulsePresence.prototype,"users",2);exports.PulsePresence=ve([O("pulse-presence")],exports.PulsePresence);var ti=Object.defineProperty,ii=Object.getOwnPropertyDescriptor,Oe=(n,e,t,i)=>{for(var s=i>1?void 0:i?ii(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ti(e,t,s),s};exports.PulseCursors=class extends _{constructor(){super(...arguments),this.cursors=new Map,this.unsubs=[],this.handleLocalCursor=e=>{var t;(t=this.client)==null||t.moveCursor({x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY})}}connectedCallback(){super.connectedCallback(),this.setupListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unsubs.forEach(e=>e()),this.unsubs=[],document.removeEventListener("mousemove",this.handleLocalCursor)}updated(e){e.has("client")&&this.client&&(this.unsubs.forEach(t=>t()),this.unsubs=[],this.setupListeners())}setupListeners(){this.client&&(this.unsubs.push(this.client.state.on("cursor",({userId:e,position:t})=>{const i=this.cursors.get(e);if(i)i.position=t;else{const s=this.client.state.presence.find(r=>r.user.id===e);s&&this.cursors.set(e,{userId:e,name:s.user.name,color:s.user.color,position:t})}this.requestUpdate()})),this.unsubs.push(this.client.state.on("presence",e=>{const t=new Set(e.map(i=>i.user.id));for(const i of this.cursors.keys())t.has(i)||this.cursors.delete(i);this.requestUpdate()})),document.addEventListener("mousemove",this.handleLocalCursor))}render(){const e=[...this.cursors.values()];return d`
177
177
  ${e.map(t=>d`
178
178
  <div
179
179
  class="cursor"
@@ -191,7 +191,7 @@
191
191
  </span>
192
192
  </div>
193
193
  `)}
194
- `}};exports.PulseCursors.styles=S`
194
+ `}};exports.PulseCursors.styles=A`
195
195
  :host {
196
196
  position: fixed;
197
197
  top: 0;
@@ -227,7 +227,7 @@
227
227
  letter-spacing: 0.01em;
228
228
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
229
229
  }
230
- `;Me([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulseCursors.prototype,"client",2);Me([b()],exports.PulseCursors.prototype,"cursors",2);exports.PulseCursors=Me([I("pulse-cursors")],exports.PulseCursors);var Qt=Object.defineProperty,ei=Object.getOwnPropertyDescriptor,re=(n,e,t,i)=>{for(var s=i>1?void 0:i?ei(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Qt(e,t,s),s};exports.PulseComments=class extends P{constructor(){super(...arguments),this.showResolved=!1,this.threads=[],this.replyingTo=null}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.threads=this.client.state.threads,this.unsub=this.client.state.on("threads",e=>{this.threads=[...e]}))}parseMentions(e){return e.split(/(@\w+)/g).map(i=>i.startsWith("@")?d`<span class="mention">${i}</span>`:i)}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}getUserForComment(e){var t;return(t=this.client.state.presence.find(i=>i.user.id===e))==null?void 0:t.user}handleNewThread(e){e.preventDefault();const i=e.target.querySelector("textarea"),s=i.value.trim();if(!s)return;const r=[...s.matchAll(/@(\w+)/g)].map(o=>o[1]);this.client.createThread(s,{mentions:r}),i.value=""}handleReply(e,t){t.preventDefault();const s=t.target.querySelector("input"),r=s.value.trim();if(!r)return;const o=[...r.matchAll(/@(\w+)/g)].map(l=>l[1]);this.client.reply(e,r,o),s.value="",this.replyingTo=null}render(){const e=this.showResolved?this.threads:this.threads.filter(t=>!t.resolved);return d`
230
+ `;Oe([ne({context:V,subscribe:!0}),g({attribute:!1})],exports.PulseCursors.prototype,"client",2);Oe([v()],exports.PulseCursors.prototype,"cursors",2);exports.PulseCursors=Oe([O("pulse-cursors")],exports.PulseCursors);var si=Object.defineProperty,ni=Object.getOwnPropertyDescriptor,re=(n,e,t,i)=>{for(var s=i>1?void 0:i?ni(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&si(e,t,s),s};exports.PulseComments=class extends _{constructor(){super(...arguments),this.showResolved=!1,this.threads=[],this.replyingTo=null}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.threads=this.client.state.threads,this.unsub=this.client.state.on("threads",e=>{this.threads=[...e]}))}parseMentions(e){return e.split(/(@\w+)/g).map(i=>i.startsWith("@")?d`<span class="mention">${i}</span>`:i)}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}getUserForComment(e){var t;return(t=this.client.state.presence.find(i=>i.user.id===e))==null?void 0:t.user}handleNewThread(e){e.preventDefault();const i=e.target.querySelector("textarea"),s=i.value.trim();if(!s)return;const r=[...s.matchAll(/@(\w+)/g)].map(o=>o[1]);this.client.createThread(s,{mentions:r}),i.value=""}handleReply(e,t){t.preventDefault();const s=t.target.querySelector("input"),r=s.value.trim();if(!r)return;const o=[...r.matchAll(/@(\w+)/g)].map(l=>l[1]);this.client.reply(e,r,o),s.value="",this.replyingTo=null}render(){const e=this.showResolved?this.threads:this.threads.filter(t=>!t.resolved);return d`
231
231
  <div class="threads">
232
232
  ${e.length===0?d`<div class="empty">
233
233
  <div class="empty-icon">&#128172;</div>
@@ -281,7 +281,7 @@
281
281
  </form>
282
282
  `:u}
283
283
  </div>
284
- `}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),r=Math.floor(s/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:t.toLocaleDateString()}};exports.PulseComments.styles=S`
284
+ `}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),r=Math.floor(s/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:t.toLocaleDateString()}};exports.PulseComments.styles=A`
285
285
  :host {
286
286
  display: block;
287
287
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
@@ -492,7 +492,7 @@
492
492
  margin-bottom: 8px;
493
493
  opacity: 0.4;
494
494
  }
495
- `;re([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulseComments.prototype,"client",2);re([m({type:Boolean,attribute:"show-resolved"})],exports.PulseComments.prototype,"showResolved",2);re([b()],exports.PulseComments.prototype,"threads",2);re([b()],exports.PulseComments.prototype,"replyingTo",2);exports.PulseComments=re([I("pulse-comments")],exports.PulseComments);var ti=Object.defineProperty,ii=Object.getOwnPropertyDescriptor,Oe=(n,e,t,i)=>{for(var s=i>1?void 0:i?ii(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ti(e,t,s),s};const si={"comment:created":"left a comment","comment:mention":"mentioned you","comment:reply":"replied to your comment","thread:resolved":"resolved a thread","reaction:added":"reacted to your comment"},ni={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};exports.PulseNotifications=class extends P{constructor(){super(...arguments),this.notifications=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.notifications=this.client.state.notifications,this.unsub=this.client.state.on("notifications",e=>{this.notifications=[...e]}))}handleClick(e){e.read||this.client.markRead(e.id),this.dispatchEvent(new CustomEvent("pulse-notification-click",{detail:e,bubbles:!0,composed:!0}))}getActorName(e){const t=this.client.state.presence.find(i=>i.user.id===e);return(t==null?void 0:t.user.name)??"Someone"}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),r=Math.floor(s/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:t.toLocaleDateString()}render(){const e=this.notifications.filter(t=>!t.read).length;return d`
495
+ `;re([ne({context:V,subscribe:!0}),g({attribute:!1})],exports.PulseComments.prototype,"client",2);re([g({type:Boolean,attribute:"show-resolved"})],exports.PulseComments.prototype,"showResolved",2);re([v()],exports.PulseComments.prototype,"threads",2);re([v()],exports.PulseComments.prototype,"replyingTo",2);exports.PulseComments=re([O("pulse-comments")],exports.PulseComments);var oi=Object.defineProperty,ri=Object.getOwnPropertyDescriptor,Re=(n,e,t,i)=>{for(var s=i>1?void 0:i?ri(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&oi(e,t,s),s};const ai={"comment:created":"left a comment","comment:mention":"mentioned you","comment:reply":"replied to your comment","thread:resolved":"resolved a thread","reaction:added":"reacted to your comment"},li={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};exports.PulseNotifications=class extends _{constructor(){super(...arguments),this.notifications=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.notifications=this.client.state.notifications,this.unsub=this.client.state.on("notifications",e=>{this.notifications=[...e]}))}handleClick(e){e.read||this.client.markRead(e.id),this.dispatchEvent(new CustomEvent("pulse-notification-click",{detail:e,bubbles:!0,composed:!0}))}getActorName(e){const t=this.client.state.presence.find(i=>i.user.id===e);return(t==null?void 0:t.user.name)??"Someone"}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),r=Math.floor(s/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:t.toLocaleDateString()}render(){const e=this.notifications.filter(t=>!t.read).length;return d`
496
496
  <div class="header">
497
497
  <span class="title">
498
498
  Notifications
@@ -511,11 +511,11 @@
511
511
  class="item ${t.read?"":"unread"}"
512
512
  @click=${()=>this.handleClick(t)}
513
513
  >
514
- <span class="icon">${ni[t.type]??"🔔"}</span>
514
+ <span class="icon">${li[t.type]??"🔔"}</span>
515
515
  <div class="content">
516
516
  <div class="text">
517
517
  <span class="actor">${this.getActorName(t.actorId)}</span>
518
- ${si[t.type]??t.type}
518
+ ${ai[t.type]??t.type}
519
519
  </div>
520
520
  <div class="time">${this.formatTime(t.createdAt)}</div>
521
521
  </div>
@@ -523,7 +523,7 @@
523
523
  </div>
524
524
  `)}
525
525
  </div>
526
- `}};exports.PulseNotifications.styles=S`
526
+ `}};exports.PulseNotifications.styles=A`
527
527
  :host {
528
528
  display: block;
529
529
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
@@ -663,7 +663,7 @@
663
663
  margin-bottom: 8px;
664
664
  opacity: 0.4;
665
665
  }
666
- `;Oe([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulseNotifications.prototype,"client",2);Oe([b()],exports.PulseNotifications.prototype,"notifications",2);exports.PulseNotifications=Oe([I("pulse-notifications")],exports.PulseNotifications);var oi=Object.defineProperty,ri=Object.getOwnPropertyDescriptor,X=(n,e,t,i)=>{for(var s=i>1?void 0:i?ri(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&oi(e,t,s),s};const ai=["👍","👎","❤️","🎉","👀","🚀"];exports.PulseReactions=class extends P{constructor(){super(...arguments),this.targetId="",this.targetType="comment",this.reactions=[],this.showPicker=!1}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.reactions=this.client.state.getReactions(this.targetId),this.unsub=this.client.state.on("reactions",e=>{e.targetId===this.targetId&&(this.reactions=[...e.reactions])}))}groupReactions(){var i,s;const e=new Map,t=(s=(i=this.client)==null?void 0:i.state.user)==null?void 0:s.id;for(const r of this.reactions){const o=e.get(r.emoji)??{count:0,userReactionId:null};o.count++,r.userId===t&&(o.userReactionId=r.id),e.set(r.emoji,o)}return[...e.entries()].map(([r,o])=>({emoji:r,...o}))}toggleReaction(e){e.userReactionId?this.client.removeReaction(e.userReactionId):this.client.addReaction(this.targetId,this.targetType,e.emoji)}addEmoji(e){this.client.addReaction(this.targetId,this.targetType,e),this.showPicker=!1}render(){const e=this.groupReactions();return d`
666
+ `;Re([ne({context:V,subscribe:!0}),g({attribute:!1})],exports.PulseNotifications.prototype,"client",2);Re([v()],exports.PulseNotifications.prototype,"notifications",2);exports.PulseNotifications=Re([O("pulse-notifications")],exports.PulseNotifications);var ci=Object.defineProperty,di=Object.getOwnPropertyDescriptor,Y=(n,e,t,i)=>{for(var s=i>1?void 0:i?di(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ci(e,t,s),s};const hi=["👍","👎","❤️","🎉","👀","🚀"];exports.PulseReactions=class extends _{constructor(){super(...arguments),this.targetId="",this.targetType="comment",this.reactions=[],this.showPicker=!1}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.reactions=this.client.state.getReactions(this.targetId),this.unsub=this.client.state.on("reactions",e=>{e.targetId===this.targetId&&(this.reactions=[...e.reactions])}))}groupReactions(){var i,s;const e=new Map,t=(s=(i=this.client)==null?void 0:i.state.user)==null?void 0:s.id;for(const r of this.reactions){const o=e.get(r.emoji)??{count:0,userReactionId:null};o.count++,r.userId===t&&(o.userReactionId=r.id),e.set(r.emoji,o)}return[...e.entries()].map(([r,o])=>({emoji:r,...o}))}toggleReaction(e){e.userReactionId?this.client.removeReaction(e.userReactionId):this.client.addReaction(this.targetId,this.targetType,e.emoji)}addEmoji(e){this.client.addReaction(this.targetId,this.targetType,e),this.showPicker=!1}render(){const e=this.groupReactions();return d`
667
667
  ${e.map(t=>d`
668
668
  <button
669
669
  class="reaction ${t.userReactionId?"active":""}"
@@ -682,7 +682,7 @@
682
682
  </button>
683
683
  ${this.showPicker?d`
684
684
  <div class="picker">
685
- ${ai.map(t=>d`
685
+ ${hi.map(t=>d`
686
686
  <button @click=${()=>this.addEmoji(t)}>
687
687
  ${t}
688
688
  </button>
@@ -690,7 +690,7 @@
690
690
  </div>
691
691
  `:u}
692
692
  </div>
693
- `}};exports.PulseReactions.styles=S`
693
+ `}};exports.PulseReactions.styles=A`
694
694
  :host {
695
695
  display: inline-flex;
696
696
  align-items: center;
@@ -801,59 +801,69 @@
801
801
  background: #f1f5f9;
802
802
  transform: scale(1.2);
803
803
  }
804
- `;X([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulseReactions.prototype,"client",2);X([m({attribute:"target-id"})],exports.PulseReactions.prototype,"targetId",2);X([m({attribute:"target-type"})],exports.PulseReactions.prototype,"targetType",2);X([b()],exports.PulseReactions.prototype,"reactions",2);X([b()],exports.PulseReactions.prototype,"showPicker",2);exports.PulseReactions=X([I("pulse-reactions")],exports.PulseReactions);/**
804
+ `;Y([ne({context:V,subscribe:!0}),g({attribute:!1})],exports.PulseReactions.prototype,"client",2);Y([g({attribute:"target-id"})],exports.PulseReactions.prototype,"targetId",2);Y([g({attribute:"target-type"})],exports.PulseReactions.prototype,"targetType",2);Y([v()],exports.PulseReactions.prototype,"reactions",2);Y([v()],exports.PulseReactions.prototype,"showPicker",2);exports.PulseReactions=Y([O("pulse-reactions")],exports.PulseReactions);/**
805
805
  * @license
806
806
  * Copyright 2017 Google LLC
807
807
  * SPDX-License-Identifier: BSD-3-Clause
808
- */const li={CHILD:2},ci=n=>(...e)=>({_$litDirective$:n,values:e});class di{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
808
+ */const pi={CHILD:2},ui=n=>(...e)=>({_$litDirective$:n,values:e});class fi{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
809
809
  * @license
810
810
  * Copyright 2017 Google LLC
811
811
  * SPDX-License-Identifier: BSD-3-Clause
812
- */class ke extends di{constructor(e){if(super(e),this.it=u,e.type!==li.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===u||e==null)return this._t=void 0,this.it=e;if(e===B)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}ke.directiveName="unsafeHTML",ke.resultType=1;/**
812
+ */class Ce extends fi{constructor(e){if(super(e),this.it=u,e.type!==pi.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===u||e==null)return this._t=void 0,this.it=e;if(e===B)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}Ce.directiveName="unsafeHTML",Ce.resultType=1;/**
813
813
  * @license
814
814
  * Copyright 2017 Google LLC
815
815
  * SPDX-License-Identifier: BSD-3-Clause
816
- */class Ce extends ke{}Ce.directiveName="unsafeSVG",Ce.resultType=2;const pi=ci(Ce);/**
816
+ */class Ee extends Ce{}Ee.directiveName="unsafeSVG",Ee.resultType=2;const mi=ui(Ee);/**
817
817
  * @license lucide v0.577.0 - ISC
818
818
  *
819
819
  * This source code is licensed under the ISC license.
820
820
  * See the LICENSE file in the root directory of this source tree.
821
- */const hi=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];/**
821
+ */const gi=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];/**
822
822
  * @license lucide v0.577.0 - ISC
823
823
  *
824
824
  * This source code is licensed under the ISC license.
825
825
  * See the LICENSE file in the root directory of this source tree.
826
- */const ui=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];/**
826
+ */const bi=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];/**
827
827
  * @license lucide v0.577.0 - ISC
828
828
  *
829
829
  * This source code is licensed under the ISC license.
830
830
  * See the LICENSE file in the root directory of this source tree.
831
- */const fi=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}]];/**
831
+ */const vi=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}]];/**
832
832
  * @license lucide v0.577.0 - ISC
833
833
  *
834
834
  * This source code is licensed under the ISC license.
835
835
  * See the LICENSE file in the root directory of this source tree.
836
- */const mi=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18"}],["path",{d:"m2.3 2.3 7.286 7.286"}],["circle",{cx:"11",cy:"11",r:"2"}]];/**
836
+ */const xi=[["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]];/**
837
837
  * @license lucide v0.577.0 - ISC
838
838
  *
839
839
  * This source code is licensed under the ISC license.
840
840
  * See the LICENSE file in the root directory of this source tree.
841
- */const gi=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}],["path",{d:"m15 5 4 4"}]];/**
841
+ */const yi=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];/**
842
842
  * @license lucide v0.577.0 - ISC
843
843
  *
844
844
  * This source code is licensed under the ISC license.
845
845
  * See the LICENSE file in the root directory of this source tree.
846
- */const ft=[["path",{d:"M12 17v5"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"}]];/**
846
+ */const wi=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18"}],["path",{d:"m2.3 2.3 7.286 7.286"}],["circle",{cx:"11",cy:"11",r:"2"}]];/**
847
847
  * @license lucide v0.577.0 - ISC
848
848
  *
849
849
  * This source code is licensed under the ISC license.
850
850
  * See the LICENSE file in the root directory of this source tree.
851
- */const bi=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];/**
851
+ */const $i=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}],["path",{d:"m15 5 4 4"}]];/**
852
852
  * @license lucide v0.577.0 - ISC
853
853
  *
854
854
  * This source code is licensed under the ISC license.
855
855
  * See the LICENSE file in the root directory of this source tree.
856
- */const vi=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];/**
856
+ */const vt=[["path",{d:"M12 17v5"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"}]];/**
857
+ * @license lucide v0.577.0 - ISC
858
+ *
859
+ * This source code is licensed under the ISC license.
860
+ * See the LICENSE file in the root directory of this source tree.
861
+ */const ki=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];/**
862
+ * @license lucide v0.577.0 - ISC
863
+ *
864
+ * This source code is licensed under the ISC license.
865
+ * See the LICENSE file in the root directory of this source tree.
866
+ */const Ci=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];/**
857
867
  * @license lucide v0.577.0 - ISC
858
868
  *
859
869
  * This source code is licensed under the ISC license.
@@ -863,7 +873,7 @@
863
873
  *
864
874
  * This source code is licensed under the ISC license.
865
875
  * See the LICENSE file in the root directory of this source tree.
866
- */const xi=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];function yi(n){return n.map(([e,t])=>{const i=Object.entries(t).filter(([,s])=>s!=null).map(([s,r])=>`${s}="${r}"`).join(" ");return`<${e} ${i}/>`}).join("")}function E(n,e=18){return zt`<svg
876
+ */const Ei=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];function Pi(n){return n.map(([e,t])=>{const i=Object.entries(t).filter(([,s])=>s!=null).map(([s,r])=>`${s}="${r}"`).join(" ");return`<${e} ${i}/>`}).join("")}function C(n,e=18){return Ht`<svg
867
877
  xmlns="http://www.w3.org/2000/svg"
868
878
  width="${e}"
869
879
  height="${e}"
@@ -873,7 +883,7 @@
873
883
  stroke-width="2"
874
884
  stroke-linecap="round"
875
885
  stroke-linejoin="round"
876
- >${pi(yi(n))}</svg>`}const K=S`
886
+ >${mi(Pi(n))}</svg>`}const K=A`
877
887
  * {
878
888
  box-sizing: border-box;
879
889
  margin: 0;
@@ -916,7 +926,7 @@
916
926
  --pw-shadow: var(--pulse-shadow);
917
927
  --pw-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
918
928
  }
919
- `,le=S`
929
+ `,le=A`
920
930
  .pw-btn {
921
931
  display: inline-flex;
922
932
  align-items: center;
@@ -960,7 +970,7 @@
960
970
  width: 18px;
961
971
  height: 18px;
962
972
  }
963
- `,ve=S`
973
+ `,xe=A`
964
974
  .pw-scrollable::-webkit-scrollbar {
965
975
  width: 4px;
966
976
  }
@@ -971,12 +981,12 @@
971
981
  .pw-scrollable::-webkit-scrollbar-track {
972
982
  background: transparent;
973
983
  }
974
- `;var wi=Object.defineProperty,$i=Object.getOwnPropertyDescriptor,Ie=(n,e,t,i)=>{for(var s=i>1?void 0:i?$i(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&wi(e,t,s),s};let F=class extends P{constructor(){super(...arguments),this.items=[],this.unsubs=[],this.counter=0}connectedCallback(){super.connectedCallback(),this.setupListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unsubs.forEach(n=>n()),this.unsubs=[]}updated(n){n.has("client")&&this.client&&(this.unsubs.forEach(e=>e()),this.unsubs=[],this.setupListeners())}setupListeners(){if(!this.client)return;const n=this.client.state.activityLogs;n.length>0&&(this.items=n.map(e=>this.logToItem(e)),this.counter=this.items.length),this.unsubs.push(this.client.state.on("activity-logs",e=>{this.items=e.map(t=>this.logToItem(t))}))}logToItem(n){return{id:n.id,type:n.type,userId:n.userId,description:n.description,timestamp:new Date(n.createdAt).getTime(),color:F.TYPE_COLORS[n.type]??"#94a3b8"}}getUserName(n){var e;return((e=this.client.state.getUser(n))==null?void 0:e.name)??"Someone"}formatRelativeTime(n){const e=Math.floor((Date.now()-n)/1e3);return e<5?"just now":e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:`${Math.floor(e/3600)}h ago`}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}render(){return d`
984
+ `;var _i=Object.defineProperty,Ti=Object.getOwnPropertyDescriptor,Le=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ti(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&_i(e,t,s),s};let F=class extends _{constructor(){super(...arguments),this.items=[],this.unsubs=[],this.counter=0}connectedCallback(){super.connectedCallback(),this.setupListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unsubs.forEach(n=>n()),this.unsubs=[]}updated(n){n.has("client")&&this.client&&(this.unsubs.forEach(e=>e()),this.unsubs=[],this.setupListeners())}setupListeners(){if(!this.client)return;const n=this.client.state.activityLogs;n.length>0&&(this.items=n.map(e=>this.logToItem(e)),this.counter=this.items.length),this.unsubs.push(this.client.state.on("activity-logs",e=>{this.items=e.map(t=>this.logToItem(t))}))}logToItem(n){return{id:n.id,type:n.type,userId:n.userId,description:n.description,timestamp:new Date(n.createdAt).getTime(),color:F.TYPE_COLORS[n.type]??"#94a3b8"}}getUserName(n){var e;return((e=this.client.state.getUser(n))==null?void 0:e.name)??"Someone"}formatRelativeTime(n){const e=Math.floor((Date.now()-n)/1e3);return e<5?"just now":e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:`${Math.floor(e/3600)}h ago`}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}render(){return d`
975
985
  <div class="panel">
976
986
  <div class="panel-header">
977
987
  <span class="panel-title">Activity</span>
978
988
  <button class="close-btn" @click=${this.fireClose} title="Close">
979
- ${E(ae,16)}
989
+ ${C(ae,16)}
980
990
  </button>
981
991
  </div>
982
992
 
@@ -1002,7 +1012,7 @@
1002
1012
  `)}
1003
1013
  </div>
1004
1014
  </div>
1005
- `}};F.styles=[K,le,ve,S`
1015
+ `}};F.styles=[K,le,xe,A`
1006
1016
  :host {
1007
1017
  display: block;
1008
1018
  }
@@ -1118,36 +1128,142 @@
1118
1128
  border-radius: 16px 16px 0 0;
1119
1129
  }
1120
1130
  }
1121
- `];F.TYPE_COLORS={join:"#22c55e",leave:"#94a3b8",thread:"var(--pw-accent, #6366f1)",comment:"#3b82f6",resolve:"#22c55e"};Ie([m({attribute:!1})],F.prototype,"client",2);Ie([b()],F.prototype,"items",2);F=Ie([I("pulse-widget-activity-panel")],F);const ki="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Ke="#6366f1",Ge="#e2e8f0",Ci="#f8fafc",Pi="#e2e8f0",Je="#64748b",pe=28,_i=Array.from({length:pe},(n,e)=>.2+Math.abs(Math.sin(e*12.9898+78.233)*43758.5453)%1*.8);function Ze(n){const e=Math.max(0,Math.floor(n)),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}class Pe{static render(e,t){let i=!1,s=t!=null?t/1e3:0,r=0;const o=document.createElement("audio");o.preload="metadata",o.src=e;const l=document.createElement("div");Object.assign(l.style,{display:"inline-flex",alignItems:"center",gap:"10px",width:"220px",height:"44px",padding:"0 10px",background:Ci,borderRadius:"12px",border:`1px solid ${Pi}`,fontFamily:ki,fontSize:"11px",color:Je,userSelect:"none",boxSizing:"border-box"});const a=document.createElement("button");Object.assign(a.style,{width:"28px",height:"28px",minWidth:"28px",borderRadius:"50%",border:"none",background:Ke,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",outline:"none",flexShrink:"0"});const c=document.createElement("span");Object.assign(c.style,{display:"block",width:"10px",height:"12px",lineHeight:"0"});function p(){c.innerHTML=`<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
1131
+ `];F.TYPE_COLORS={join:"#22c55e",leave:"#94a3b8",thread:"var(--pw-accent, #6366f1)",comment:"#3b82f6",resolve:"#22c55e"};Le([g({attribute:!1})],F.prototype,"client",2);Le([v()],F.prototype,"items",2);F=Le([O("pulse-widget-activity-panel")],F);const Si="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Je="#6366f1",Ze="#e2e8f0",Ai="#f8fafc",Mi="#e2e8f0",Qe="#64748b",he=28,Ii=Array.from({length:he},(n,e)=>.2+Math.abs(Math.sin(e*12.9898+78.233)*43758.5453)%1*.8);function et(n){const e=Math.max(0,Math.floor(n)),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}class Pe{static render(e,t){let i=!1,s=t!=null?t/1e3:0,r=0;const o=document.createElement("audio");o.preload="metadata",o.src=e;const l=document.createElement("div");Object.assign(l.style,{display:"inline-flex",alignItems:"center",gap:"10px",width:"220px",height:"44px",padding:"0 10px",background:Ai,borderRadius:"12px",border:`1px solid ${Mi}`,fontFamily:Si,fontSize:"11px",color:Qe,userSelect:"none",boxSizing:"border-box"});const a=document.createElement("button");Object.assign(a.style,{width:"28px",height:"28px",minWidth:"28px",borderRadius:"50%",border:"none",background:Je,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",outline:"none",flexShrink:"0"});const c=document.createElement("span");Object.assign(c.style,{display:"block",width:"10px",height:"12px",lineHeight:"0"});function h(){c.innerHTML=`<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
1122
1132
  <path d="M1 1L9 6L1 11V1Z" fill="white" stroke="white" stroke-width="1" stroke-linejoin="round"/>
1123
- </svg>`}function h(){c.innerHTML=`<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
1133
+ </svg>`}function p(){c.innerHTML=`<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
1124
1134
  <rect x="1" y="1" width="2.5" height="10" rx="0.5" fill="white"/>
1125
1135
  <rect x="6.5" y="1" width="2.5" height="10" rx="0.5" fill="white"/>
1126
- </svg>`}p(),a.appendChild(c);const f=document.createElement("div");Object.assign(f.style,{flex:"1",display:"flex",flexDirection:"column",gap:"3px",overflow:"hidden",minWidth:"0"});const g=document.createElement("div");Object.assign(g.style,{display:"flex",alignItems:"center",gap:"1.5px",height:"22px",cursor:"pointer"});const $=[];for(let y=0;y<pe;y++){const T=document.createElement("div"),v=Math.round(_i[y]*20);Object.assign(T.style,{flex:"1",height:`${Math.max(3,v)}px`,borderRadius:"1px",background:Ge,transition:"background 0.1s ease",minWidth:"0"}),$.push(T),g.appendChild(T)}const A=document.createElement("div");Object.assign(A.style,{fontSize:"10px",color:Je,whiteSpace:"nowrap",lineHeight:"1"});function k(){const y=Ze(r),T=Ze(s);A.textContent=`${y} / ${T}`}k(),f.appendChild(g),f.appendChild(A),l.appendChild(a),l.appendChild(f);function w(){const y=s>0?r/s:0,T=Math.floor(y*pe);for(let v=0;v<pe;v++)$[v].style.background=v<=T?Ke:Ge}return g.addEventListener("click",y=>{if(s<=0)return;const T=g.getBoundingClientRect(),v=Math.min(1,Math.max(0,(y.clientX-T.left)/T.width));o.currentTime=v*s,r=o.currentTime,w(),k()}),a.addEventListener("click",()=>{i?o.pause():o.play().catch(()=>{})}),o.addEventListener("play",()=>{i=!0,h()}),o.addEventListener("pause",()=>{i=!1,p()}),o.addEventListener("ended",()=>{i=!1,p(),r=0,w(),k()}),o.addEventListener("timeupdate",()=>{r=o.currentTime,w(),k()}),o.addEventListener("loadedmetadata",()=>{o.duration&&isFinite(o.duration)&&(s=o.duration,k())}),o.addEventListener("durationchange",()=>{o.duration&&isFinite(o.duration)&&(s=o.duration,k())}),l}}const Qe=80,Ei="#e2e8f0",Ti=`
1136
+ </svg>`}h(),a.appendChild(c);const m=document.createElement("div");Object.assign(m.style,{flex:"1",display:"flex",flexDirection:"column",gap:"3px",overflow:"hidden",minWidth:"0"});const f=document.createElement("div");Object.assign(f.style,{display:"flex",alignItems:"center",gap:"1.5px",height:"22px",cursor:"pointer"});const b=[];for(let $=0;$<he;$++){const S=document.createElement("div"),x=Math.round(Ii[$]*20);Object.assign(S.style,{flex:"1",height:`${Math.max(3,x)}px`,borderRadius:"1px",background:Ze,transition:"background 0.1s ease",minWidth:"0"}),b.push(S),f.appendChild(S)}const y=document.createElement("div");Object.assign(y.style,{fontSize:"10px",color:Qe,whiteSpace:"nowrap",lineHeight:"1"});function E(){const $=et(r),S=et(s);y.textContent=`${$} / ${S}`}E(),m.appendChild(f),m.appendChild(y),l.appendChild(a),l.appendChild(m);function k(){const $=s>0?r/s:0,S=Math.floor($*he);for(let x=0;x<he;x++)b[x].style.background=x<=S?Je:Ze}return f.addEventListener("click",$=>{if(s<=0)return;const S=f.getBoundingClientRect(),x=Math.min(1,Math.max(0,($.clientX-S.left)/S.width));o.currentTime=x*s,r=o.currentTime,k(),E()}),a.addEventListener("click",()=>{i?o.pause():o.play().catch(()=>{})}),o.addEventListener("play",()=>{i=!0,p()}),o.addEventListener("pause",()=>{i=!1,h()}),o.addEventListener("ended",()=>{i=!1,h(),r=0,k(),E()}),o.addEventListener("timeupdate",()=>{r=o.currentTime,k(),E()}),o.addEventListener("loadedmetadata",()=>{o.duration&&isFinite(o.duration)&&(s=o.duration,E())}),o.addEventListener("durationchange",()=>{o.duration&&isFinite(o.duration)&&(s=o.duration,E())}),l}}class _e{constructor(){this.container=null,this.stream=null,this.recorder=null,this.analyser=null,this.audioCtx=null,this.recording=!1,this.animFrame=null,this.startTime=0,this.maxDuration=12e4,this.maxTimer=null,this.canvas=null,this.timerEl=null,this.resolve=null,this.animate=()=>{this.recording&&(this.drawWaveform(),this.updateTimer(),this.animFrame=requestAnimationFrame(this.animate))}}async startRecording(e){this.destroy(),this.stream=await navigator.mediaDevices.getUserMedia({audio:!0}),this.audioCtx=new AudioContext;const t=this.audioCtx.createMediaStreamSource(this.stream);this.analyser=this.audioCtx.createAnalyser(),this.analyser.fftSize=64,t.connect(this.analyser);const i=this.detectMimeType(),s={};i&&(s.mimeType=i),this.recorder=new MediaRecorder(this.stream,s);const r=[];this.recorder.ondataavailable=l=>{l.data.size>0&&r.push(l.data)},this.buildUI(e);const o=new Promise(l=>{this.resolve=l});return this.recorder.onstop=()=>{var c,h;const l=((c=this.recorder)==null?void 0:c.mimeType)||i||"audio/webm",a=new Blob(r,{type:l});(h=this.resolve)==null||h.call(this,a),this.resolve=null,this.cleanupResources()},this.recorder.start(),this.recording=!0,this.startTime=Date.now(),this.maxTimer=setTimeout(()=>{this.stopRecording()},this.maxDuration),this.animate(),o}stopRecording(){!this.recording||!this.recorder||(this.recording=!1,this.recorder.state==="recording"&&this.recorder.stop())}cancelRecording(){var e;this.recorder&&(this.recording=!1,this.recorder.ondataavailable=null,this.recorder.onstop=null,this.recorder.state==="recording"&&this.recorder.stop(),(e=this.resolve)==null||e.call(this,null),this.resolve=null,this.cleanupResources())}destroy(){this.cancelRecording(),this.cleanupResources()}detectMimeType(){if(typeof MediaRecorder.isTypeSupported=="function"){if(MediaRecorder.isTypeSupported("audio/webm;codecs=opus"))return"audio/webm;codecs=opus";if(MediaRecorder.isTypeSupported("audio/webm"))return"audio/webm";if(MediaRecorder.isTypeSupported("audio/mp4;codecs=mp4a.40.2"))return"audio/mp4;codecs=mp4a.40.2";if(MediaRecorder.isTypeSupported("audio/mp4"))return"audio/mp4"}}buildUI(e){this.container=document.createElement("div"),this.container.className="pulse-audio-recorder",Object.assign(this.container.style,{display:"flex",alignItems:"center",gap:"10px",padding:"8px 12px",background:"#ffffff",borderRadius:"12px",boxShadow:"0 2px 12px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.06)",border:"1px solid #e2e8f0",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:"13px",width:"fit-content"});const t=document.createElement("button");t.title="Cancel",t.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',Object.assign(t.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",background:"none",cursor:"pointer",color:"#64748b",borderRadius:"6px",padding:"0",transition:"background 0.15s, color 0.15s",flexShrink:"0"}),t.addEventListener("mouseenter",()=>{t.style.background="#f1f5f9",t.style.color="#0f172a"}),t.addEventListener("mouseleave",()=>{t.style.background="none",t.style.color="#64748b"}),t.addEventListener("click",()=>this.cancelRecording()),this.container.appendChild(t),this.canvas=document.createElement("canvas"),this.canvas.width=200,this.canvas.height=40,Object.assign(this.canvas.style,{display:"block",borderRadius:"4px",flexShrink:"0"}),this.container.appendChild(this.canvas),this.timerEl=document.createElement("span"),this.timerEl.textContent="00:00",Object.assign(this.timerEl.style,{color:"#ef4444",fontWeight:"600",fontSize:"13px",fontVariantNumeric:"tabular-nums",minWidth:"40px",flexShrink:"0"}),this.container.appendChild(this.timerEl);const i=document.createElement("button");i.title="Stop recording",i.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>',Object.assign(i.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"#ef4444",cursor:"pointer",color:"#ffffff",borderRadius:"50%",padding:"0",transition:"background 0.15s, transform 0.15s",flexShrink:"0"}),i.addEventListener("mouseenter",()=>{i.style.background="#dc2626",i.style.transform="scale(1.08)"}),i.addEventListener("mouseleave",()=>{i.style.background="#ef4444",i.style.transform="scale(1)"}),i.addEventListener("click",()=>this.stopRecording()),this.container.appendChild(i),e.appendChild(this.container)}drawWaveform(){if(!this.canvas||!this.analyser)return;const e=this.canvas.getContext("2d");if(!e)return;const t=this.canvas.width,i=this.canvas.height,s=this.analyser.frequencyBinCount,r=new Uint8Array(s);this.analyser.getByteFrequencyData(r),e.clearRect(0,0,t,i);const o=s,l=Math.max(2,t/o*.7),a=(t-l*o)/(o-1||1);for(let c=0;c<o;c++){const h=r[c]/255,p=Math.max(2,h*i*.85),m=c*(l+a),f=(i-p)/2,b=.4+h*.6;e.fillStyle=`rgba(99, 102, 241, ${b})`,e.beginPath(),e.roundRect(m,f,l,p,1),e.fill()}}updateTimer(){if(!this.timerEl)return;const e=Date.now()-this.startTime,t=Math.floor(e/1e3),i=Math.floor(t/60),s=t%60;this.timerEl.textContent=`${String(i).padStart(2,"0")}:${String(s).padStart(2,"0")}`}cleanupResources(){if(this.animFrame!==null&&(cancelAnimationFrame(this.animFrame),this.animFrame=null),this.maxTimer!==null&&(clearTimeout(this.maxTimer),this.maxTimer=null),this.audioCtx&&(this.audioCtx.close().catch(()=>{}),this.audioCtx=null),this.analyser=null,this.stream){for(const e of this.stream.getTracks())e.stop();this.stream=null}this.recorder=null,this.container&&(this.container.remove(),this.container=null),this.canvas=null,this.timerEl=null}}const tt=80,Oi="#e2e8f0",Ri=`
1127
1137
  <svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
1128
1138
  <circle cx="14" cy="14" r="14" fill="rgba(0,0,0,0.35)"/>
1129
1139
  <polygon points="11,8 22,14 11,20" fill="rgba(255,255,255,0.9)"/>
1130
- </svg>`,et=`
1140
+ </svg>`,it=`
1131
1141
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.9)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
1132
1142
  <polygon points="11,5 6,9 2,9 2,15 6,15 11,19"/>
1133
1143
  <line x1="23" y1="9" x2="17" y2="15"/>
1134
1144
  <line x1="17" y1="9" x2="23" y2="15"/>
1135
- </svg>`,Si=`
1145
+ </svg>`,Li=`
1136
1146
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.9)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
1137
1147
  <polygon points="11,5 6,9 2,9 2,15 6,15 11,19"/>
1138
1148
  <path d="M19.07 4.93a10 10 0 0 1 0 14.14"/>
1139
1149
  <path d="M15.54 8.46a5 5 0 0 1 0 7.07"/>
1140
- </svg>`;class mt{static render(e,t){let i=!1,s=!0;const r=document.createElement("div");Object.assign(r.style,{position:"relative",display:"inline-block",width:`${Qe}px`,height:`${Qe}px`,borderRadius:"50%",border:`2px solid ${Ei}`,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden",cursor:"pointer",flexShrink:"0",userSelect:"none",WebkitUserSelect:"none"});const o=document.createElement("video");Object.assign(o.style,{width:"100%",height:"100%",objectFit:"cover",display:"block",borderRadius:"50%"}),o.src=e,o.loop=!0,o.muted=!0,o.playsInline=!0,o.preload="metadata",t&&(o.poster=t),r.appendChild(o);const l=document.createElement("div");Object.assign(l.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",transition:"opacity 0.25s ease",opacity:"1",pointerEvents:"none"}),l.innerHTML=Ti,r.appendChild(l);const a=document.createElement("div");Object.assign(a.style,{position:"absolute",bottom:"2px",right:"2px",width:"22px",height:"22px",borderRadius:"50%",background:"rgba(0,0,0,0.45)",display:"none",alignItems:"center",justifyContent:"center",pointerEvents:"none",transition:"opacity 0.2s ease"}),a.innerHTML=et,r.appendChild(a);function c(){l.style.opacity=i?"0":"1"}function p(){a.style.display=i?"flex":"none",a.innerHTML=s?et:Si}return r.addEventListener("click",h=>{h.stopPropagation(),i?s?(o.muted=!1,s=!1):(o.pause(),i=!1,s=!0,o.muted=!0):(o.muted=!0,s=!0,o.play().catch(()=>{}),i=!0),c(),p()}),o.addEventListener("pause",()=>{i&&(i=!1,s=!0,o.muted=!0,c(),p())}),r}}const C=class C{static open(e){C.close();const t=document.createElement("div");t.id="pulse-widget-lightbox",Object.assign(t.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"100000",background:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",opacity:"0",transition:"opacity 200ms ease",cursor:"pointer",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const i=document.createElement("button");i.textContent="×",Object.assign(i.style,{position:"absolute",top:"16px",right:"16px",width:"40px",height:"40px",border:"none",borderRadius:"50%",background:"rgba(255,255,255,0.15)",color:"#fff",fontSize:"24px",lineHeight:"40px",textAlign:"center",cursor:"pointer",padding:"0",fontFamily:"inherit",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 150ms ease"}),i.addEventListener("mouseenter",()=>{i.style.background="rgba(255,255,255,0.3)"}),i.addEventListener("mouseleave",()=>{i.style.background="rgba(255,255,255,0.15)"}),i.addEventListener("click",o=>{o.stopPropagation(),C.close()});const s=document.createElement("img");s.src=e,s.alt="Lightbox image",Object.assign(s.style,{maxWidth:"90vw",maxHeight:"90vh",borderRadius:"8px",objectFit:"contain",cursor:"default",userSelect:"none"}),s.addEventListener("click",o=>{o.stopPropagation()}),t.appendChild(i),t.appendChild(s),t.addEventListener("click",()=>{C.close()});const r=o=>{o.key==="Escape"&&C.close()};document.addEventListener("keydown",r),C.overlay=t,C.onKeyDown=r,document.body.appendChild(t),requestAnimationFrame(()=>{t.style.opacity="1"})}static close(){if(!C.overlay)return;const e=C.overlay;C.onKeyDown&&(document.removeEventListener("keydown",C.onKeyDown),C.onKeyDown=null),e.style.opacity="0",e.addEventListener("transitionend",()=>{e.remove()}),C.overlay=null}};C.overlay=null,C.onKeyDown=null;let me=C;const Ai=["👍","👎","❤️","🎉","👀","🚀"],ce="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Mi='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>',Oi='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',tt=`<button class="pulse-close-btn" style="
1150
+ </svg>`;class xt{static render(e,t){let i=!1,s=!0;const r=document.createElement("div");Object.assign(r.style,{position:"relative",display:"inline-block",width:`${tt}px`,height:`${tt}px`,borderRadius:"50%",border:`2px solid ${Oi}`,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden",cursor:"pointer",flexShrink:"0",userSelect:"none",WebkitUserSelect:"none"});const o=document.createElement("video");Object.assign(o.style,{width:"100%",height:"100%",objectFit:"cover",display:"block",borderRadius:"50%"}),o.src=e,o.loop=!0,o.muted=!0,o.playsInline=!0,o.preload="metadata",t&&(o.poster=t),r.appendChild(o);const l=document.createElement("div");Object.assign(l.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",transition:"opacity 0.25s ease",opacity:"1",pointerEvents:"none"}),l.innerHTML=Ri,r.appendChild(l);const a=document.createElement("div");Object.assign(a.style,{position:"absolute",bottom:"2px",right:"2px",width:"22px",height:"22px",borderRadius:"50%",background:"rgba(0,0,0,0.45)",display:"none",alignItems:"center",justifyContent:"center",pointerEvents:"none",transition:"opacity 0.2s ease"}),a.innerHTML=it,r.appendChild(a);function c(){l.style.opacity=i?"0":"1"}function h(){a.style.display=i?"flex":"none",a.innerHTML=s?it:Li}return r.addEventListener("click",p=>{p.stopPropagation(),i?s?(o.muted=!1,s=!1):(o.pause(),i=!1,s=!0,o.muted=!0):(o.muted=!0,s=!0,o.play().catch(()=>{}),i=!0),c(),h()}),o.addEventListener("pause",()=>{i&&(i=!1,s=!0,o.muted=!0,c(),h())}),r}}const st=60,ji=`
1151
+ .vr-overlay {
1152
+ display: flex;
1153
+ flex-direction: column;
1154
+ align-items: center;
1155
+ gap: 12px;
1156
+ padding: 16px;
1157
+ background: #ffffff;
1158
+ border-radius: 16px;
1159
+ box-shadow: 0 8px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
1160
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1161
+ user-select: none;
1162
+ }
1163
+
1164
+ .vr-circle-wrapper {
1165
+ position: relative;
1166
+ width: 136px;
1167
+ height: 136px;
1168
+ display: flex;
1169
+ align-items: center;
1170
+ justify-content: center;
1171
+ }
1172
+
1173
+ .vr-ring {
1174
+ position: absolute;
1175
+ inset: 0;
1176
+ border-radius: 50%;
1177
+ border: 3px solid #ef4444;
1178
+ animation: vr-pulse 1.5s ease-in-out infinite;
1179
+ }
1180
+
1181
+ @keyframes vr-pulse {
1182
+ 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
1183
+ 50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
1184
+ }
1185
+
1186
+ .vr-video-circle {
1187
+ width: 120px;
1188
+ height: 120px;
1189
+ border-radius: 50%;
1190
+ overflow: hidden;
1191
+ background: #0f172a;
1192
+ position: relative;
1193
+ }
1194
+
1195
+ .vr-video-circle video {
1196
+ width: 100%;
1197
+ height: 100%;
1198
+ object-fit: cover;
1199
+ transform: scaleX(-1);
1200
+ }
1201
+
1202
+ .vr-timer {
1203
+ font-size: 14px;
1204
+ font-weight: 600;
1205
+ color: #0f172a;
1206
+ font-variant-numeric: tabular-nums;
1207
+ letter-spacing: 0.02em;
1208
+ }
1209
+
1210
+ .vr-countdown {
1211
+ color: #ef4444;
1212
+ }
1213
+
1214
+ .vr-actions {
1215
+ display: flex;
1216
+ align-items: center;
1217
+ gap: 12px;
1218
+ }
1219
+
1220
+ .vr-btn {
1221
+ display: inline-flex;
1222
+ align-items: center;
1223
+ justify-content: center;
1224
+ border: none;
1225
+ cursor: pointer;
1226
+ font-family: inherit;
1227
+ font-size: 13px;
1228
+ font-weight: 600;
1229
+ padding: 8px 18px;
1230
+ border-radius: 8px;
1231
+ transition: all 0.15s ease;
1232
+ }
1233
+
1234
+ .vr-btn:active {
1235
+ transform: scale(0.95);
1236
+ }
1237
+
1238
+ .vr-btn-stop {
1239
+ background: #ef4444;
1240
+ color: #fff;
1241
+ }
1242
+
1243
+ .vr-btn-stop:hover {
1244
+ background: #dc2626;
1245
+ }
1246
+
1247
+ .vr-btn-cancel {
1248
+ background: #f1f5f9;
1249
+ color: #64748b;
1250
+ }
1251
+
1252
+ .vr-btn-cancel:hover {
1253
+ background: #e2e8f0;
1254
+ color: #0f172a;
1255
+ }
1256
+ `;function nt(n){return n.toString().padStart(2,"0")}function zi(n){const e=Math.floor(n/60),t=n%60;return`${nt(e)}:${nt(t)}`}function Ui(){const n=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"];for(const e of n)if(MediaRecorder.isTypeSupported(e))return e;return""}function Di(n){return new Promise((e,t)=>{const i=URL.createObjectURL(n),s=document.createElement("video");s.muted=!0,s.playsInline=!0,s.preload="auto",s.src=i,s.addEventListener("loadeddata",()=>{s.currentTime=.01}),s.addEventListener("seeked",()=>{const r=document.createElement("canvas");r.width=s.videoWidth||240,r.height=s.videoHeight||240,r.getContext("2d").drawImage(s,0,0,r.width,r.height),URL.revokeObjectURL(i),r.toBlob(l=>{l?e(l):t(new Error("Failed to generate poster frame"))},"image/jpeg",.85)}),s.addEventListener("error",()=>{URL.revokeObjectURL(i),t(new Error("Failed to load video for poster generation"))}),s.load()})}class Ni{constructor(){this.recording=!1,this.container=null,this.stream=null,this.mediaRecorder=null,this.chunks=[],this.timerInterval=null,this.elapsed=0,this.resolvePromise=null,this.root=null,this.styleEl=null,this.videoEl=null,this.timerEl=null}async startRecording(e){if(this.recording)return null;let t;try{t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0})}catch{return null}this.stream=t,this.container=e,this.recording=!0,this.elapsed=0,this.chunks=[],this.buildUI(e),this.videoEl&&(this.videoEl.srcObject=t,this.videoEl.play().catch(()=>{}));const i=Ui(),s={};i&&(s.mimeType=i);const r=new MediaRecorder(t,s);return this.mediaRecorder=r,r.ondataavailable=o=>{o.data.size>0&&this.chunks.push(o.data)},r.onstop=()=>{this.handleRecordingComplete()},r.start(),this.timerInterval=setInterval(()=>{this.elapsed++,this.updateTimer(),this.elapsed>=st&&this.stopRecording()},1e3),new Promise(o=>{this.resolvePromise=o})}stopRecording(){!this.recording||!this.mediaRecorder||this.mediaRecorder.state==="recording"&&this.mediaRecorder.stop()}cancelRecording(){var e;this.cleanup(),(e=this.resolvePromise)==null||e.call(this,null),this.resolvePromise=null}destroy(){this.cancelRecording()}buildUI(e){this.styleEl=document.createElement("style"),this.styleEl.textContent=ji,document.head.appendChild(this.styleEl),this.root=document.createElement("div"),this.root.className="vr-overlay";const t=document.createElement("div");t.className="vr-circle-wrapper";const i=document.createElement("div");i.className="vr-ring",t.appendChild(i);const s=document.createElement("div");s.className="vr-video-circle",this.videoEl=document.createElement("video"),this.videoEl.muted=!0,this.videoEl.playsInline=!0,this.videoEl.setAttribute("playsinline",""),s.appendChild(this.videoEl),t.appendChild(s),this.root.appendChild(t),this.timerEl=document.createElement("span"),this.timerEl.className="vr-timer",this.timerEl.textContent="00:00",this.root.appendChild(this.timerEl);const r=document.createElement("div");r.className="vr-actions";const o=document.createElement("button");o.className="vr-btn vr-btn-stop",o.textContent="Stop",o.addEventListener("click",()=>this.stopRecording()),r.appendChild(o);const l=document.createElement("button");l.className="vr-btn vr-btn-cancel",l.textContent="Cancel",l.addEventListener("click",()=>this.cancelRecording()),r.appendChild(l),this.root.appendChild(r),e.appendChild(this.root)}updateTimer(){if(!this.timerEl)return;const e=st-this.elapsed;this.timerEl.textContent=zi(this.elapsed),e<=10?this.timerEl.classList.add("vr-countdown"):this.timerEl.classList.remove("vr-countdown")}async handleRecordingComplete(){var s,r;const e=((s=this.mediaRecorder)==null?void 0:s.mimeType)||"video/webm",t=new Blob(this.chunks,{type:e});let i;try{i=await Di(t)}catch{const o=document.createElement("canvas");o.width=1,o.height=1,i=await new Promise(l=>{o.toBlob(a=>l(a),"image/png")})}this.cleanup(),(r=this.resolvePromise)==null||r.call(this,{blob:t,posterBlob:i}),this.resolvePromise=null}cleanup(){if(this.recording=!1,this.timerInterval&&(clearInterval(this.timerInterval),this.timerInterval=null),this.mediaRecorder&&this.mediaRecorder.state!=="inactive")try{this.mediaRecorder.stop()}catch{}if(this.mediaRecorder=null,this.stream){for(const e of this.stream.getTracks())e.stop();this.stream=null}this.videoEl&&(this.videoEl.srcObject=null,this.videoEl=null),this.root&&this.root.parentElement&&this.root.parentElement.removeChild(this.root),this.root=null,this.styleEl&&this.styleEl.parentElement&&this.styleEl.parentElement.removeChild(this.styleEl),this.styleEl=null,this.chunks=[],this.elapsed=0}}const P=class P{static open(e){P.close();const t=document.createElement("div");t.id="pulse-widget-lightbox",Object.assign(t.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"100000",background:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",opacity:"0",transition:"opacity 200ms ease",cursor:"pointer",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const i=document.createElement("button");i.textContent="×",Object.assign(i.style,{position:"absolute",top:"16px",right:"16px",width:"40px",height:"40px",border:"none",borderRadius:"50%",background:"rgba(255,255,255,0.15)",color:"#fff",fontSize:"24px",lineHeight:"40px",textAlign:"center",cursor:"pointer",padding:"0",fontFamily:"inherit",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 150ms ease"}),i.addEventListener("mouseenter",()=>{i.style.background="rgba(255,255,255,0.3)"}),i.addEventListener("mouseleave",()=>{i.style.background="rgba(255,255,255,0.15)"}),i.addEventListener("click",o=>{o.stopPropagation(),P.close()});const s=document.createElement("img");s.src=e,s.alt="Lightbox image",Object.assign(s.style,{maxWidth:"90vw",maxHeight:"90vh",borderRadius:"8px",objectFit:"contain",cursor:"default",userSelect:"none"}),s.addEventListener("click",o=>{o.stopPropagation()}),t.appendChild(i),t.appendChild(s),t.addEventListener("click",()=>{P.close()});const r=o=>{o.key==="Escape"&&P.close()};document.addEventListener("keydown",r),P.overlay=t,P.onKeyDown=r,document.body.appendChild(t),requestAnimationFrame(()=>{t.style.opacity="1"})}static close(){if(!P.overlay)return;const e=P.overlay;P.onKeyDown&&(document.removeEventListener("keydown",P.onKeyDown),P.onKeyDown=null),e.style.opacity="0",e.addEventListener("transitionend",()=>{e.remove()}),P.overlay=null}};P.overlay=null,P.onKeyDown=null;let me=P;class ge{constructor(e){this.uploading=!1,this.client=e,this.input=document.createElement("input"),this.input.type="file",this.input.style.display="none",document.body.appendChild(this.input)}pickFile(e){return new Promise(t=>{this.input.accept=e,this.input.value="";const i=()=>{r(),t(null)},s=async()=>{var l;r();const o=(l=this.input.files)==null?void 0:l[0];if(!o){t(null);return}this.uploading=!0;try{const a=await this.client.uploadFile(o);t(a)}catch{t(null)}finally{this.uploading=!1}},r=()=>{this.input.removeEventListener("change",s),this.input.removeEventListener("cancel",i)};this.input.addEventListener("change",s,{once:!0}),this.input.addEventListener("cancel",i,{once:!0}),this.input.click()})}async uploadBlob(e,t){this.uploading=!0;try{const i=new File([e],t,{type:e.type});return await this.client.uploadFile(i)}catch{return null}finally{this.uploading=!1}}destroy(){this.input.remove()}}const Hi=["👍","👎","❤️","🎉","👀","🚀"],ce="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Bi='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>',Fi='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',ot=`<button class="pulse-close-btn" style="
1141
1257
  border:none;background:none;cursor:pointer;color:#94a3b8;padding:4px;
1142
1258
  border-radius:6px;display:flex;align-items:center;justify-content:center;
1143
1259
  transition:all 0.15s;flex-shrink:0;
1144
1260
  " onmouseover="this.style.background='#f1f5f9';this.style.color='#0f172a'"
1145
1261
  onmouseout="this.style.background='none';this.style.color='#94a3b8'">
1146
1262
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
1147
- </button>`;class Ii{constructor(e,t={}){this.container=null,this.overlay=null,this.form=null,this.popover=null,this.threads=[],this.pinEls=new Map,this._pinModeActive=!1,this.editingPopoverCommentId=null,this.popoverPickerOpen=null,this.lastTypingSendPins=new Map,this.repositionDebounce=null,this.mutationObserver=null,this.handleReposition=()=>{this.repositionDebounce||(this.repositionDebounce=setTimeout(()=>{this.repositionDebounce=null,this.renderPins()},200))},this.handleEscape=i=>{i.key==="Escape"&&this.exitPinMode()},this.handlePopoverEscape=i=>{i.key==="Escape"&&this.closePopover()},this.handlePopoverOutsideClick=i=>{var s,r;if(this.popover&&!this.popover.contains(i.target)){if((s=this.container)!=null&&s.contains(i.target)||(r=this.pickerEl)!=null&&r.contains(i.target))return;this.closePopover()}},this.handleOverlayClick=i=>{this.form&&(this.form.remove(),this.form=null);const s=window.innerWidth,r=window.innerHeight,o={x:i.clientX/s,y:i.clientY/r,scrollX:window.scrollX,scrollY:window.scrollY},l=this.overlay.style.pointerEvents;this.overlay.style.pointerEvents="none";const a=document.elementFromPoint(i.clientX,i.clientY);if(this.overlay.style.pointerEvents=l,a){o.selector=this.getSelector(a);const c=a.getBoundingClientRect();c.width>0&&c.height>0&&(o.elementOffsetX=(i.clientX-c.left)/c.width,o.elementOffsetY=(i.clientY-c.top)/c.height)}this.showPinForm(i.clientX,i.clientY,o)},this.pickerEl=null,this.client=e,this.onPinModeExit=t.onPinModeExit,this.init()}get pinModeActive(){return this._pinModeActive}init(){this.container=document.createElement("div"),this.container.id="pulse-widget-pins",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9997"}),document.body.appendChild(this.container),this.threads=this.client.state.threads,this.renderPins(),this.unsub=this.client.state.on("threads",e=>{if(this.threads=[...e],this.renderPins(),this.popover&&this.popover.dataset.threadId){const t=this.threads.find(i=>i.id===this.popover.dataset.threadId);t?this.refreshPopoverComments(t):this.closePopover()}}),this.reactionUnsub=this.client.state.on("reactions",()=>{if(this.popover&&this.popover.dataset.threadId){const e=this.threads.find(t=>t.id===this.popover.dataset.threadId);e&&this.refreshPopoverComments(e)}}),this.typingUnsub2=this.client.state.on("typing",()=>{this.popover&&this.popover.dataset.threadId&&this.updatePopoverTyping(this.popover.dataset.threadId)}),window.addEventListener("scroll",this.handleReposition,!0),window.addEventListener("resize",this.handleReposition),this.mutationObserver=new MutationObserver(this.handleReposition),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]})}enterPinMode(){this._pinModeActive||(this._pinModeActive=!0,this.closePopover(),this.overlay=document.createElement("div"),Object.assign(this.overlay.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"10000",cursor:"crosshair",background:"rgba(99, 102, 241, 0.04)"}),this.overlay.addEventListener("click",this.handleOverlayClick),document.addEventListener("keydown",this.handleEscape),document.body.appendChild(this.overlay))}exitPinMode(){var e,t,i;this._pinModeActive&&(this._pinModeActive=!1,(e=this.overlay)==null||e.remove(),this.overlay=null,(t=this.form)==null||t.remove(),this.form=null,document.removeEventListener("keydown",this.handleEscape),(i=this.onPinModeExit)==null||i.call(this))}setVisible(e){this.container&&(this.container.style.display=e?"":"none")}destroy(){var e,t,i,s,r,o;this.exitPinMode(),this.closePopover(),this.removePickerEl(),(e=this.unsub)==null||e.call(this),(t=this.threadUnsub)==null||t.call(this),(i=this.reactionUnsub)==null||i.call(this),(s=this.typingUnsub2)==null||s.call(this),window.removeEventListener("scroll",this.handleReposition,!0),window.removeEventListener("resize",this.handleReposition),(r=this.mutationObserver)==null||r.disconnect(),this.mutationObserver=null,this.repositionDebounce&&(clearTimeout(this.repositionDebounce),this.repositionDebounce=null),(o=this.container)==null||o.remove(),this.container=null,this.pinEls.clear()}closePopover(){var e;this.removePickerEl(),this.popoverPickerOpen=null,(e=this.popover)==null||e.remove(),this.popover=null,this.editingPopoverCommentId=null,document.removeEventListener("keydown",this.handlePopoverEscape),document.removeEventListener("pointerdown",this.handlePopoverOutsideClick)}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}getSelector(e){const t=[];let i=e;for(;i&&i!==document.body&&i!==document.documentElement;){if(i.id){t.unshift(`#${i.id}`);break}const s=i.tagName.toLowerCase(),r=[...i.classList].filter(a=>!a.startsWith("pulse-")).slice(0,2);let o=r.length>0?`${s}.${r.join(".")}`:s;const l=i.parentElement;if(l){const a=[...l.children].filter(c=>c.tagName===i.tagName);if(a.length>1){const c=a.indexOf(i)+1;o+=`:nth-child(${c})`}}if(t.unshift(o),i=i.parentElement,t.length>=4)break}return t.join(" > ")}showPinForm(e,t,i){this.form=document.createElement("div");const s=Math.min(280,window.innerWidth-32),r=120;let o=e+16,l=t-10;o+s>window.innerWidth-16&&(o=e-s-16),l+r>window.innerHeight-16&&(l=window.innerHeight-r-16),l<16&&(l=16),Object.assign(this.form.style,{position:"fixed",left:`${o}px`,top:`${l}px`,width:`${s}px`,zIndex:"10001",background:"#fff",borderRadius:"12px",boxShadow:"0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08)",border:"1px solid #e2e8f0",padding:"14px",fontFamily:ce}),this.form.innerHTML=`
1263
+ </button>`;class Wi{constructor(e,t={}){this.container=null,this.overlay=null,this.form=null,this.popover=null,this.threads=[],this.pinEls=new Map,this._pinModeActive=!1,this.editingPopoverCommentId=null,this.popoverPickerOpen=null,this.lastTypingSendPins=new Map,this.repositionDebounce=null,this.mutationObserver=null,this.upload=null,this.audioRecorder=null,this.videoRecorder=null,this.pendingAttachmentIds=[],this.handleReposition=()=>{this.repositionDebounce||(this.repositionDebounce=setTimeout(()=>{this.repositionDebounce=null,this.renderPins()},200))},this.handleEscape=i=>{i.key==="Escape"&&this.exitPinMode()},this.handlePopoverEscape=i=>{i.key==="Escape"&&this.closePopover()},this.handlePopoverOutsideClick=i=>{var s,r;if(this.popover&&!this.popover.contains(i.target)){if((s=this.container)!=null&&s.contains(i.target)||(r=this.pickerEl)!=null&&r.contains(i.target))return;this.closePopover()}},this.handleOverlayClick=i=>{this.form&&(this.form.remove(),this.form=null);const s=window.innerWidth,r=window.innerHeight,o={x:i.clientX/s,y:i.clientY/r,scrollX:window.scrollX,scrollY:window.scrollY},l=this.overlay.style.pointerEvents;this.overlay.style.pointerEvents="none";const a=document.elementFromPoint(i.clientX,i.clientY);if(this.overlay.style.pointerEvents=l,a){o.selector=this.getSelector(a);const c=a.getBoundingClientRect();c.width>0&&c.height>0&&(o.elementOffsetX=(i.clientX-c.left)/c.width,o.elementOffsetY=(i.clientY-c.top)/c.height)}this.showPinForm(i.clientX,i.clientY,o)},this.pickerEl=null,this.client=e,this.onPinModeExit=t.onPinModeExit,this.init()}get pinModeActive(){return this._pinModeActive}init(){this.container=document.createElement("div"),this.container.id="pulse-widget-pins",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9997"}),document.body.appendChild(this.container),this.threads=this.client.state.threads,this.renderPins(),this.unsub=this.client.state.on("threads",e=>{if(this.threads=[...e],this.renderPins(),this.popover&&this.popover.dataset.threadId){const t=this.threads.find(i=>i.id===this.popover.dataset.threadId);t?this.refreshPopoverComments(t):this.closePopover()}}),this.reactionUnsub=this.client.state.on("reactions",()=>{if(this.popover&&this.popover.dataset.threadId){const e=this.threads.find(t=>t.id===this.popover.dataset.threadId);e&&this.refreshPopoverComments(e)}}),this.typingUnsub2=this.client.state.on("typing",()=>{this.popover&&this.popover.dataset.threadId&&this.updatePopoverTyping(this.popover.dataset.threadId)}),window.addEventListener("scroll",this.handleReposition,!0),window.addEventListener("resize",this.handleReposition),this.mutationObserver=new MutationObserver(this.handleReposition),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]})}enterPinMode(){this._pinModeActive||(this._pinModeActive=!0,this.closePopover(),this.overlay=document.createElement("div"),Object.assign(this.overlay.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"10000",cursor:"crosshair",background:"rgba(99, 102, 241, 0.04)"}),this.overlay.addEventListener("click",this.handleOverlayClick),document.addEventListener("keydown",this.handleEscape),document.body.appendChild(this.overlay))}exitPinMode(){var e,t,i;this._pinModeActive&&(this._pinModeActive=!1,(e=this.overlay)==null||e.remove(),this.overlay=null,(t=this.form)==null||t.remove(),this.form=null,document.removeEventListener("keydown",this.handleEscape),(i=this.onPinModeExit)==null||i.call(this))}setVisible(e){this.container&&(this.container.style.display=e?"":"none")}destroy(){var e,t,i,s,r,o;this.exitPinMode(),this.closePopover(),this.removePickerEl(),(e=this.unsub)==null||e.call(this),(t=this.threadUnsub)==null||t.call(this),(i=this.reactionUnsub)==null||i.call(this),(s=this.typingUnsub2)==null||s.call(this),window.removeEventListener("scroll",this.handleReposition,!0),window.removeEventListener("resize",this.handleReposition),(r=this.mutationObserver)==null||r.disconnect(),this.mutationObserver=null,this.repositionDebounce&&(clearTimeout(this.repositionDebounce),this.repositionDebounce=null),(o=this.container)==null||o.remove(),this.container=null,this.pinEls.clear()}closePopover(){var e;this.removePickerEl(),this.popoverPickerOpen=null,(e=this.popover)==null||e.remove(),this.popover=null,this.editingPopoverCommentId=null,document.removeEventListener("keydown",this.handlePopoverEscape),document.removeEventListener("pointerdown",this.handlePopoverOutsideClick)}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}getSelector(e){const t=[];let i=e;for(;i&&i!==document.body&&i!==document.documentElement;){if(i.id){t.unshift(`#${i.id}`);break}const s=i.tagName.toLowerCase(),r=[...i.classList].filter(a=>!a.startsWith("pulse-")).slice(0,2);let o=r.length>0?`${s}.${r.join(".")}`:s;const l=i.parentElement;if(l){const a=[...l.children].filter(c=>c.tagName===i.tagName);if(a.length>1){const c=a.indexOf(i)+1;o+=`:nth-child(${c})`}}if(t.unshift(o),i=i.parentElement,t.length>=4)break}return t.join(" > ")}showPinForm(e,t,i){this.form=document.createElement("div");const s=Math.min(280,window.innerWidth-32),r=120;let o=e+16,l=t-10;o+s>window.innerWidth-16&&(o=e-s-16),l+r>window.innerHeight-16&&(l=window.innerHeight-r-16),l<16&&(l=16),Object.assign(this.form.style,{position:"fixed",left:`${o}px`,top:`${l}px`,width:`${s}px`,zIndex:"10001",background:"#fff",borderRadius:"12px",boxShadow:"0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08)",border:"1px solid #e2e8f0",padding:"14px",fontFamily:ce}),this.form.innerHTML=`
1148
1264
  <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;">
1149
1265
  <span style="font-size:13px;font-weight:600;color:#0f172a;">Add a comment here</span>
1150
- ${tt}
1266
+ ${ot}
1151
1267
  </div>
1152
1268
  <textarea
1153
1269
  placeholder="Write a comment..."
@@ -1157,26 +1273,40 @@
1157
1273
  outline:none;box-sizing:border-box;color:#0f172a;
1158
1274
  "
1159
1275
  ></textarea>
1160
- <div style="display:flex;gap:6px;margin-top:8px;justify-content:flex-end;">
1161
- <button class="pin-cancel" style="
1162
- padding:6px 14px;border:1px solid #e2e8f0;border-radius:6px;
1163
- font-size:12px;font-weight:500;cursor:pointer;background:#fff;
1164
- font-family:inherit;color:#64748b;
1165
- ">Cancel</button>
1166
- <button class="pin-submit" style="
1167
- padding:6px 14px;background:#6366f1;color:#fff;border:none;
1168
- border-radius:6px;font-size:12px;font-weight:600;cursor:pointer;
1169
- font-family:inherit;
1170
- ">Pin Comment</button>
1276
+ <div style="display:flex;align-items:center;justify-content:space-between;margin-top:8px;">
1277
+ <div style="display:flex;gap:2px;" class="media-btns">
1278
+ <button class="attach-img" title="Attach image" style="border:none;background:none;cursor:pointer;color:#94a3b8;padding:4px;border-radius:4px;display:flex;align-items:center;" onmouseover="this.style.color='#6366f1'" onmouseout="this.style.color='#94a3b8'">
1279
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>
1280
+ </button>
1281
+ <button class="attach-mic" title="Record audio" style="border:none;background:none;cursor:pointer;color:#94a3b8;padding:4px;border-radius:4px;display:flex;align-items:center;" onmouseover="this.style.color='#6366f1'" onmouseout="this.style.color='#94a3b8'">
1282
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>
1283
+ </button>
1284
+ <button class="attach-video" title="Record video" style="border:none;background:none;cursor:pointer;color:#94a3b8;padding:4px;border-radius:4px;display:flex;align-items:center;" onmouseover="this.style.color='#6366f1'" onmouseout="this.style.color='#94a3b8'">
1285
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m22 8-6 4 6 4V8Z"/><rect width="14" height="12" x="2" y="6" rx="2" ry="2"/></svg>
1286
+ </button>
1287
+ </div>
1288
+ <div style="display:flex;gap:6px;">
1289
+ <button class="pin-cancel" style="
1290
+ padding:6px 14px;border:1px solid #e2e8f0;border-radius:6px;
1291
+ font-size:12px;font-weight:500;cursor:pointer;background:#fff;
1292
+ font-family:inherit;color:#64748b;
1293
+ ">Cancel</button>
1294
+ <button class="pin-submit" style="
1295
+ padding:6px 14px;background:#6366f1;color:#fff;border:none;
1296
+ border-radius:6px;font-size:12px;font-weight:600;cursor:pointer;
1297
+ font-family:inherit;
1298
+ ">Pin Comment</button>
1299
+ </div>
1171
1300
  </div>
1172
- `;const a=this.form.querySelector("textarea"),c=this.form.querySelector(".pulse-close-btn"),p=this.form.querySelector(".pin-cancel"),h=this.form.querySelector(".pin-submit");c.addEventListener("click",()=>this.exitPinMode()),p.addEventListener("click",()=>this.exitPinMode()),h.addEventListener("click",()=>{const f=a.value.trim();if(!f)return;const g=[...f.matchAll(/@(\w+)/g)].map($=>$[1]);this.client.createThread(f,{position:i,mentions:g}),this.exitPinMode()}),a.addEventListener("keydown",f=>{f.key==="Escape"&&this.exitPinMode(),f.stopPropagation()}),document.body.appendChild(this.form),requestAnimationFrame(()=>a.focus())}showThreadPopover(e,t){this.closePopover(),this.popover=document.createElement("div"),this.popover.dataset.threadId=e.id;const i=window.innerWidth<=480,s=i?window.innerWidth:300,r=t.getBoundingClientRect();let o,l;i?(o=0,l=window.innerHeight*.4):(o=r.right+10,l=r.top-8,o+s>window.innerWidth-16&&(o=r.left-s-10),l<16&&(l=16)),Object.assign(this.popover.style,{position:"fixed",left:`${o}px`,top:`${l}px`,width:i?"100vw":`${s}px`,maxHeight:i?"60vh":"360px",zIndex:"10001",background:"#fff",borderRadius:i?"16px 16px 0 0":"12px",boxShadow:"0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08)",border:"1px solid #e2e8f0",fontFamily:ce,display:"flex",flexDirection:"column",overflow:"hidden",pointerEvents:"auto",...i?{bottom:"0",top:"auto"}:{}});const a=document.createElement("div");Object.assign(a.style,{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderBottom:"1px solid #f1f5f9",flexShrink:"0"}),a.innerHTML=`
1301
+ <div class="pin-attachments-preview" style="margin-top:6px;"></div>
1302
+ `;const a=this.form.querySelector("textarea"),c=this.form.querySelector(".pulse-close-btn"),h=this.form.querySelector(".pin-cancel"),p=this.form.querySelector(".pin-submit");c.addEventListener("click",()=>this.exitPinMode()),h.addEventListener("click",()=>this.exitPinMode()),this.pendingAttachmentIds=[],this.upload||(this.upload=new ge(this.client));const m=this.form.querySelector(".pin-attachments-preview");this.form.querySelector(".attach-img").addEventListener("click",async()=>{const f=await this.upload.pickFile("image/*");if(f){this.pendingAttachmentIds.push(f.id);const b=document.createElement("img");b.src=f.thumbnailUrl||f.url,Object.assign(b.style,{width:"48px",height:"48px",borderRadius:"6px",objectFit:"cover",border:"1px solid #e2e8f0"}),m.appendChild(b)}}),this.form.querySelector(".attach-mic").addEventListener("click",async()=>{this.audioRecorder||(this.audioRecorder=new _e);const f=await this.audioRecorder.startRecording(m);if(f){const b=await this.upload.uploadBlob(f,"audio.webm");if(b){this.pendingAttachmentIds.push(b.id);const y=document.createElement("span");Object.assign(y.style,{display:"inline-block",padding:"4px 10px",borderRadius:"6px",background:"#f1f5f9",fontSize:"11px",color:"#64748b"}),y.textContent="🎤 Audio attached",m.appendChild(y)}}}),this.form.querySelector(".attach-video").addEventListener("click",async()=>{this.videoRecorder||(this.videoRecorder=new Ni);const f=await this.videoRecorder.startRecording(m);if(f){const b=await this.upload.uploadBlob(f.blob,"video.webm");if(b){this.pendingAttachmentIds.push(b.id);const y=document.createElement("span");Object.assign(y.style,{display:"inline-block",padding:"4px 10px",borderRadius:"6px",background:"#f1f5f9",fontSize:"11px",color:"#64748b"}),y.textContent="🎥 Video attached",m.appendChild(y)}}}),p.addEventListener("click",()=>{const f=a.value.trim();if(!f&&this.pendingAttachmentIds.length===0)return;const b=[...(f||"").matchAll(/@(\w+)/g)].map(y=>y[1]);this.client.createThread(f||"(attachment)",{position:i,mentions:b}),this.pendingAttachmentIds=[],this.exitPinMode()}),a.addEventListener("keydown",f=>{f.key==="Escape"&&this.exitPinMode(),f.stopPropagation()}),document.body.appendChild(this.form),requestAnimationFrame(()=>a.focus())}showThreadPopover(e,t){this.closePopover(),this.popover=document.createElement("div"),this.popover.dataset.threadId=e.id;const i=window.innerWidth<=480,s=i?window.innerWidth:300,r=t.getBoundingClientRect();let o,l;i?(o=0,l=window.innerHeight*.4):(o=r.right+10,l=r.top-8,o+s>window.innerWidth-16&&(o=r.left-s-10),l<16&&(l=16)),Object.assign(this.popover.style,{position:"fixed",left:`${o}px`,top:`${l}px`,width:i?"100vw":`${s}px`,maxHeight:i?"60vh":"360px",zIndex:"10001",background:"#fff",borderRadius:i?"16px 16px 0 0":"12px",boxShadow:"0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08)",border:"1px solid #e2e8f0",fontFamily:ce,display:"flex",flexDirection:"column",overflow:"hidden",pointerEvents:"auto",...i?{bottom:"0",top:"auto"}:{}});const a=document.createElement("div");Object.assign(a.style,{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderBottom:"1px solid #f1f5f9",flexShrink:"0"}),a.innerHTML=`
1173
1303
  <span style="font-size:13px;font-weight:700;color:#0f172a;">Thread</span>
1174
- ${tt}
1175
- `,a.querySelector(".pulse-close-btn").addEventListener("click",()=>{this.closePopover()}),this.popover.appendChild(a),this.refreshPopoverComments(e),this.addPopoverReplyForm(e),document.body.appendChild(this.popover);const c=this.popover.getBoundingClientRect();c.bottom>window.innerHeight-16&&(this.popover.style.top=`${Math.max(16,window.innerHeight-c.height-16)}px`),requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.handlePopoverOutsideClick),document.addEventListener("keydown",this.handlePopoverEscape)})}refreshPopoverComments(e){var l;if(!this.popover)return;this.removePickerEl(),this.editingPopoverCommentId&&!e.comments.find(a=>a.id===this.editingPopoverCommentId)&&(this.editingPopoverCommentId=null);let t=this.popover.querySelector(".popover-comments");if(!t){t=document.createElement("div"),t.className="popover-comments",Object.assign(t.style,{flex:"1",overflowY:"auto",padding:"12px 14px",minHeight:"0"});const a=this.popover.firstElementChild;a&&a.nextSibling?this.popover.insertBefore(t,a.nextSibling):this.popover.appendChild(t)}const i=(l=this.client.state.user)==null?void 0:l.id;t.innerHTML=e.comments.map(a=>{const c=this.client.state.getUser(a.userId),p=c?c.name.split(" ").map(v=>v[0]).join("").toUpperCase().slice(0,2):"?",h=(c==null?void 0:c.color)??"#94a3b8",f=this.escapeHtml((c==null?void 0:c.name)??"Unknown"),g=this.formatTime(a.createdAt),$=i===a.userId,A=a.editedAt?'<span style="font-size:10px;color:#94a3b8;font-style:italic;">(edited)</span>':"";if(this.editingPopoverCommentId===a.id)return`
1304
+ ${ot}
1305
+ `,a.querySelector(".pulse-close-btn").addEventListener("click",()=>{this.closePopover()}),this.popover.appendChild(a),this.refreshPopoverComments(e),this.addPopoverReplyForm(e),document.body.appendChild(this.popover);const c=this.popover.getBoundingClientRect();c.bottom>window.innerHeight-16&&(this.popover.style.top=`${Math.max(16,window.innerHeight-c.height-16)}px`),requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.handlePopoverOutsideClick),document.addEventListener("keydown",this.handlePopoverEscape)})}refreshPopoverComments(e){var l;if(!this.popover)return;this.removePickerEl(),this.editingPopoverCommentId&&!e.comments.find(a=>a.id===this.editingPopoverCommentId)&&(this.editingPopoverCommentId=null);let t=this.popover.querySelector(".popover-comments");if(!t){t=document.createElement("div"),t.className="popover-comments",Object.assign(t.style,{flex:"1",overflowY:"auto",padding:"12px 14px",minHeight:"0"});const a=this.popover.firstElementChild;a&&a.nextSibling?this.popover.insertBefore(t,a.nextSibling):this.popover.appendChild(t)}const i=(l=this.client.state.user)==null?void 0:l.id;t.innerHTML=e.comments.map(a=>{const c=this.client.state.getUser(a.userId),h=c?c.name.split(" ").map(x=>x[0]).join("").toUpperCase().slice(0,2):"?",p=(c==null?void 0:c.color)??"#94a3b8",m=this.escapeHtml((c==null?void 0:c.name)??"Unknown"),f=this.formatTime(a.createdAt),b=i===a.userId,y=a.editedAt?'<span style="font-size:10px;color:#94a3b8;font-style:italic;">(edited)</span>':"";if(this.editingPopoverCommentId===a.id)return`
1176
1306
  <div style="margin-bottom:10px;" data-comment-id="${a.id}">
1177
1307
  <div style="display:flex;align-items:center;gap:7px;margin-bottom:4px;">
1178
- <div style="width:22px;height:22px;border-radius:50%;background:${h};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${p}</div>
1179
- <span style="font-size:12px;font-weight:600;color:#0f172a;">${f}</span>
1308
+ <div style="width:22px;height:22px;border-radius:50%;background:${p};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${h}</div>
1309
+ <span style="font-size:12px;font-weight:600;color:#0f172a;">${m}</span>
1180
1310
  </div>
1181
1311
  <div style="margin-left:29px;">
1182
1312
  <textarea class="edit-textarea" style="width:100%;padding:6px 10px;border:1.5px solid #e2e8f0;border-radius:6px;font-size:12px;font-family:inherit;outline:none;resize:vertical;min-height:48px;color:#0f172a;box-sizing:border-box;">${this.escapeHtml(a.body)}</textarea>
@@ -1186,35 +1316,45 @@
1186
1316
  </div>
1187
1317
  </div>
1188
1318
  </div>
1189
- `;const k=a.body.replace(/@(\w+)/g,'<span style="color:#6366f1;font-weight:600;background:#eef2ff;padding:0 3px;border-radius:3px;">@$1</span>'),w=(a.attachments??[]).map(v=>{if(v.type==="image"){const bt=v.thumbnailUrl||v.url;return`<div class="popover-attachment-img" data-full-url="${this.escapeHtml(v.url)}" style="margin:4px 0 4px 29px;cursor:pointer;">
1190
- <img src="${this.escapeHtml(bt)}" alt="${this.escapeHtml(v.filename)}" style="max-width:180px;max-height:120px;border-radius:8px;border:1px solid #e2e8f0;display:block;" />
1191
- </div>`}return v.type==="audio"?`<div class="popover-attachment-audio" data-url="${this.escapeHtml(v.url)}" data-duration="${v.durationMs??""}" style="margin:4px 0 4px 29px;"></div>`:v.type==="video"?`<div class="popover-attachment-video" data-url="${this.escapeHtml(v.url)}" data-poster="${this.escapeHtml(v.thumbnailUrl??"")}" style="margin:4px 0 4px 29px;"></div>`:""}).join(""),y=$?`<div class="popover-comment-actions" style="display:flex;gap:2px;margin-top:2px;margin-left:29px;">
1319
+ `;const E=a.body.replace(/@(\w+)/g,'<span style="color:#6366f1;font-weight:600;background:#eef2ff;padding:0 3px;border-radius:3px;">@$1</span>'),k=(a.attachments??[]).map(x=>{if(x.type==="image"){const wt=x.thumbnailUrl||x.url;return`<div class="popover-attachment-img" data-full-url="${this.escapeHtml(x.url)}" style="margin:4px 0 4px 29px;cursor:pointer;">
1320
+ <img src="${this.escapeHtml(wt)}" alt="${this.escapeHtml(x.filename)}" style="max-width:180px;max-height:120px;border-radius:8px;border:1px solid #e2e8f0;display:block;" />
1321
+ </div>`}return x.type==="audio"?`<div class="popover-attachment-audio" data-url="${this.escapeHtml(x.url)}" data-duration="${x.durationMs??""}" style="margin:4px 0 4px 29px;"></div>`:x.type==="video"?`<div class="popover-attachment-video" data-url="${this.escapeHtml(x.url)}" data-poster="${this.escapeHtml(x.thumbnailUrl??"")}" style="margin:4px 0 4px 29px;"></div>`:""}).join(""),$=b?`<div class="popover-comment-actions" style="display:flex;gap:2px;margin-top:2px;margin-left:29px;">
1192
1322
  <button class="edit-btn" data-comment-id="${a.id}" style="border:none;background:none;cursor:pointer;color:#94a3b8;padding:3px;border-radius:4px;display:flex;align-items:center;transition:all 0.15s;" title="Edit"
1193
1323
  onmouseover="this.style.color='#6366f1';this.style.background='#eef2ff'"
1194
- onmouseout="this.style.color='#94a3b8';this.style.background='none'">${Mi}</button>
1324
+ onmouseout="this.style.color='#94a3b8';this.style.background='none'">${Bi}</button>
1195
1325
  <button class="delete-btn" data-comment-id="${a.id}" style="border:none;background:none;cursor:pointer;color:#94a3b8;padding:3px;border-radius:4px;display:flex;align-items:center;transition:all 0.15s;" title="Delete"
1196
1326
  onmouseover="this.style.color='#ef4444';this.style.background='#fef2f2'"
1197
- onmouseout="this.style.color='#94a3b8';this.style.background='none'">${Oi}</button>
1198
- </div>`:"",T=this.buildReactionPillsHtml(a.id);return`
1327
+ onmouseout="this.style.color='#94a3b8';this.style.background='none'">${Fi}</button>
1328
+ </div>`:"",S=this.buildReactionPillsHtml(a.id);return`
1199
1329
  <div class="popover-comment" style="margin-bottom:10px;" data-comment-id="${a.id}">
1200
1330
  <div style="display:flex;align-items:center;gap:7px;margin-bottom:2px;">
1201
- <div style="width:22px;height:22px;border-radius:50%;background:${h};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${p}</div>
1202
- <span style="font-size:12px;font-weight:600;color:#0f172a;">${f}</span>
1203
- <span style="font-size:10px;color:#94a3b8;">${g}</span>
1204
- ${A}
1331
+ <div style="width:22px;height:22px;border-radius:50%;background:${p};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${h}</div>
1332
+ <span style="font-size:12px;font-weight:600;color:#0f172a;">${m}</span>
1333
+ <span style="font-size:10px;color:#94a3b8;">${f}</span>
1334
+ ${y}
1205
1335
  </div>
1206
- <div style="font-size:13px;color:#334155;line-height:1.45;margin-left:29px;word-wrap:break-word;">${k}</div>
1207
- ${w}
1208
- ${y}
1209
- ${T}
1336
+ <div style="font-size:13px;color:#334155;line-height:1.45;margin-left:29px;word-wrap:break-word;">${E}</div>
1337
+ ${k}
1338
+ ${$}
1339
+ ${S}
1210
1340
  </div>
1211
- `}).join(""),t.querySelectorAll(".edit-btn").forEach(a=>{a.addEventListener("click",()=>{this.editingPopoverCommentId=a.dataset.commentId,this.refreshPopoverComments(e)})}),t.querySelectorAll(".delete-btn").forEach(a=>{a.addEventListener("click",()=>{this.client.deleteComment(a.dataset.commentId)})});const s=t.querySelector(".edit-save"),r=t.querySelector(".edit-cancel"),o=t.querySelector(".edit-textarea");s&&o&&s.addEventListener("click",()=>{const a=o.value.trim();if(!a)return;const c=[...a.matchAll(/@(\w+)/g)].map(p=>p[1]);this.client.editComment(this.editingPopoverCommentId,a,c),this.editingPopoverCommentId=null}),r&&r.addEventListener("click",()=>{this.editingPopoverCommentId=null,this.refreshPopoverComments(e)}),t.querySelectorAll("[data-reaction-emoji]").forEach(a=>{a.addEventListener("click",c=>{c.stopPropagation();const p=a.dataset.reactionEmoji,h=a.dataset.reactionTarget,f=a.dataset.reactionId;f?this.client.removeReaction(f):this.client.addReaction(h,"comment",p)})}),t.querySelectorAll(".popover-reaction-add").forEach(a=>{a.addEventListener("click",c=>{c.stopPropagation();const p=a.dataset.commentId;this.popoverPickerOpen===p?(this.popoverPickerOpen=null,this.removePickerEl()):(this.popoverPickerOpen=p,this.showPickerForButton(a,p))})}),t.querySelectorAll(".popover-attachment-img").forEach(a=>{a.addEventListener("click",()=>{const c=a.dataset.fullUrl;c&&me.open(c)})}),t.querySelectorAll(".popover-attachment-audio").forEach(a=>{const c=a.dataset.url;if(c){const p=a.dataset.duration?parseInt(a.dataset.duration):void 0,h=Pe.render(c,p);a.appendChild(h)}}),t.querySelectorAll(".popover-attachment-video").forEach(a=>{const c=a.dataset.url;if(c){const p=a.dataset.poster||void 0,h=mt.render(c,p);a.appendChild(h)}}),t.scrollTop=t.scrollHeight}addPopoverReplyForm(e){if(!this.popover)return;const t=document.createElement("div");Object.assign(t.style,{padding:"8px 14px 12px",borderTop:"1px solid #f1f5f9",display:"flex",gap:"6px"}),t.innerHTML=`
1212
- <input type="text" placeholder="Reply..."
1213
- style="flex:1;padding:7px 10px;border:1.5px solid #e2e8f0;border-radius:8px;font-size:12px;font-family:inherit;outline:none;color:#0f172a;" />
1214
- <button style="padding:7px 14px;background:#6366f1;color:#fff;border:none;border-radius:8px;font-size:12px;font-weight:600;cursor:pointer;font-family:inherit;white-space:nowrap;">Send</button>
1215
- `;const i=t.querySelector("input"),s=t.querySelector("button"),r=()=>{const o=i.value.trim();if(!o)return;const l=[...o.matchAll(/@(\w+)/g)].map(a=>a[1]);this.client.reply(e.id,o,l),i.value=""};s.addEventListener("click",r),i.addEventListener("input",()=>{const o=Date.now(),l=this.lastTypingSendPins.get(e.id)??0;o-l>=2e3&&(this.client.sendTyping(e.id),this.lastTypingSendPins.set(e.id,o))}),i.addEventListener("keydown",o=>{o.key==="Enter"&&(o.preventDefault(),r()),o.key==="Escape"&&this.closePopover(),o.stopPropagation()}),this.popover.appendChild(t)}removePickerEl(){var e;(e=this.pickerEl)==null||e.remove(),this.pickerEl=null}showPickerForButton(e,t){this.removePickerEl();const i=e.getBoundingClientRect();this.pickerEl=document.createElement("div"),Object.assign(this.pickerEl.style,{position:"fixed",left:`${i.left}px`,top:`${i.top-4}px`,transform:"translateY(-100%)",display:"flex",gap:"2px",padding:"4px 6px",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"8px",boxShadow:"0 4px 24px rgba(0,0,0,0.12)",zIndex:"10002",fontFamily:ce});for(const s of Ai){const r=document.createElement("button");Object.assign(r.style,{border:"none",background:"none",cursor:"pointer",fontSize:"16px",padding:"4px",borderRadius:"4px",lineHeight:"1"}),r.textContent=s,r.addEventListener("click",o=>{o.stopPropagation();const a=this.client.state.getReactions(t).find(c=>{var p;return c.emoji===s&&c.userId===((p=this.client.state.user)==null?void 0:p.id)});a?this.client.removeReaction(a.id):this.client.addReaction(t,"comment",s),this.popoverPickerOpen=null,this.removePickerEl()}),this.pickerEl.appendChild(r)}document.body.appendChild(this.pickerEl)}buildReactionPillsHtml(e){var a;const t=this.client.state.getReactions(e),i=(a=this.client.state.user)==null?void 0:a.id,s=new Map;for(const c of t){const p=s.get(c.emoji)??{count:0,ownId:null};p.count++,c.userId===i&&(p.ownId=c.id),s.set(c.emoji,p)}const r="display:inline-flex;align-items:center;gap:3px;padding:2px 8px;border-radius:12px;border:1px solid #e2e8f0;background:#fff;font-size:12px;cursor:pointer;transition:all 0.15s;line-height:1.4;",o=r+"background:#eef2ff;border-color:#6366f1;";let l='<div style="margin-left:29px;display:flex;gap:4px;flex-wrap:wrap;margin-top:4px;">';for(const[c,{count:p,ownId:h}]of s){const f=h?o:r;l+=`<button data-reaction-emoji="${c}" data-reaction-target="${e}" ${h?`data-reaction-id="${h}"`:""} style="${f}">
1216
- <span>${c}</span><span style="font-size:11px;font-weight:600;color:#64748b;">${p}</span>
1217
- </button>`}return l+=`<button class="popover-reaction-add" data-comment-id="${e}" style="display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:1px dashed #e2e8f0;background:none;cursor:pointer;color:#94a3b8;font-size:14px;">+</button>`,l+="</div>",l}updatePopoverTyping(e){if(!this.popover)return;let t=this.popover.querySelector(".popover-typing");if(!t){t=document.createElement("div"),t.className="popover-typing",Object.assign(t.style,{padding:"0 14px 4px",fontSize:"11px",color:"#94a3b8",fontStyle:"italic",minHeight:"16px"});const s=this.popover.lastElementChild;s&&this.popover.insertBefore(t,s)}const i=this.client.state.getTypingUsers(e).filter(s=>{var r;return s!==((r=this.client.state.user)==null?void 0:r.id)}).map(s=>{const r=this.client.state.presence.find(o=>o.user.id===s);return(r==null?void 0:r.user.name)??"Someone"});i.length===0?t.textContent="":i.length===1?t.textContent=`${i[0]} is typing...`:t.textContent=`${i.join(", ")} are typing...`}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),r=Math.floor(s/6e4);if(r<1)return"now";if(r<60)return`${r}m`;const o=Math.floor(r/60);return o<24?`${o}h`:t.toLocaleDateString()}resolvePosition(e){if(e.selector&&e.elementOffsetX!=null&&e.elementOffsetY!=null)try{const t=document.querySelector(e.selector);if(t){const i=t.getBoundingClientRect();return{x:i.left+e.elementOffsetX*i.width,y:i.top+e.elementOffsetY*i.height}}}catch{}return{x:e.x*window.innerWidth,y:e.y*window.innerHeight}}renderPins(){if(!this.container)return;const e=this.threads.filter(i=>i.position&&!i.resolved),t=new Set(e.map(i=>i.id));for(const[i,s]of this.pinEls)t.has(i)||(s.remove(),this.pinEls.delete(i));e.forEach((i,s)=>{const r=i.position;let o=this.pinEls.get(i.id);o||(o=document.createElement("div"),Object.assign(o.style,{position:"fixed",width:"24px",height:"24px",borderRadius:"50%",background:"#6366f1",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:"700",fontFamily:ce,cursor:"pointer",pointerEvents:"auto",boxShadow:"0 2px 8px rgba(99,102,241,0.4)",border:"2px solid #fff",transition:"left 0.15s ease, top 0.15s ease, transform 0.15s ease",zIndex:"9997",transform:"translate(-50%, -50%)"}),o.addEventListener("mouseenter",()=>{o.style.transform="translate(-50%, -50%) scale(1.15)"}),o.addEventListener("mouseleave",()=>{o.style.transform="translate(-50%, -50%)"}),o.addEventListener("click",()=>{if(this.popover&&this.popover.dataset.threadId===i.id){this.closePopover();return}const a=this.threads.find(c=>c.id===i.id);a&&this.showThreadPopover(a,o)}),this.container.appendChild(o),this.pinEls.set(i.id,o)),o.textContent=`${s+1}`;const l=this.resolvePosition(r);o.style.left=`${l.x}px`,o.style.top=`${l.y}px`})}}var ji=Object.defineProperty,Li=Object.getOwnPropertyDescriptor,L=(n,e,t,i)=>{for(var s=i>1?void 0:i?Li(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ji(e,t,s),s};const Ri=["👍","👎","❤️","🎉","👀","🚀"];let O=class extends P{constructor(){super(...arguments),this.highlightThreadId=null,this.threads=[],this.replyingTo=null,this.editingCommentId=null,this.editBody="",this.pickerOpenForComment=null,this.typingByThread=new Map,this.reactionsVersion=0,this.typingTimers=new Map,this.lastTypingSend=new Map}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var n,e,t;super.disconnectedCallback(),(n=this.unsub)==null||n.call(this),(e=this.reactionUnsub)==null||e.call(this),(t=this.typingUnsub)==null||t.call(this);for(const i of this.typingTimers.values())clearTimeout(i);this.typingTimers.clear()}updated(n){var e,t,i,s,r;n.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),(t=this.reactionUnsub)==null||t.call(this),(i=this.typingUnsub)==null||i.call(this),this.setupListener()),(s=this.shadowRoot)==null||s.querySelectorAll(".audio-player-host").forEach(o=>{if(o.children.length>0)return;const l=o.dataset.url;if(l){const a=o.dataset.duration?parseInt(o.dataset.duration):void 0;o.appendChild(Pe.render(l,a))}}),(r=this.shadowRoot)==null||r.querySelectorAll(".video-player-host").forEach(o=>{if(o.children.length>0)return;const l=o.dataset.url;l&&o.appendChild(mt.render(l,o.dataset.poster||void 0))})}setupListener(){this.client&&(this.threads=this.client.state.threads,this.unsub=this.client.state.on("threads",n=>{this.threads=[...n]}),this.reactionUnsub=this.client.state.on("reactions",()=>{this.reactionsVersion++}),this.typingUnsub=this.client.state.on("typing",({threadId:n})=>{this.refreshTyping(n)}))}refreshTyping(n){const t=this.client.state.getTypingUsers(n).filter(s=>{var r;return s!==((r=this.client.state.user)==null?void 0:r.id)}).map(s=>{const r=this.client.state.presence.find(o=>o.user.id===s);return(r==null?void 0:r.user.name)??"Someone"}),i=new Map(this.typingByThread);i.set(n,t),this.typingByThread=i,this.typingTimers.has(n)&&clearTimeout(this.typingTimers.get(n)),this.typingTimers.set(n,setTimeout(()=>{this.refreshTyping(n)},3500))}handleTypingInput(n){const e=Date.now(),t=this.lastTypingSend.get(n)??0;e-t>=2e3&&(this.client.sendTyping(n),this.lastTypingSend.set(n,e))}toggleReaction(n,e){var r;const t=this.client.state.getReactions(n),i=(r=this.client.state.user)==null?void 0:r.id,s=t.find(o=>o.emoji===e&&o.userId===i);s?this.client.removeReaction(s.id):this.client.addReaction(n,"comment",e),this.pickerOpenForComment=null}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}scrollToThread(n){this.updateComplete.then(()=>{var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(`[data-thread-id="${n}"]`);e==null||e.scrollIntoView({behavior:"smooth",block:"center"})})}parseMentions(n){return n.split(/(@\w+)/g).map(t=>t.startsWith("@")?d`<span class="mention">${t}</span>`:t)}getInitials(n){return n.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}getUserForComment(n){return this.client.state.getUser(n)}formatTime(n){const e=new Date(n),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const r=Math.floor(s/60);return r<24?`${r}h`:e.toLocaleDateString()}handleReply(n,e){e.preventDefault();const i=e.target.querySelector("input"),s=i.value.trim();if(!s)return;const r=[...s.matchAll(/@(\w+)/g)].map(o=>o[1]);this.client.reply(n,s,r),i.value="",this.replyingTo=null}isOwnComment(n){var e,t;return((t=(e=this.client)==null?void 0:e.state.user)==null?void 0:t.id)===n.userId}startEdit(n){this.editingCommentId=n.id,this.editBody=n.body}cancelEdit(){this.editingCommentId=null,this.editBody=""}saveEdit(n){const e=this.editBody.trim();if(!e)return;const t=[...e.matchAll(/@(\w+)/g)].map(i=>i[1]);this.client.editComment(n,e,t),this.editingCommentId=null,this.editBody=""}deleteComment(n){this.client.deleteComment(n)}renderEditForm(n){return d`
1341
+ `}).join(""),t.querySelectorAll(".edit-btn").forEach(a=>{a.addEventListener("click",()=>{this.editingPopoverCommentId=a.dataset.commentId,this.refreshPopoverComments(e)})}),t.querySelectorAll(".delete-btn").forEach(a=>{a.addEventListener("click",()=>{this.client.deleteComment(a.dataset.commentId)})});const s=t.querySelector(".edit-save"),r=t.querySelector(".edit-cancel"),o=t.querySelector(".edit-textarea");s&&o&&s.addEventListener("click",()=>{const a=o.value.trim();if(!a)return;const c=[...a.matchAll(/@(\w+)/g)].map(h=>h[1]);this.client.editComment(this.editingPopoverCommentId,a,c),this.editingPopoverCommentId=null}),r&&r.addEventListener("click",()=>{this.editingPopoverCommentId=null,this.refreshPopoverComments(e)}),t.querySelectorAll("[data-reaction-emoji]").forEach(a=>{a.addEventListener("click",c=>{c.stopPropagation();const h=a.dataset.reactionEmoji,p=a.dataset.reactionTarget,m=a.dataset.reactionId;m?this.client.removeReaction(m):this.client.addReaction(p,"comment",h)})}),t.querySelectorAll(".popover-reaction-add").forEach(a=>{a.addEventListener("click",c=>{c.stopPropagation();const h=a.dataset.commentId;this.popoverPickerOpen===h?(this.popoverPickerOpen=null,this.removePickerEl()):(this.popoverPickerOpen=h,this.showPickerForButton(a,h))})}),t.querySelectorAll(".popover-attachment-img").forEach(a=>{a.addEventListener("click",()=>{const c=a.dataset.fullUrl;c&&me.open(c)})}),t.querySelectorAll(".popover-attachment-audio").forEach(a=>{const c=a.dataset.url;if(c){const h=a.dataset.duration?parseInt(a.dataset.duration):void 0,p=Pe.render(c,h);a.appendChild(p)}}),t.querySelectorAll(".popover-attachment-video").forEach(a=>{const c=a.dataset.url;if(c){const h=a.dataset.poster||void 0,p=xt.render(c,h);a.appendChild(p)}}),t.scrollTop=t.scrollHeight}addPopoverReplyForm(e){if(!this.popover)return;const t=document.createElement("div");Object.assign(t.style,{padding:"8px 14px 12px",borderTop:"1px solid #f1f5f9",display:"flex",gap:"6px"}),t.innerHTML=`
1342
+ <div style="display:flex;gap:6px;width:100%;">
1343
+ <input type="text" placeholder="Reply..."
1344
+ style="flex:1;padding:7px 10px;border:1.5px solid #e2e8f0;border-radius:8px;font-size:12px;font-family:inherit;outline:none;color:#0f172a;min-width:0;" />
1345
+ <div style="display:flex;gap:1px;align-items:center;flex-shrink:0;">
1346
+ <button class="reply-attach-img" title="Image" style="border:none;background:none;cursor:pointer;color:#94a3b8;padding:3px;border-radius:4px;display:flex;" onmouseover="this.style.color='#6366f1'" onmouseout="this.style.color='#94a3b8'">
1347
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>
1348
+ </button>
1349
+ <button class="reply-attach-mic" title="Audio" style="border:none;background:none;cursor:pointer;color:#94a3b8;padding:3px;border-radius:4px;display:flex;" onmouseover="this.style.color='#6366f1'" onmouseout="this.style.color='#94a3b8'">
1350
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>
1351
+ </button>
1352
+ </div>
1353
+ <button class="reply-send" style="padding:7px 14px;background:#6366f1;color:#fff;border:none;border-radius:8px;font-size:12px;font-weight:600;cursor:pointer;font-family:inherit;white-space:nowrap;flex-shrink:0;">Send</button>
1354
+ </div>
1355
+ `;const i=t.querySelector("input"),s=t.querySelector(".reply-send");this.upload||(this.upload=new ge(this.client)),t.querySelector(".reply-attach-img").addEventListener("click",async()=>{await this.upload.pickFile("image/*")&&this.client.reply(e.id,"(image)")}),t.querySelector(".reply-attach-mic").addEventListener("click",async()=>{this.audioRecorder||(this.audioRecorder=new _e);const o=await this.audioRecorder.startRecording(t);o&&await this.upload.uploadBlob(o,"audio.webm")&&this.client.reply(e.id,"(audio note)")});const r=()=>{const o=i.value.trim();if(!o)return;const l=[...o.matchAll(/@(\w+)/g)].map(a=>a[1]);this.client.reply(e.id,o,l),i.value=""};s.addEventListener("click",r),i.addEventListener("input",()=>{const o=Date.now(),l=this.lastTypingSendPins.get(e.id)??0;o-l>=2e3&&(this.client.sendTyping(e.id),this.lastTypingSendPins.set(e.id,o))}),i.addEventListener("keydown",o=>{o.key==="Enter"&&(o.preventDefault(),r()),o.key==="Escape"&&this.closePopover(),o.stopPropagation()}),this.popover.appendChild(t)}removePickerEl(){var e;(e=this.pickerEl)==null||e.remove(),this.pickerEl=null}showPickerForButton(e,t){this.removePickerEl();const i=e.getBoundingClientRect();this.pickerEl=document.createElement("div"),Object.assign(this.pickerEl.style,{position:"fixed",left:`${i.left}px`,top:`${i.top-4}px`,transform:"translateY(-100%)",display:"flex",gap:"2px",padding:"4px 6px",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"8px",boxShadow:"0 4px 24px rgba(0,0,0,0.12)",zIndex:"10002",fontFamily:ce});for(const s of Hi){const r=document.createElement("button");Object.assign(r.style,{border:"none",background:"none",cursor:"pointer",fontSize:"16px",padding:"4px",borderRadius:"4px",lineHeight:"1"}),r.textContent=s,r.addEventListener("click",o=>{o.stopPropagation();const a=this.client.state.getReactions(t).find(c=>{var h;return c.emoji===s&&c.userId===((h=this.client.state.user)==null?void 0:h.id)});a?this.client.removeReaction(a.id):this.client.addReaction(t,"comment",s),this.popoverPickerOpen=null,this.removePickerEl()}),this.pickerEl.appendChild(r)}document.body.appendChild(this.pickerEl)}buildReactionPillsHtml(e){var a;const t=this.client.state.getReactions(e),i=(a=this.client.state.user)==null?void 0:a.id,s=new Map;for(const c of t){const h=s.get(c.emoji)??{count:0,ownId:null};h.count++,c.userId===i&&(h.ownId=c.id),s.set(c.emoji,h)}const r="display:inline-flex;align-items:center;gap:3px;padding:2px 8px;border-radius:12px;border:1px solid #e2e8f0;background:#fff;font-size:12px;cursor:pointer;transition:all 0.15s;line-height:1.4;",o=r+"background:#eef2ff;border-color:#6366f1;";let l='<div style="margin-left:29px;display:flex;gap:4px;flex-wrap:wrap;margin-top:4px;">';for(const[c,{count:h,ownId:p}]of s){const m=p?o:r;l+=`<button data-reaction-emoji="${c}" data-reaction-target="${e}" ${p?`data-reaction-id="${p}"`:""} style="${m}">
1356
+ <span>${c}</span><span style="font-size:11px;font-weight:600;color:#64748b;">${h}</span>
1357
+ </button>`}return l+=`<button class="popover-reaction-add" data-comment-id="${e}" style="display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:1px dashed #e2e8f0;background:none;cursor:pointer;color:#94a3b8;font-size:14px;">+</button>`,l+="</div>",l}updatePopoverTyping(e){if(!this.popover)return;let t=this.popover.querySelector(".popover-typing");if(!t){t=document.createElement("div"),t.className="popover-typing",Object.assign(t.style,{padding:"0 14px 4px",fontSize:"11px",color:"#94a3b8",fontStyle:"italic",minHeight:"16px"});const s=this.popover.lastElementChild;s&&this.popover.insertBefore(t,s)}const i=this.client.state.getTypingUsers(e).filter(s=>{var r;return s!==((r=this.client.state.user)==null?void 0:r.id)}).map(s=>{const r=this.client.state.presence.find(o=>o.user.id===s);return(r==null?void 0:r.user.name)??"Someone"});i.length===0?t.textContent="":i.length===1?t.textContent=`${i[0]} is typing...`:t.textContent=`${i.join(", ")} are typing...`}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),r=Math.floor(s/6e4);if(r<1)return"now";if(r<60)return`${r}m`;const o=Math.floor(r/60);return o<24?`${o}h`:t.toLocaleDateString()}resolvePosition(e){if(e.selector&&e.elementOffsetX!=null&&e.elementOffsetY!=null)try{const t=document.querySelector(e.selector);if(t){const i=t.getBoundingClientRect();return{x:i.left+e.elementOffsetX*i.width,y:i.top+e.elementOffsetY*i.height}}}catch{}return{x:e.x*window.innerWidth,y:e.y*window.innerHeight}}renderPins(){if(!this.container)return;const e=this.threads.filter(i=>i.position&&!i.resolved),t=new Set(e.map(i=>i.id));for(const[i,s]of this.pinEls)t.has(i)||(s.remove(),this.pinEls.delete(i));e.forEach((i,s)=>{const r=i.position;let o=this.pinEls.get(i.id);o||(o=document.createElement("div"),Object.assign(o.style,{position:"fixed",width:"24px",height:"24px",borderRadius:"50%",background:"#6366f1",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:"700",fontFamily:ce,cursor:"pointer",pointerEvents:"auto",boxShadow:"0 2px 8px rgba(99,102,241,0.4)",border:"2px solid #fff",transition:"left 0.15s ease, top 0.15s ease, transform 0.15s ease",zIndex:"9997",transform:"translate(-50%, -50%)"}),o.addEventListener("mouseenter",()=>{o.style.transform="translate(-50%, -50%) scale(1.15)"}),o.addEventListener("mouseleave",()=>{o.style.transform="translate(-50%, -50%)"}),o.addEventListener("click",()=>{if(this.popover&&this.popover.dataset.threadId===i.id){this.closePopover();return}const a=this.threads.find(c=>c.id===i.id);a&&this.showThreadPopover(a,o)}),this.container.appendChild(o),this.pinEls.set(i.id,o)),o.textContent=`${s+1}`;const l=this.resolvePosition(r);o.style.left=`${l.x}px`,o.style.top=`${l.y}px`})}}var qi=Object.defineProperty,Vi=Object.getOwnPropertyDescriptor,L=(n,e,t,i)=>{for(var s=i>1?void 0:i?Vi(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&qi(e,t,s),s};const Xi=["👍","👎","❤️","🎉","👀","🚀"];let I=class extends _{constructor(){super(...arguments),this.highlightThreadId=null,this.threads=[],this.replyingTo=null,this.editingCommentId=null,this.editBody="",this.pickerOpenForComment=null,this.typingByThread=new Map,this.reactionsVersion=0,this.typingTimers=new Map,this.lastTypingSend=new Map}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var n,e,t;super.disconnectedCallback(),(n=this.unsub)==null||n.call(this),(e=this.reactionUnsub)==null||e.call(this),(t=this.typingUnsub)==null||t.call(this);for(const i of this.typingTimers.values())clearTimeout(i);this.typingTimers.clear()}updated(n){var e,t,i,s,r;n.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),(t=this.reactionUnsub)==null||t.call(this),(i=this.typingUnsub)==null||i.call(this),this.setupListener()),(s=this.shadowRoot)==null||s.querySelectorAll(".audio-player-host").forEach(o=>{if(o.children.length>0)return;const l=o.dataset.url;if(l){const a=o.dataset.duration?parseInt(o.dataset.duration):void 0;o.appendChild(Pe.render(l,a))}}),(r=this.shadowRoot)==null||r.querySelectorAll(".video-player-host").forEach(o=>{if(o.children.length>0)return;const l=o.dataset.url;l&&o.appendChild(xt.render(l,o.dataset.poster||void 0))})}setupListener(){this.client&&(this.threads=this.client.state.threads,this.unsub=this.client.state.on("threads",n=>{this.threads=[...n]}),this.reactionUnsub=this.client.state.on("reactions",()=>{this.reactionsVersion++}),this.typingUnsub=this.client.state.on("typing",({threadId:n})=>{this.refreshTyping(n)}))}refreshTyping(n){const t=this.client.state.getTypingUsers(n).filter(s=>{var r;return s!==((r=this.client.state.user)==null?void 0:r.id)}).map(s=>{const r=this.client.state.presence.find(o=>o.user.id===s);return(r==null?void 0:r.user.name)??"Someone"}),i=new Map(this.typingByThread);i.set(n,t),this.typingByThread=i,this.typingTimers.has(n)&&clearTimeout(this.typingTimers.get(n)),this.typingTimers.set(n,setTimeout(()=>{this.refreshTyping(n)},3500))}handleTypingInput(n){const e=Date.now(),t=this.lastTypingSend.get(n)??0;e-t>=2e3&&(this.client.sendTyping(n),this.lastTypingSend.set(n,e))}toggleReaction(n,e){var r;const t=this.client.state.getReactions(n),i=(r=this.client.state.user)==null?void 0:r.id,s=t.find(o=>o.emoji===e&&o.userId===i);s?this.client.removeReaction(s.id):this.client.addReaction(n,"comment",e),this.pickerOpenForComment=null}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}scrollToThread(n){this.updateComplete.then(()=>{var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(`[data-thread-id="${n}"]`);e==null||e.scrollIntoView({behavior:"smooth",block:"center"})})}parseMentions(n){return n.split(/(@\w+)/g).map(t=>t.startsWith("@")?d`<span class="mention">${t}</span>`:t)}getInitials(n){return n.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}getUserForComment(n){return this.client.state.getUser(n)}formatTime(n){const e=new Date(n),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const r=Math.floor(s/60);return r<24?`${r}h`:e.toLocaleDateString()}async handleAttachImage(n){this.upload||(this.upload=new ge(this.client)),await this.upload.pickFile("image/*")&&this.client.reply(n,"(image)")}async handleRecordAudio(n){var i;this.upload||(this.upload=new ge(this.client)),this.audioRecorder||(this.audioRecorder=new _e);const e=(i=this.shadowRoot)==null?void 0:i.querySelector(`[data-thread-id="${n}"]`),t=await this.audioRecorder.startRecording(e??document.body);t&&await this.upload.uploadBlob(t,"audio.webm")&&this.client.reply(n,"(audio note)")}handleReply(n,e){e.preventDefault();const i=e.target.querySelector("input"),s=i.value.trim();if(!s)return;const r=[...s.matchAll(/@(\w+)/g)].map(o=>o[1]);this.client.reply(n,s,r),i.value="",this.replyingTo=null}isOwnComment(n){var e,t;return((t=(e=this.client)==null?void 0:e.state.user)==null?void 0:t.id)===n.userId}startEdit(n){this.editingCommentId=n.id,this.editBody=n.body}cancelEdit(){this.editingCommentId=null,this.editBody=""}saveEdit(n){const e=this.editBody.trim();if(!e)return;const t=[...e.matchAll(/@(\w+)/g)].map(i=>i[1]);this.client.editComment(n,e,t),this.editingCommentId=null,this.editBody=""}deleteComment(n){this.client.deleteComment(n)}renderEditForm(n){return d`
1218
1358
  <div class="edit-form">
1219
1359
  <textarea
1220
1360
  .value=${this.editBody}
@@ -1244,7 +1384,7 @@
1244
1384
  +
1245
1385
  ${this.pickerOpenForComment===n.id?d`
1246
1386
  <div class="emoji-picker">
1247
- ${Ri.map(r=>d`
1387
+ ${Xi.map(r=>d`
1248
1388
  <button @click=${o=>{o.stopPropagation(),this.toggleReaction(n.id,r)}}>${r}</button>
1249
1389
  `)}
1250
1390
  </div>
@@ -1259,7 +1399,7 @@
1259
1399
  <span class="thread-count">${this.threads.length}</span>
1260
1400
  </span>
1261
1401
  <button class="close-btn" @click=${this.fireClose} title="Close">
1262
- ${E(ae,16)}
1402
+ ${C(ae,16)}
1263
1403
  </button>
1264
1404
  </div>
1265
1405
 
@@ -1299,7 +1439,7 @@
1299
1439
  data-thread-id=${n.id}
1300
1440
  >
1301
1441
  ${n.position?d`<div class="pin-badge">
1302
- ${E(ft,12)}
1442
+ ${C(vt,12)}
1303
1443
  Pinned
1304
1444
  </div>`:u}
1305
1445
  ${n.comments.map((t,i)=>{const s=this.getUserForComment(t.userId),r=this.isOwnComment(t),o=this.editingCommentId===t.id;return d`
@@ -1321,8 +1461,8 @@
1321
1461
  ${this.renderAttachments(t.attachments??[])}
1322
1462
  `}
1323
1463
  ${r&&!o?d`<div class="comment-actions">
1324
- <button @click=${()=>this.startEdit(t)} title="Edit">${E(gi,14)}</button>
1325
- <button class="danger" @click=${()=>this.deleteComment(t.id)} title="Delete">${E(vi,14)}</button>
1464
+ <button @click=${()=>this.startEdit(t)} title="Edit">${C($i,14)}</button>
1465
+ <button class="danger" @click=${()=>this.deleteComment(t.id)} title="Delete">${C(Ci,14)}</button>
1326
1466
  </div>`:u}
1327
1467
  ${this.renderReactions(t)}
1328
1468
  </div>
@@ -1353,11 +1493,25 @@
1353
1493
  placeholder="Reply..."
1354
1494
  @input=${()=>this.handleTypingInput(n.id)}
1355
1495
  />
1496
+ <button
1497
+ type="button"
1498
+ class="pw-btn pw-btn-icon"
1499
+ title="Attach image"
1500
+ style="padding:4px;color:var(--pw-text-muted)"
1501
+ @click=${()=>this.handleAttachImage(n.id)}
1502
+ >${C(yi,14)}</button>
1503
+ <button
1504
+ type="button"
1505
+ class="pw-btn pw-btn-icon"
1506
+ title="Record audio"
1507
+ style="padding:4px;color:var(--pw-text-muted)"
1508
+ @click=${()=>this.handleRecordAudio(n.id)}
1509
+ >${C(xi,14)}</button>
1356
1510
  <button class="pw-btn pw-btn-primary" type="submit">Send</button>
1357
1511
  </form>
1358
1512
  `:u}
1359
1513
  </div>
1360
- `}};O.styles=[K,le,ve,S`
1514
+ `}};I.styles=[K,le,xe,A`
1361
1515
  :host {
1362
1516
  display: block;
1363
1517
  }
@@ -1814,7 +1968,7 @@
1814
1968
  background: var(--pw-surface-hover);
1815
1969
  color: var(--pw-text);
1816
1970
  }
1817
- `];L([m({attribute:!1})],O.prototype,"client",2);L([m()],O.prototype,"highlightThreadId",2);L([b()],O.prototype,"threads",2);L([b()],O.prototype,"replyingTo",2);L([b()],O.prototype,"editingCommentId",2);L([b()],O.prototype,"editBody",2);L([b()],O.prototype,"pickerOpenForComment",2);L([b()],O.prototype,"typingByThread",2);L([b()],O.prototype,"reactionsVersion",2);O=L([I("pulse-widget-comments-panel")],O);var zi=Object.defineProperty,Di=Object.getOwnPropertyDescriptor,je=(n,e,t,i)=>{for(var s=i>1?void 0:i?Di(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&zi(e,t,s),s};const Ui={"comment:created":"left a comment","comment:mention":"mentioned you","comment:reply":"replied to your comment","thread:resolved":"resolved a thread","reaction:added":"reacted to your comment"},Hi={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};let ie=class extends P{constructor(){super(...arguments),this.notifications=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.unsub)==null||n.call(this)}updated(n){var e;n.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),this.setupListener())}setupListener(){this.client&&(this.notifications=this.client.state.notifications,this.unsub=this.client.state.on("notifications",n=>{this.notifications=[...n]}))}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}handleClick(n){n.read||this.client.markRead(n.id)}getActorName(n){var e;return((e=this.client.state.getUser(n))==null?void 0:e.name)??"Someone"}formatTime(n){const e=new Date(n),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const r=Math.floor(s/60);return r<24?`${r}h`:e.toLocaleDateString()}render(){const n=this.notifications.filter(e=>!e.read).length;return d`
1971
+ `];L([g({attribute:!1})],I.prototype,"client",2);L([g()],I.prototype,"highlightThreadId",2);L([v()],I.prototype,"threads",2);L([v()],I.prototype,"replyingTo",2);L([v()],I.prototype,"editingCommentId",2);L([v()],I.prototype,"editBody",2);L([v()],I.prototype,"pickerOpenForComment",2);L([v()],I.prototype,"typingByThread",2);L([v()],I.prototype,"reactionsVersion",2);I=L([O("pulse-widget-comments-panel")],I);var Yi=Object.defineProperty,Ki=Object.getOwnPropertyDescriptor,je=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ki(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yi(e,t,s),s};const Gi={"comment:created":"left a comment","comment:mention":"mentioned you","comment:reply":"replied to your comment","thread:resolved":"resolved a thread","reaction:added":"reacted to your comment"},Ji={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};let ie=class extends _{constructor(){super(...arguments),this.notifications=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.unsub)==null||n.call(this)}updated(n){var e;n.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),this.setupListener())}setupListener(){this.client&&(this.notifications=this.client.state.notifications,this.unsub=this.client.state.on("notifications",n=>{this.notifications=[...n]}))}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}handleClick(n){n.read||this.client.markRead(n.id)}getActorName(n){var e;return((e=this.client.state.getUser(n))==null?void 0:e.name)??"Someone"}formatTime(n){const e=new Date(n),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const r=Math.floor(s/60);return r<24?`${r}h`:e.toLocaleDateString()}render(){const n=this.notifications.filter(e=>!e.read).length;return d`
1818
1972
  <div class="panel">
1819
1973
  <div class="panel-header">
1820
1974
  <span class="panel-title">
@@ -1826,7 +1980,7 @@
1826
1980
  Mark all read
1827
1981
  </button>`:u}
1828
1982
  <button class="close-btn" @click=${this.fireClose} title="Close">
1829
- ${E(ae,16)}
1983
+ ${C(ae,16)}
1830
1984
  </button>
1831
1985
  </div>
1832
1986
  </div>
@@ -1840,11 +1994,11 @@
1840
1994
  class="item ${e.read?"":"unread"}"
1841
1995
  @click=${()=>this.handleClick(e)}
1842
1996
  >
1843
- <span class="icon">${Hi[e.type]??"🔔"}</span>
1997
+ <span class="icon">${Ji[e.type]??"🔔"}</span>
1844
1998
  <div class="content">
1845
1999
  <div class="text">
1846
2000
  <span class="actor">${this.getActorName(e.actorId)}</span>
1847
- ${Ui[e.type]??e.type}
2001
+ ${Gi[e.type]??e.type}
1848
2002
  </div>
1849
2003
  <div class="time">${this.formatTime(e.createdAt)}</div>
1850
2004
  </div>
@@ -1853,7 +2007,7 @@
1853
2007
  `)}
1854
2008
  </div>
1855
2009
  </div>
1856
- `}};ie.styles=[K,le,ve,S`
2010
+ `}};ie.styles=[K,le,xe,A`
1857
2011
  :host {
1858
2012
  display: block;
1859
2013
  }
@@ -2044,7 +2198,7 @@
2044
2198
  min-height: 44px;
2045
2199
  }
2046
2200
  }
2047
- `];je([m({attribute:!1})],ie.prototype,"client",2);je([b()],ie.prototype,"notifications",2);ie=je([I("pulse-widget-notifications-panel")],ie);const Ni=3e3;class Bi{constructor(e){this.container=null,this.cursors=new Map,this.cursorEls=new Map,this.cursorLastSeen=new Map,this.unsubs=[],this.enabled=!1,this.sending=!1,this.staleTimer=null,this.handleLocalCursor=t=>{t.pointerType!=="touch"&&this.client.moveCursor({x:t.clientX,y:t.clientY,pageX:t.pageX,pageY:t.pageY})},this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-cursors",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9998",overflow:"hidden"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("cursor",({userId:e,position:t})=>{const i=this.cursors.get(e);if(i)i.position=t;else{const s=this.client.state.presence.find(r=>r.user.id===e);s&&this.cursors.set(e,{userId:e,name:s.user.name,color:s.user.color,position:t})}this.cursorLastSeen.set(e,Date.now()),this.renderCursor(e)})),this.unsubs.push(this.client.state.on("presence",e=>{var i;const t=new Set(e.map(s=>s.user.id));for(const s of this.cursors.keys())t.has(s)||(this.cursors.delete(s),(i=this.cursorEls.get(s))==null||i.remove(),this.cursorEls.delete(s),this.cursorLastSeen.delete(s))})),this.setSending(!0),this.staleTimer=setInterval(()=>{const e=Date.now();for(const[t,i]of this.cursorLastSeen)if(e-i>Ni){this.cursors.delete(t);const s=this.cursorEls.get(t);s&&s.remove(),this.cursorEls.delete(t),this.cursorLastSeen.delete(t)}},1e3))}disable(){var e;this.enabled&&(this.enabled=!1,this.setSending(!1),this.unsubs.forEach(t=>t()),this.unsubs=[],this.staleTimer&&(clearInterval(this.staleTimer),this.staleTimer=null),(e=this.container)==null||e.remove(),this.container=null,this.cursors.clear(),this.cursorEls.clear(),this.cursorLastSeen.clear())}get isEnabled(){return this.enabled}get isSending(){return this.sending}setSending(e){e!==this.sending&&(this.sending=e,e?document.addEventListener("pointermove",this.handleLocalCursor):document.removeEventListener("pointermove",this.handleLocalCursor))}setReceiving(e){this.container&&(this.container.style.display=e?"":"none")}showClickRipple(e,t){if(!this.container)return;const i=this.client.state.presence.find(o=>o.user.id===e),s=(i==null?void 0:i.user.color)??"#6366f1",r=document.createElement("div");Object.assign(r.style,{position:"absolute",left:`${t.x}px`,top:`${t.y}px`,width:"0px",height:"0px",borderRadius:"50%",border:`3px solid ${s}`,transform:"translate(-50%, -50%)",pointerEvents:"none",opacity:"1",transition:"width 0.6s ease-out, height 0.6s ease-out, opacity 0.6s ease-out"}),this.container.appendChild(r),requestAnimationFrame(()=>{r.style.width="60px",r.style.height="60px",r.style.opacity="0"}),setTimeout(()=>r.remove(),600)}showEmojiDrop(e,t,i){if(!this.container)return;const s=document.createElement("div");Object.assign(s.style,{position:"absolute",left:`${i.x}px`,top:`${i.y}px`,fontSize:"32px",pointerEvents:"none",transition:"transform 2s ease-out, opacity 2s ease-out",transform:"translate(-50%, 0)",zIndex:"10",lineHeight:"1"}),s.textContent=t,this.container.appendChild(s),requestAnimationFrame(()=>{s.style.transform="translate(-50%, -80px)",s.style.opacity="0"}),setTimeout(()=>s.remove(),2e3)}destroy(){this.disable()}renderCursor(e){if(!this.container)return;const t=this.cursors.get(e);if(!t)return;let i=this.cursorEls.get(e);if(!i){i=document.createElement("div"),Object.assign(i.style,{position:"absolute",transition:"transform 60ms cubic-bezier(0.22,1,0.36,1)",willChange:"transform",pointerEvents:"none"});const s=t.color||"#e74c3c";i.innerHTML=`
2201
+ `];je([g({attribute:!1})],ie.prototype,"client",2);je([v()],ie.prototype,"notifications",2);ie=je([O("pulse-widget-notifications-panel")],ie);const Zi=3e3;class Qi{constructor(e){this.container=null,this.cursors=new Map,this.cursorEls=new Map,this.cursorLastSeen=new Map,this.unsubs=[],this.enabled=!1,this.sending=!1,this.staleTimer=null,this.handleLocalCursor=t=>{t.pointerType!=="touch"&&this.client.moveCursor({x:t.clientX,y:t.clientY,pageX:t.pageX,pageY:t.pageY})},this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-cursors",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9998",overflow:"hidden"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("cursor",({userId:e,position:t})=>{const i=this.cursors.get(e);if(i)i.position=t;else{const s=this.client.state.presence.find(r=>r.user.id===e);s&&this.cursors.set(e,{userId:e,name:s.user.name,color:s.user.color,position:t})}this.cursorLastSeen.set(e,Date.now()),this.renderCursor(e)})),this.unsubs.push(this.client.state.on("presence",e=>{var i;const t=new Set(e.map(s=>s.user.id));for(const s of this.cursors.keys())t.has(s)||(this.cursors.delete(s),(i=this.cursorEls.get(s))==null||i.remove(),this.cursorEls.delete(s),this.cursorLastSeen.delete(s))})),this.setSending(!0),this.staleTimer=setInterval(()=>{const e=Date.now();for(const[t,i]of this.cursorLastSeen)if(e-i>Zi){this.cursors.delete(t);const s=this.cursorEls.get(t);s&&s.remove(),this.cursorEls.delete(t),this.cursorLastSeen.delete(t)}},1e3))}disable(){var e;this.enabled&&(this.enabled=!1,this.setSending(!1),this.unsubs.forEach(t=>t()),this.unsubs=[],this.staleTimer&&(clearInterval(this.staleTimer),this.staleTimer=null),(e=this.container)==null||e.remove(),this.container=null,this.cursors.clear(),this.cursorEls.clear(),this.cursorLastSeen.clear())}get isEnabled(){return this.enabled}get isSending(){return this.sending}setSending(e){e!==this.sending&&(this.sending=e,e?document.addEventListener("pointermove",this.handleLocalCursor):document.removeEventListener("pointermove",this.handleLocalCursor))}setReceiving(e){this.container&&(this.container.style.display=e?"":"none")}showClickRipple(e,t){if(!this.container)return;const i=this.client.state.presence.find(o=>o.user.id===e),s=(i==null?void 0:i.user.color)??"#6366f1",r=document.createElement("div");Object.assign(r.style,{position:"absolute",left:`${t.x}px`,top:`${t.y}px`,width:"0px",height:"0px",borderRadius:"50%",border:`3px solid ${s}`,transform:"translate(-50%, -50%)",pointerEvents:"none",opacity:"1",transition:"width 0.6s ease-out, height 0.6s ease-out, opacity 0.6s ease-out"}),this.container.appendChild(r),requestAnimationFrame(()=>{r.style.width="60px",r.style.height="60px",r.style.opacity="0"}),setTimeout(()=>r.remove(),600)}showEmojiDrop(e,t,i){if(!this.container)return;const s=document.createElement("div");Object.assign(s.style,{position:"absolute",left:`${i.x}px`,top:`${i.y}px`,fontSize:"32px",pointerEvents:"none",transition:"transform 2s ease-out, opacity 2s ease-out",transform:"translate(-50%, 0)",zIndex:"10",lineHeight:"1"}),s.textContent=t,this.container.appendChild(s),requestAnimationFrame(()=>{s.style.transform="translate(-50%, -80px)",s.style.opacity="0"}),setTimeout(()=>s.remove(),2e3)}destroy(){this.disable()}renderCursor(e){if(!this.container)return;const t=this.cursors.get(e);if(!t)return;let i=this.cursorEls.get(e);if(!i){i=document.createElement("div"),Object.assign(i.style,{position:"absolute",transition:"transform 60ms cubic-bezier(0.22,1,0.36,1)",willChange:"transform",pointerEvents:"none"});const s=t.color||"#e74c3c";i.innerHTML=`
2048
2202
  <svg width="24" height="24" viewBox="0 0 16 16" fill="${s}" style="filter:drop-shadow(0 2px 4px rgba(0,0,0,0.4))">
2049
2203
  <path d="M0 0l6.5 16L8 9l7-2.5z" stroke="#fff" stroke-width="1"/>
2050
2204
  </svg>
@@ -2058,7 +2212,7 @@
2058
2212
  box-shadow:0 2px 10px rgba(0,0,0,0.25);
2059
2213
  letter-spacing:0.01em;
2060
2214
  ">${t.name}</span>
2061
- `,this.container.appendChild(i),this.cursorEls.set(e,i)}i.style.transform=`translate(${t.position.x}px, ${t.position.y}px)`}}class Fi{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.drawMode=!1,this.currentPoints=[],this.currentPath=null,this.lastPoint=null,this.fadeTimers=new Map,this.handlePointerDown=t=>{var l,a,c;t.preventDefault(),(a=(l=t.target)==null?void 0:l.setPointerCapture)==null||a.call(l,t.pointerId),this.currentPoints=[{x:t.clientX,y:t.clientY}],this.lastPoint={x:t.clientX,y:t.clientY};const i=this.client.state.user,s=(i==null?void 0:i.color)??"#6366f1",o=2+(t.pressure>0?t.pressure:.5)*4;this.currentPath=document.createElementNS("http://www.w3.org/2000/svg","polyline"),this.currentPath.setAttribute("fill","none"),this.currentPath.setAttribute("stroke",s),this.currentPath.setAttribute("stroke-width",String(o)),this.currentPath.setAttribute("stroke-linecap","round"),this.currentPath.setAttribute("stroke-linejoin","round"),this.currentPath.setAttribute("points",`${t.clientX},${t.clientY}`),(c=this.container)==null||c.appendChild(this.currentPath),document.addEventListener("pointermove",this.handlePointerMove),document.addEventListener("pointerup",this.handlePointerUp)},this.handlePointerMove=t=>{if(!this.currentPath||!this.lastPoint)return;const i=t.clientX-this.lastPoint.x,s=t.clientY-this.lastPoint.y;if(i*i+s*s<4)return;this.currentPoints.push({x:t.clientX,y:t.clientY}),this.lastPoint={x:t.clientX,y:t.clientY};const r=this.currentPoints.map(o=>`${o.x},${o.y}`).join(" ");this.currentPath.setAttribute("points",r)},this.handlePointerUp=()=>{var t;if(document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.currentPoints.length>1){const i=this.client.state.user,s=(i==null?void 0:i.color)??"#6366f1";this.client.drawStroke(this.currentPoints,s,3),this.currentPath&&this.scheduleFade(this.currentPath)}else(t=this.currentPath)==null||t.remove();this.currentPoints=[],this.currentPath=null,this.lastPoint=null},this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.container.id="pulse-widget-drawing",this.container.setAttribute("style","position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:9989;"),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("draw-stroke",({userId:e,points:t,color:i,width:s})=>{this.renderStroke(t,i,s)})),this.unsubs.push(this.client.state.on("draw-clear",({userId:e})=>{})))}disable(){var e;if(this.enabled){this.enabled=!1,this.disableDrawMode(),this.unsubs.forEach(t=>t()),this.unsubs=[];for(const t of this.fadeTimers.values())clearTimeout(t);this.fadeTimers.clear(),(e=this.container)==null||e.remove(),this.container=null}}destroy(){this.disable()}enableDrawMode(){!this.container||this.drawMode||(this.drawMode=!0,this.container.style.pointerEvents="auto",this.container.style.cursor="crosshair",this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.handlePointerDown))}disableDrawMode(){this.drawMode&&(this.drawMode=!1,this.container&&(this.container.style.pointerEvents="none",this.container.style.cursor="",this.container.style.touchAction="",this.container.removeEventListener("pointerdown",this.handlePointerDown)),document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.currentPoints=[],this.currentPath=null,this.lastPoint=null)}renderStroke(e,t,i){if(!this.container||e.length<2)return;const s=document.createElementNS("http://www.w3.org/2000/svg","polyline");s.setAttribute("fill","none"),s.setAttribute("stroke",t),s.setAttribute("stroke-width",String(i)),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),s.setAttribute("points",e.map(r=>`${r.x},${r.y}`).join(" ")),s.style.willChange="opacity",this.container.appendChild(s),this.scheduleFade(s)}scheduleFade(e){const t=setTimeout(()=>{e.style.transition="opacity 1s ease-out",e.style.opacity="0",setTimeout(()=>{e.remove(),this.fadeTimers.delete(e)},1e3)},1e4);this.fadeTimers.set(e,t)}}function Wi(n){if(!n.rangeCount||n.isCollapsed)return null;const e=n.getRangeAt(0),t=e.startContainer,i=e.endContainer,s=it(t),r=it(i);return!s||!r?null:{startSelector:s,startOffset:e.startOffset,endSelector:r,endOffset:e.endOffset}}function qi(n){var e,t;try{const i=nt(n.startSelector),s=nt(n.endSelector);if(!i||!s)return null;const r=document.createRange(),o=i.nodeType===Node.TEXT_NODE?((e=i.textContent)==null?void 0:e.length)??0:i.childNodes.length,l=s.nodeType===Node.TEXT_NODE?((t=s.textContent)==null?void 0:t.length)??0:s.childNodes.length;return r.setStart(i,Math.min(n.startOffset,o)),r.setEnd(s,Math.min(n.endOffset,l)),r}catch{return null}}function it(n){if(n.nodeType===Node.TEXT_NODE){const e=n.parentElement;if(!e)return null;const t=st(e);if(!t)return null;const i=Array.from(e.childNodes).indexOf(n);return`${t}::text(${i})`}return n.nodeType===Node.ELEMENT_NODE?st(n):null}function st(n){if(!n||n===document.documentElement)return"html";if(n===document.body)return"body";if(n.id)return`#${CSS.escape(n.id)}`;const e=[];let t=n,i=0;for(;t&&t!==document.body&&i<10;){const s=t.parentElement;if(!s)break;const r=t.tagName.toLowerCase(),o=t.tagName,l=Array.from(s.children).filter(a=>a.tagName===o);if(l.length===1)e.unshift(r);else{const a=l.indexOf(t)+1;e.unshift(`${r}:nth-of-type(${a})`)}if(s.id){e.unshift(`#${CSS.escape(s.id)}`);break}t=s,i++}return e.length>0?e.join(" > "):null}function nt(n){const e=n.match(/^(.+)::text\((\d+)\)$/);if(e){const t=e[1],i=parseInt(e[2],10);try{const s=document.querySelector(t);return s?s.childNodes[i]??null:null}catch{return null}}try{return document.querySelector(n)}catch{return null}}class Vi{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.selectionEls=new Map,this.clearTimers=new Map,this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-selections",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9995"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("selection",({userId:e,selection:t})=>{this.renderSelection(e,t)})),this.unsubs.push(this.client.state.on("presence",e=>{const t=new Set(e.map(i=>i.user.id));for(const i of this.selectionEls.keys())t.has(i)||this.clearSelection(i)})))}disable(){var e;if(this.enabled){this.enabled=!1,this.unsubs.forEach(t=>t()),this.unsubs=[];for(const t of this.clearTimers.values())clearTimeout(t);this.clearTimers.clear(),(e=this.container)==null||e.remove(),this.container=null,this.selectionEls.clear()}}destroy(){this.disable()}renderSelection(e,t){var l;if(!this.container)return;const i=(l=this.client.state.user)==null?void 0:l.id;if(e===i||(this.clearSelection(e),!t))return;const s=qi(t);if(!s)return;const r=this.client.state.presence.find(a=>a.user.id===e),o=(r==null?void 0:r.user.color)??"#6366f1";try{const a=s.getClientRects(),c=[];for(let p=0;p<a.length;p++){const h=a[p],f=document.createElement("div");Object.assign(f.style,{position:"absolute",left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`,background:o,opacity:"0.2",borderRadius:"2px",pointerEvents:"none"}),this.container.appendChild(f),c.push(f)}this.selectionEls.set(e,c)}catch{}this.clearTimers.has(e)&&clearTimeout(this.clearTimers.get(e)),this.clearTimers.set(e,setTimeout(()=>{this.clearSelection(e),this.clearTimers.delete(e)},5e3))}clearSelection(e){const t=this.selectionEls.get(e);if(t){for(const i of t)i.remove();this.selectionEls.delete(e)}}}var Yi=Object.defineProperty,Xi=Object.getOwnPropertyDescriptor,Le=(n,e,t,i)=>{for(var s=i>1?void 0:i?Xi(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yi(e,t,s),s};let se=class extends P{constructor(){super(...arguments),this.roomId=""}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}toggle(n){const e={...this.settings,[n]:!this.settings[n]};this.dispatchEvent(new CustomEvent("settings-change",{detail:e,bubbles:!0,composed:!0}))}renderToggle(n,e){return d`
2215
+ `,this.container.appendChild(i),this.cursorEls.set(e,i)}i.style.transform=`translate(${t.position.x}px, ${t.position.y}px)`}}class es{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.drawMode=!1,this.currentPoints=[],this.currentPath=null,this.lastPoint=null,this.fadeTimers=new Map,this.handlePointerDown=t=>{var l,a,c;t.preventDefault(),(a=(l=t.target)==null?void 0:l.setPointerCapture)==null||a.call(l,t.pointerId),this.currentPoints=[{x:t.clientX,y:t.clientY}],this.lastPoint={x:t.clientX,y:t.clientY};const i=this.client.state.user,s=(i==null?void 0:i.color)??"#6366f1",o=2+(t.pressure>0?t.pressure:.5)*4;this.currentPath=document.createElementNS("http://www.w3.org/2000/svg","polyline"),this.currentPath.setAttribute("fill","none"),this.currentPath.setAttribute("stroke",s),this.currentPath.setAttribute("stroke-width",String(o)),this.currentPath.setAttribute("stroke-linecap","round"),this.currentPath.setAttribute("stroke-linejoin","round"),this.currentPath.setAttribute("points",`${t.clientX},${t.clientY}`),(c=this.container)==null||c.appendChild(this.currentPath),document.addEventListener("pointermove",this.handlePointerMove),document.addEventListener("pointerup",this.handlePointerUp)},this.handlePointerMove=t=>{if(!this.currentPath||!this.lastPoint)return;const i=t.clientX-this.lastPoint.x,s=t.clientY-this.lastPoint.y;if(i*i+s*s<4)return;this.currentPoints.push({x:t.clientX,y:t.clientY}),this.lastPoint={x:t.clientX,y:t.clientY};const r=this.currentPoints.map(o=>`${o.x},${o.y}`).join(" ");this.currentPath.setAttribute("points",r)},this.handlePointerUp=()=>{var t;if(document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.currentPoints.length>1){const i=this.client.state.user,s=(i==null?void 0:i.color)??"#6366f1";this.client.drawStroke(this.currentPoints,s,3),this.currentPath&&this.scheduleFade(this.currentPath)}else(t=this.currentPath)==null||t.remove();this.currentPoints=[],this.currentPath=null,this.lastPoint=null},this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.container.id="pulse-widget-drawing",this.container.setAttribute("style","position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:9989;"),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("draw-stroke",({userId:e,points:t,color:i,width:s})=>{this.renderStroke(t,i,s)})),this.unsubs.push(this.client.state.on("draw-clear",({userId:e})=>{})))}disable(){var e;if(this.enabled){this.enabled=!1,this.disableDrawMode(),this.unsubs.forEach(t=>t()),this.unsubs=[];for(const t of this.fadeTimers.values())clearTimeout(t);this.fadeTimers.clear(),(e=this.container)==null||e.remove(),this.container=null}}destroy(){this.disable()}enableDrawMode(){!this.container||this.drawMode||(this.drawMode=!0,this.container.style.pointerEvents="auto",this.container.style.cursor="crosshair",this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.handlePointerDown))}disableDrawMode(){this.drawMode&&(this.drawMode=!1,this.container&&(this.container.style.pointerEvents="none",this.container.style.cursor="",this.container.style.touchAction="",this.container.removeEventListener("pointerdown",this.handlePointerDown)),document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.currentPoints=[],this.currentPath=null,this.lastPoint=null)}renderStroke(e,t,i){if(!this.container||e.length<2)return;const s=document.createElementNS("http://www.w3.org/2000/svg","polyline");s.setAttribute("fill","none"),s.setAttribute("stroke",t),s.setAttribute("stroke-width",String(i)),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),s.setAttribute("points",e.map(r=>`${r.x},${r.y}`).join(" ")),s.style.willChange="opacity",this.container.appendChild(s),this.scheduleFade(s)}scheduleFade(e){const t=setTimeout(()=>{e.style.transition="opacity 1s ease-out",e.style.opacity="0",setTimeout(()=>{e.remove(),this.fadeTimers.delete(e)},1e3)},1e4);this.fadeTimers.set(e,t)}}function ts(n){if(!n.rangeCount||n.isCollapsed)return null;const e=n.getRangeAt(0),t=e.startContainer,i=e.endContainer,s=rt(t),r=rt(i);return!s||!r?null:{startSelector:s,startOffset:e.startOffset,endSelector:r,endOffset:e.endOffset}}function is(n){var e,t;try{const i=lt(n.startSelector),s=lt(n.endSelector);if(!i||!s)return null;const r=document.createRange(),o=i.nodeType===Node.TEXT_NODE?((e=i.textContent)==null?void 0:e.length)??0:i.childNodes.length,l=s.nodeType===Node.TEXT_NODE?((t=s.textContent)==null?void 0:t.length)??0:s.childNodes.length;return r.setStart(i,Math.min(n.startOffset,o)),r.setEnd(s,Math.min(n.endOffset,l)),r}catch{return null}}function rt(n){if(n.nodeType===Node.TEXT_NODE){const e=n.parentElement;if(!e)return null;const t=at(e);if(!t)return null;const i=Array.from(e.childNodes).indexOf(n);return`${t}::text(${i})`}return n.nodeType===Node.ELEMENT_NODE?at(n):null}function at(n){if(!n||n===document.documentElement)return"html";if(n===document.body)return"body";if(n.id)return`#${CSS.escape(n.id)}`;const e=[];let t=n,i=0;for(;t&&t!==document.body&&i<10;){const s=t.parentElement;if(!s)break;const r=t.tagName.toLowerCase(),o=t.tagName,l=Array.from(s.children).filter(a=>a.tagName===o);if(l.length===1)e.unshift(r);else{const a=l.indexOf(t)+1;e.unshift(`${r}:nth-of-type(${a})`)}if(s.id){e.unshift(`#${CSS.escape(s.id)}`);break}t=s,i++}return e.length>0?e.join(" > "):null}function lt(n){const e=n.match(/^(.+)::text\((\d+)\)$/);if(e){const t=e[1],i=parseInt(e[2],10);try{const s=document.querySelector(t);return s?s.childNodes[i]??null:null}catch{return null}}try{return document.querySelector(n)}catch{return null}}class ss{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.selectionEls=new Map,this.clearTimers=new Map,this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-selections",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9995"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("selection",({userId:e,selection:t})=>{this.renderSelection(e,t)})),this.unsubs.push(this.client.state.on("presence",e=>{const t=new Set(e.map(i=>i.user.id));for(const i of this.selectionEls.keys())t.has(i)||this.clearSelection(i)})))}disable(){var e;if(this.enabled){this.enabled=!1,this.unsubs.forEach(t=>t()),this.unsubs=[];for(const t of this.clearTimers.values())clearTimeout(t);this.clearTimers.clear(),(e=this.container)==null||e.remove(),this.container=null,this.selectionEls.clear()}}destroy(){this.disable()}renderSelection(e,t){var l;if(!this.container)return;const i=(l=this.client.state.user)==null?void 0:l.id;if(e===i||(this.clearSelection(e),!t))return;const s=is(t);if(!s)return;const r=this.client.state.presence.find(a=>a.user.id===e),o=(r==null?void 0:r.user.color)??"#6366f1";try{const a=s.getClientRects(),c=[];for(let h=0;h<a.length;h++){const p=a[h],m=document.createElement("div");Object.assign(m.style,{position:"absolute",left:`${p.left}px`,top:`${p.top}px`,width:`${p.width}px`,height:`${p.height}px`,background:o,opacity:"0.2",borderRadius:"2px",pointerEvents:"none"}),this.container.appendChild(m),c.push(m)}this.selectionEls.set(e,c)}catch{}this.clearTimers.has(e)&&clearTimeout(this.clearTimers.get(e)),this.clearTimers.set(e,setTimeout(()=>{this.clearSelection(e),this.clearTimers.delete(e)},5e3))}clearSelection(e){const t=this.selectionEls.get(e);if(t){for(const i of t)i.remove();this.selectionEls.delete(e)}}}var ns=Object.defineProperty,os=Object.getOwnPropertyDescriptor,ze=(n,e,t,i)=>{for(var s=i>1?void 0:i?os(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ns(e,t,s),s};let se=class extends _{constructor(){super(...arguments),this.roomId=""}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}toggle(n){const e={...this.settings,[n]:!this.settings[n]};this.dispatchEvent(new CustomEvent("settings-change",{detail:e,bubbles:!0,composed:!0}))}renderToggle(n,e){return d`
2062
2216
  <div class="setting-row">
2063
2217
  <span class="setting-label">${n}</span>
2064
2218
  <label class="toggle">
@@ -2075,7 +2229,7 @@
2075
2229
  <div class="panel-header">
2076
2230
  <span class="panel-title">Settings</span>
2077
2231
  <button class="close-btn" @click=${this.fireClose} title="Close">
2078
- ${E(ae,16)}
2232
+ ${C(ae,16)}
2079
2233
  </button>
2080
2234
  </div>
2081
2235
 
@@ -2117,7 +2271,7 @@
2117
2271
  ${this.renderToggle("Show drawings","showDrawings")}
2118
2272
  </div>
2119
2273
  </div>
2120
- `}};se.styles=[K,le,ve,S`
2274
+ `}};se.styles=[K,le,xe,A`
2121
2275
  :host {
2122
2276
  display: block;
2123
2277
  }
@@ -2286,9 +2440,9 @@
2286
2440
  min-height: 44px;
2287
2441
  }
2288
2442
  }
2289
- `];Le([m({attribute:!1})],se.prototype,"settings",2);Le([m()],se.prototype,"roomId",2);se=Le([I("pulse-widget-settings-panel")],se);const he={enabled:!0,showMyCursor:!0,showOthersCursors:!0,showMyClicks:!0,showOthersClicks:!0,appearOffline:!1,showCommentPins:!0,showViewportIndicators:!0,showSelections:!0,showDrawings:!0},gt="pulse:settings:";function Ki(n){try{const e=localStorage.getItem(`${gt}${n}`);return e?{...he,...JSON.parse(e)}:{...he}}catch{return{...he}}}function Gi(n,e){localStorage.setItem(`${gt}${n}`,JSON.stringify(e))}var Ji=Object.defineProperty,Zi=Object.getOwnPropertyDescriptor,j=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zi(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ji(e,t,s),s};let M=class extends P{constructor(){super(...arguments),this.collapsed=!1,this.activePanel=null,this.pinModeActive=!1,this.featuresDisabled=!1,this.drawModeActive=!1,this.followingUserId=null,this.display="floating",this.users=[],this.unreadCount=0}connectedCallback(){super.connectedCallback(),this.setupPresence()}disconnectedCallback(){var n,e;super.disconnectedCallback(),(n=this.unsub)==null||n.call(this),(e=this.notifUnsub)==null||e.call(this)}updated(n){var e,t;n.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),(t=this.notifUnsub)==null||t.call(this),this.setupPresence())}setupPresence(){this.client&&(this.users=this.client.state.presence,this.unreadCount=this.client.state.unreadCount,this.unsub=this.client.state.on("presence",n=>{this.users=n}),this.notifUnsub=this.client.state.on("notifications",()=>{this.unreadCount=this.client.state.unreadCount}))}getInitials(n){return n.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}fire(n){this.dispatchEvent(new CustomEvent("toolbar-action",{detail:n,bubbles:!0,composed:!0}))}fireFollow(n){this.dispatchEvent(new CustomEvent("toolbar-follow",{detail:n,bubbles:!0,composed:!0}))}fireToggle(){this.dispatchEvent(new CustomEvent("toolbar-toggle",{bubbles:!0,composed:!0}))}render(){const n=this.display==="inline";if(this.collapsed)return d`
2443
+ `];ze([g({attribute:!1})],se.prototype,"settings",2);ze([g()],se.prototype,"roomId",2);se=ze([O("pulse-widget-settings-panel")],se);const pe={enabled:!0,showMyCursor:!0,showOthersCursors:!0,showMyClicks:!0,showOthersClicks:!0,appearOffline:!1,showCommentPins:!0,showViewportIndicators:!0,showSelections:!0,showDrawings:!0},yt="pulse:settings:";function rs(n){try{const e=localStorage.getItem(`${yt}${n}`);return e?{...pe,...JSON.parse(e)}:{...pe}}catch{return{...pe}}}function as(n,e){localStorage.setItem(`${yt}${n}`,JSON.stringify(e))}var ls=Object.defineProperty,cs=Object.getOwnPropertyDescriptor,R=(n,e,t,i)=>{for(var s=i>1?void 0:i?cs(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ls(e,t,s),s};let M=class extends _{constructor(){super(...arguments),this.collapsed=!1,this.activePanel=null,this.pinModeActive=!1,this.featuresDisabled=!1,this.drawModeActive=!1,this.followingUserId=null,this.display="floating",this.users=[],this.unreadCount=0}connectedCallback(){super.connectedCallback(),this.setupPresence()}disconnectedCallback(){var n,e;super.disconnectedCallback(),(n=this.unsub)==null||n.call(this),(e=this.notifUnsub)==null||e.call(this)}updated(n){var e,t;n.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),(t=this.notifUnsub)==null||t.call(this),this.setupPresence())}setupPresence(){this.client&&(this.users=this.client.state.presence,this.unreadCount=this.client.state.unreadCount,this.unsub=this.client.state.on("presence",n=>{this.users=n}),this.notifUnsub=this.client.state.on("notifications",()=>{this.unreadCount=this.client.state.unreadCount}))}getInitials(n){return n.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}fire(n){this.dispatchEvent(new CustomEvent("toolbar-action",{detail:n,bubbles:!0,composed:!0}))}fireFollow(n){this.dispatchEvent(new CustomEvent("toolbar-follow",{detail:n,bubbles:!0,composed:!0}))}fireToggle(){this.dispatchEvent(new CustomEvent("toolbar-toggle",{bubbles:!0,composed:!0}))}render(){const n=this.display==="inline";if(this.collapsed)return d`
2290
2444
  <div class="toolbar collapsed ${n?"inline":""}" @click=${this.fireToggle}>
2291
- <span class="fab-icon">${E(xi,n?18:24)}</span>
2445
+ <span class="fab-icon">${C(Ei,n?18:24)}</span>
2292
2446
  </div>
2293
2447
  `;const e=this.users.slice(0,3),t=this.users.length-3;return d`
2294
2448
  <div class="toolbar ${n?"inline":""}"
@@ -2320,7 +2474,7 @@
2320
2474
  ?disabled=${this.featuresDisabled}
2321
2475
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
2322
2476
  >
2323
- ${E(ft)}
2477
+ ${C(vt)}
2324
2478
  </button>
2325
2479
 
2326
2480
  <!-- View comments -->
@@ -2331,7 +2485,7 @@
2331
2485
  ?disabled=${this.featuresDisabled}
2332
2486
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
2333
2487
  >
2334
- ${E(fi)}
2488
+ ${C(vi)}
2335
2489
  </button>
2336
2490
 
2337
2491
  <!-- Activity feed -->
@@ -2342,7 +2496,7 @@
2342
2496
  ?disabled=${this.featuresDisabled}
2343
2497
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
2344
2498
  >
2345
- ${E(ui)}
2499
+ ${C(bi)}
2346
2500
  </button>
2347
2501
 
2348
2502
  <!-- Draw mode -->
@@ -2353,7 +2507,7 @@
2353
2507
  ?disabled=${this.featuresDisabled}
2354
2508
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
2355
2509
  >
2356
- ${E(mi)}
2510
+ ${C(wi)}
2357
2511
  </button>
2358
2512
 
2359
2513
  <!-- Notifications -->
@@ -2364,7 +2518,7 @@
2364
2518
  ?disabled=${this.featuresDisabled}
2365
2519
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":"position:relative"}"
2366
2520
  >
2367
- ${E(hi)}
2521
+ ${C(gi)}
2368
2522
  ${this.unreadCount>0?d`<span class="badge">${this.unreadCount>9?"9+":this.unreadCount}</span>`:u}
2369
2523
  </button>
2370
2524
 
@@ -2374,7 +2528,7 @@
2374
2528
  @click=${()=>this.fire("settings")}
2375
2529
  title="Settings"
2376
2530
  >
2377
- ${E(bi)}
2531
+ ${C(ki)}
2378
2532
  </button>
2379
2533
 
2380
2534
  <div class="separator"></div>
@@ -2385,10 +2539,10 @@
2385
2539
  @click=${this.fireToggle}
2386
2540
  title="Collapse"
2387
2541
  >
2388
- ${E(ae,14)}
2542
+ ${C(ae,14)}
2389
2543
  </button>
2390
2544
  </div>
2391
- `}};M.styles=[K,le,S`
2545
+ `}};M.styles=[K,le,A`
2392
2546
  :host {
2393
2547
  display: block;
2394
2548
  }
@@ -2598,7 +2752,7 @@
2598
2752
  height: 32px;
2599
2753
  }
2600
2754
  }
2601
- `];j([m({attribute:!1})],M.prototype,"client",2);j([m({type:Boolean})],M.prototype,"collapsed",2);j([m()],M.prototype,"activePanel",2);j([m({type:Boolean})],M.prototype,"pinModeActive",2);j([m({type:Boolean})],M.prototype,"featuresDisabled",2);j([m({type:Boolean})],M.prototype,"drawModeActive",2);j([m()],M.prototype,"followingUserId",2);j([m()],M.prototype,"display",2);j([b()],M.prototype,"users",2);j([b()],M.prototype,"unreadCount",2);M=j([I("pulse-widget-toolbar")],M);class Qi{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.pillEls=new Map,this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-viewports",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9996"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("viewport",()=>{this.render()})),this.unsubs.push(this.client.state.on("presence",()=>{this.render()})),this.render())}disable(){var e;this.enabled&&(this.enabled=!1,this.unsubs.forEach(t=>t()),this.unsubs=[],(e=this.container)==null||e.remove(),this.container=null,this.pillEls.clear())}destroy(){this.disable()}render(){var o;if(!this.container)return;if(document.documentElement.scrollHeight<=window.innerHeight){for(const l of this.pillEls.values())l.remove();this.pillEls.clear();return}const e=window.scrollY,t=window.innerHeight,i=document.documentElement.scrollHeight,s=(o=this.client.state.user)==null?void 0:o.id,r=new Set;for(const[l,a]of this.client.state.viewports){if(l===s)continue;const c=a.scrollY,p=a.scrollY+a.viewportHeight,h=e,f=e+t;if(c>=h&&p<=f){const y=this.pillEls.get(l);y&&(y.style.display="none");continue}r.add(l);const g=this.client.state.presence.find(y=>y.user.id===l);if(!g)continue;const $=a.scrollY+a.viewportHeight/2,A=i>0?$/i:0,k=Math.max(8,Math.min(t-28,A*t));let w=this.pillEls.get(l);w||(w=document.createElement("div"),Object.assign(w.style,{position:"absolute",right:"8px",padding:"2px 6px",borderRadius:"10px",fontSize:"10px",fontWeight:"700",color:"#fff",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",whiteSpace:"nowrap",pointerEvents:"none",transition:"top 0.3s ease"}),this.container.appendChild(w),this.pillEls.set(l,w)),w.style.display="",w.style.background=g.user.color,w.style.top=`${k}px`,w.textContent=this.getInitials(g.user.name)}for(const[l,a]of this.pillEls)!r.has(l)&&!this.client.state.viewports.has(l)&&(a.remove(),this.pillEls.delete(l))}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}}var es=Object.defineProperty,ts=Object.getOwnPropertyDescriptor,_=(n,e,t,i)=>{for(var s=i>1?void 0:i?ts(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&es(e,t,s),s};exports.PulseWidget=class extends P{constructor(){super(...arguments),this.apiKey="",this.token="",this.room="",this.position="bottom-right",this.display="floating",this.collapsed=!0,this.activePanel=null,this.pinModeActive=!1,this.highlightThreadId=null,this.settings={...he},this.followingUserId=null,this.drawModeActive=!1,this.connectionState="disconnected",this.showConnectedFlash=!1,this.unsubs=[],this.clientConfigKey="",this._isFollowScrolling=!1,this._viewportThrottleTimer=null,this._selectionThrottleTimer=null,this._connectedFlashTimer=null,this._wasDisconnected=!1,this.handleScroll=()=>{!this.settings.enabled||!this.client||this._isFollowScrolling||(this.followingUserId&&(this.followingUserId=null),!this._viewportThrottleTimer&&(this._viewportThrottleTimer=setTimeout(()=>{var e;this._viewportThrottleTimer=null,(e=this.client)==null||e.updateViewport({scrollX:window.scrollX,scrollY:window.scrollY,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,pageWidth:document.documentElement.scrollWidth,pageHeight:document.documentElement.scrollHeight})},200)))},this.handleSelectionChange=()=>{!this.settings.enabled||!this.settings.showSelections||!this.client||this._selectionThrottleTimer||(this._selectionThrottleTimer=setTimeout(()=>{var i,s;this._selectionThrottleTimer=null;const e=window.getSelection();if(!e||e.isCollapsed){(i=this.client)==null||i.updateSelection(null);return}const t=Wi(e);(s=this.client)==null||s.updateSelection(t)},500))},this.handleDocumentClick=e=>{var t;this.settings.enabled&&this.settings.showMyClicks&&(this.contains(e.target)||(t=this.client)==null||t.performClick({x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY}))},this.handleKeydown=e=>{var t,i;e.key==="Escape"&&(this.drawModeActive?((t=this.drawingOverlay)==null||t.disableDrawMode(),this.drawModeActive=!1):this.followingUserId?this.followingUserId=null:this.pinModeActive?((i=this.commentPins)==null||i.exitPinMode(),this.pinModeActive=!1):this.activePanel&&(this.activePanel=null,this.highlightThreadId=null))}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeydown),document.addEventListener("pointerup",this.handleDocumentClick),this.apiKey&&this.token&&this.room&&this.initClient()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("pointerup",this.handleDocumentClick),this.teardownClient()}getConfigKey(){return`${this.apiKey}\0${this.token}\0${this.room}\0${this.endpoint??""}`}initClient(){const e={apiKey:this.apiKey,token:this.token,room:this.room,endpoint:this.endpoint};this.client=new at(e),this.clientConfigKey=this.getConfigKey(),this.cursorOverlay=new Bi(this.client),this.commentPins=new Ii(this.client,{onPinModeExit:()=>{this.pinModeActive=!1}}),this.viewportOverlay=new Qi(this.client),this.selectionOverlay=new Vi(this.client),this.drawingOverlay=new Fi(this.client),this.settings=Ki(this.room),this.applySettings(this.settings),this.unsubs.push(this.client.on("connection",t=>{this.connectionState=t,t==="connected"&&this._wasDisconnected?(this.showConnectedFlash=!0,this._connectedFlashTimer&&clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=setTimeout(()=>{this.showConnectedFlash=!1,this._connectedFlashTimer=null},2e3),this._wasDisconnected=!1):(t==="connecting"||t==="disconnected")&&(this._wasDisconnected=!0,this.showConnectedFlash=!1,this._connectedFlashTimer&&(clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=null))})),this.unsubs.push(this.client.state.on("click",({userId:t,position:i})=>{var s;this.settings.showOthersClicks&&((s=this.cursorOverlay)!=null&&s.isEnabled)&&this.cursorOverlay.showClickRipple(t,i)})),this.unsubs.push(this.client.state.on("viewport",({userId:t})=>{if(this.followingUserId===t){const i=this.client.state.getViewport(t);i&&(this._isFollowScrolling=!0,window.scrollTo({top:i.scrollY,left:i.scrollX,behavior:"smooth"}),setTimeout(()=>{this._isFollowScrolling=!1},500))}})),window.addEventListener("scroll",this.handleScroll),document.addEventListener("selectionchange",this.handleSelectionChange),this.client.connect()}teardownClient(){var e,t,i,s,r,o;this.unsubs.forEach(l=>l()),this.unsubs=[],window.removeEventListener("scroll",this.handleScroll),document.removeEventListener("selectionchange",this.handleSelectionChange),this._viewportThrottleTimer&&(clearTimeout(this._viewportThrottleTimer),this._viewportThrottleTimer=null),this._selectionThrottleTimer&&(clearTimeout(this._selectionThrottleTimer),this._selectionThrottleTimer=null),(e=this.cursorOverlay)==null||e.destroy(),(t=this.commentPins)==null||t.destroy(),(i=this.viewportOverlay)==null||i.destroy(),(s=this.selectionOverlay)==null||s.destroy(),(r=this.drawingOverlay)==null||r.destroy(),(o=this.client)==null||o.disconnect(),this.client=void 0,this.cursorOverlay=void 0,this.commentPins=void 0,this.viewportOverlay=void 0,this.selectionOverlay=void 0,this.drawingOverlay=void 0,this.clientConfigKey="",this.followingUserId=null,this.drawModeActive=!1,this.connectionState="disconnected",this.showConnectedFlash=!1,this._wasDisconnected=!1,this._connectedFlashTimer&&(clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=null)}handlePanelClose(){this.activePanel=null,this.highlightThreadId=null}handleToolbarAction(e){var i,s,r,o;const t=e.detail;if(!(!this.settings.enabled&&t!=="settings"))switch(t){case"comments":this.activePanel=this.activePanel==="comments"?null:"comments",this.highlightThreadId=null;break;case"settings":this.activePanel=this.activePanel==="settings"?null:"settings";break;case"notifications":this.activePanel=this.activePanel==="notifications"?null:"notifications";break;case"activity":this.activePanel=this.activePanel==="activity"?null:"activity";break;case"pin-mode":this.pinModeActive=!this.pinModeActive,this.pinModeActive?(i=this.commentPins)==null||i.enterPinMode():(s=this.commentPins)==null||s.exitPinMode();break;case"draw-mode":this.drawModeActive=!this.drawModeActive,this.drawModeActive?(r=this.drawingOverlay)==null||r.enableDrawMode():(o=this.drawingOverlay)==null||o.disableDrawMode();break}}handleFollow(e){const t=e.detail;this.followingUserId===t?this.followingUserId=null:this.followingUserId=t}handleSettingsChange(e){const t=e.detail;this.settings=t,Gi(this.room,t),this.applySettings(t)}applySettings(e){var t,i,s,r,o,l,a,c,p,h,f,g,$,A,k,w,y;if(!e.enabled){(t=this.cursorOverlay)==null||t.disable(),(i=this.viewportOverlay)==null||i.disable(),(s=this.selectionOverlay)==null||s.disable(),(r=this.drawingOverlay)==null||r.disable(),this.drawModeActive&&((o=this.drawingOverlay)==null||o.disableDrawMode(),this.drawModeActive=!1),(l=this.client)==null||l.setAppearOffline(!0),(a=this.commentPins)==null||a.setVisible(!1),this.followingUserId=null,this.pinModeActive&&((c=this.commentPins)==null||c.exitPinMode(),this.pinModeActive=!1),this.activePanel=this.activePanel==="settings"?"settings":null,this.highlightThreadId=null;return}this.applyCursorSettings(e),(p=this.client)==null||p.setAppearOffline(e.appearOffline),(h=this.commentPins)==null||h.setVisible(e.showCommentPins),e.showViewportIndicators?(f=this.viewportOverlay)==null||f.enable():(g=this.viewportOverlay)==null||g.disable(),e.showSelections?($=this.selectionOverlay)==null||$.enable():(A=this.selectionOverlay)==null||A.disable(),e.showDrawings?(k=this.drawingOverlay)==null||k.enable():((w=this.drawingOverlay)==null||w.disable(),this.drawModeActive&&((y=this.drawingOverlay)==null||y.disableDrawMode(),this.drawModeActive=!1))}applyCursorSettings(e){if(!this.cursorOverlay)return;e.showMyCursor||e.showOthersCursors?(this.cursorOverlay.enable(),this.cursorOverlay.setSending(e.showMyCursor),this.cursorOverlay.setReceiving(e.showOthersCursors)):this.cursorOverlay.disable()}updated(e){(e.has("room")||e.has("token")||e.has("apiKey")||e.has("endpoint"))&&this.apiKey&&this.token&&this.room&&this.getConfigKey()!==this.clientConfigKey&&(this.teardownClient(),this.initClient(),this.activePanel=null,this.highlightThreadId=null,this.pinModeActive=!1),(e.has("activePanel")||e.has("collapsed"))&&requestAnimationFrame(()=>this.positionPopups())}positionPopups(){var A,k,w,y;const e=this.display==="inline",t=(A=this.shadowRoot)==null?void 0:A.querySelector(".inline-trigger"),i=(k=this.shadowRoot)==null?void 0:k.querySelector("pulse-widget-toolbar"),s=e?t:i;if(!s)return;const r=s.getBoundingClientRect(),o=window.innerWidth,l=window.innerHeight,a=8,c=(w=this.shadowRoot)==null?void 0:w.querySelector(".toolbar-popover");if(c){Object.assign(c.style,{top:"auto",left:"auto"});const T=c.getBoundingClientRect(),v=this.computePosition(r,T,o,l,a);c.style.top=`${v.top}px`,c.style.left=`${v.left}px`}const p=(y=this.shadowRoot)==null?void 0:y.querySelector(".panel-container");if(!p)return;Object.assign(p.style,{top:"auto",left:"auto"});const h=c??i;if(!h)return;const f=h.getBoundingClientRect(),g=p.getBoundingClientRect(),$=this.computePosition(f,g,o,l,a);p.style.top=`${$.top}px`,p.style.left=`${$.left}px`}computePosition(e,t,i,s,r){const o=e.top,l=s-e.bottom;let a;o>=t.height+r?a=e.top-t.height-r:l>=t.height+r?a=e.bottom+r:a=o>=l?Math.max(r,e.top-t.height-r):e.bottom+r;let c;const p=e.right-t.width;return p>=r?c=p:e.left+t.width+r<=i?c=e.left:c=Math.max(r,Math.min(i-t.width-r,e.left)),a=Math.max(r,Math.min(s-t.height-r,a)),c=Math.max(r,Math.min(i-t.width-r,c)),{top:a,left:c}}getFollowUserName(){var t;if(!this.followingUserId)return"";const e=(t=this.client)==null?void 0:t.state.presence.find(i=>i.user.id===this.followingUserId);return(e==null?void 0:e.user.name)??"user"}renderConnectionBanner(){return this.showConnectedFlash?d`<div class="connection-banner connected">
2755
+ `];R([g({attribute:!1})],M.prototype,"client",2);R([g({type:Boolean})],M.prototype,"collapsed",2);R([g()],M.prototype,"activePanel",2);R([g({type:Boolean})],M.prototype,"pinModeActive",2);R([g({type:Boolean})],M.prototype,"featuresDisabled",2);R([g({type:Boolean})],M.prototype,"drawModeActive",2);R([g()],M.prototype,"followingUserId",2);R([g()],M.prototype,"display",2);R([v()],M.prototype,"users",2);R([v()],M.prototype,"unreadCount",2);M=R([O("pulse-widget-toolbar")],M);class ds{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.pillEls=new Map,this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-viewports",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9996"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("viewport",()=>{this.render()})),this.unsubs.push(this.client.state.on("presence",()=>{this.render()})),this.render())}disable(){var e;this.enabled&&(this.enabled=!1,this.unsubs.forEach(t=>t()),this.unsubs=[],(e=this.container)==null||e.remove(),this.container=null,this.pillEls.clear())}destroy(){this.disable()}render(){var o;if(!this.container)return;if(document.documentElement.scrollHeight<=window.innerHeight){for(const l of this.pillEls.values())l.remove();this.pillEls.clear();return}const e=window.scrollY,t=window.innerHeight,i=document.documentElement.scrollHeight,s=(o=this.client.state.user)==null?void 0:o.id,r=new Set;for(const[l,a]of this.client.state.viewports){if(l===s)continue;const c=a.scrollY,h=a.scrollY+a.viewportHeight,p=e,m=e+t;if(c>=p&&h<=m){const $=this.pillEls.get(l);$&&($.style.display="none");continue}r.add(l);const f=this.client.state.presence.find($=>$.user.id===l);if(!f)continue;const b=a.scrollY+a.viewportHeight/2,y=i>0?b/i:0,E=Math.max(8,Math.min(t-28,y*t));let k=this.pillEls.get(l);k||(k=document.createElement("div"),Object.assign(k.style,{position:"absolute",right:"8px",padding:"2px 6px",borderRadius:"10px",fontSize:"10px",fontWeight:"700",color:"#fff",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",whiteSpace:"nowrap",pointerEvents:"none",transition:"top 0.3s ease"}),this.container.appendChild(k),this.pillEls.set(l,k)),k.style.display="",k.style.background=f.user.color,k.style.top=`${E}px`,k.textContent=this.getInitials(f.user.name)}for(const[l,a]of this.pillEls)!r.has(l)&&!this.client.state.viewports.has(l)&&(a.remove(),this.pillEls.delete(l))}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}}var hs=Object.defineProperty,ps=Object.getOwnPropertyDescriptor,T=(n,e,t,i)=>{for(var s=i>1?void 0:i?ps(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&hs(e,t,s),s};exports.PulseWidget=class extends _{constructor(){super(...arguments),this.apiKey="",this.token="",this.room="",this.position="bottom-right",this.display="floating",this.collapsed=!0,this.activePanel=null,this.pinModeActive=!1,this.highlightThreadId=null,this.settings={...pe},this.followingUserId=null,this.drawModeActive=!1,this.connectionState="disconnected",this.showConnectedFlash=!1,this.unsubs=[],this.clientConfigKey="",this._isFollowScrolling=!1,this._viewportThrottleTimer=null,this._selectionThrottleTimer=null,this._connectedFlashTimer=null,this._wasDisconnected=!1,this.handleScroll=()=>{!this.settings.enabled||!this.client||this._isFollowScrolling||(this.followingUserId&&(this.followingUserId=null),!this._viewportThrottleTimer&&(this._viewportThrottleTimer=setTimeout(()=>{var e;this._viewportThrottleTimer=null,(e=this.client)==null||e.updateViewport({scrollX:window.scrollX,scrollY:window.scrollY,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,pageWidth:document.documentElement.scrollWidth,pageHeight:document.documentElement.scrollHeight})},200)))},this.handleSelectionChange=()=>{!this.settings.enabled||!this.settings.showSelections||!this.client||this._selectionThrottleTimer||(this._selectionThrottleTimer=setTimeout(()=>{var i,s;this._selectionThrottleTimer=null;const e=window.getSelection();if(!e||e.isCollapsed){(i=this.client)==null||i.updateSelection(null);return}const t=ts(e);(s=this.client)==null||s.updateSelection(t)},500))},this.handleDocumentClick=e=>{var t;this.settings.enabled&&this.settings.showMyClicks&&(this.contains(e.target)||(t=this.client)==null||t.performClick({x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY}))},this.handleKeydown=e=>{var t,i;e.key==="Escape"&&(this.drawModeActive?((t=this.drawingOverlay)==null||t.disableDrawMode(),this.drawModeActive=!1):this.followingUserId?this.followingUserId=null:this.pinModeActive?((i=this.commentPins)==null||i.exitPinMode(),this.pinModeActive=!1):this.activePanel&&(this.activePanel=null,this.highlightThreadId=null))}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeydown),document.addEventListener("pointerup",this.handleDocumentClick),this.apiKey&&this.token&&this.room&&this.initClient()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("pointerup",this.handleDocumentClick),this.teardownClient()}getConfigKey(){return`${this.apiKey}\0${this.token}\0${this.room}\0${this.endpoint??""}`}initClient(){const e={apiKey:this.apiKey,token:this.token,room:this.room,endpoint:this.endpoint};this.client=new ht(e),this.clientConfigKey=this.getConfigKey(),this.cursorOverlay=new Qi(this.client),this.commentPins=new Wi(this.client,{onPinModeExit:()=>{this.pinModeActive=!1}}),this.viewportOverlay=new ds(this.client),this.selectionOverlay=new ss(this.client),this.drawingOverlay=new es(this.client),this.settings=rs(this.room),this.applySettings(this.settings),this.unsubs.push(this.client.on("connection",t=>{this.connectionState=t,t==="connected"&&this._wasDisconnected?(this.showConnectedFlash=!0,this._connectedFlashTimer&&clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=setTimeout(()=>{this.showConnectedFlash=!1,this._connectedFlashTimer=null},2e3),this._wasDisconnected=!1):(t==="connecting"||t==="disconnected")&&(this._wasDisconnected=!0,this.showConnectedFlash=!1,this._connectedFlashTimer&&(clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=null))})),this.unsubs.push(this.client.state.on("click",({userId:t,position:i})=>{var s;this.settings.showOthersClicks&&((s=this.cursorOverlay)!=null&&s.isEnabled)&&this.cursorOverlay.showClickRipple(t,i)})),this.unsubs.push(this.client.state.on("viewport",({userId:t})=>{if(this.followingUserId===t){const i=this.client.state.getViewport(t);i&&(this._isFollowScrolling=!0,window.scrollTo({top:i.scrollY,left:i.scrollX,behavior:"smooth"}),setTimeout(()=>{this._isFollowScrolling=!1},500))}})),window.addEventListener("scroll",this.handleScroll),document.addEventListener("selectionchange",this.handleSelectionChange),this.client.connect()}teardownClient(){var e,t,i,s,r,o;this.unsubs.forEach(l=>l()),this.unsubs=[],window.removeEventListener("scroll",this.handleScroll),document.removeEventListener("selectionchange",this.handleSelectionChange),this._viewportThrottleTimer&&(clearTimeout(this._viewportThrottleTimer),this._viewportThrottleTimer=null),this._selectionThrottleTimer&&(clearTimeout(this._selectionThrottleTimer),this._selectionThrottleTimer=null),(e=this.cursorOverlay)==null||e.destroy(),(t=this.commentPins)==null||t.destroy(),(i=this.viewportOverlay)==null||i.destroy(),(s=this.selectionOverlay)==null||s.destroy(),(r=this.drawingOverlay)==null||r.destroy(),(o=this.client)==null||o.disconnect(),this.client=void 0,this.cursorOverlay=void 0,this.commentPins=void 0,this.viewportOverlay=void 0,this.selectionOverlay=void 0,this.drawingOverlay=void 0,this.clientConfigKey="",this.followingUserId=null,this.drawModeActive=!1,this.connectionState="disconnected",this.showConnectedFlash=!1,this._wasDisconnected=!1,this._connectedFlashTimer&&(clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=null)}handlePanelClose(){this.activePanel=null,this.highlightThreadId=null}handleToolbarAction(e){var i,s,r,o;const t=e.detail;if(!(!this.settings.enabled&&t!=="settings"))switch(t){case"comments":this.activePanel=this.activePanel==="comments"?null:"comments",this.highlightThreadId=null;break;case"settings":this.activePanel=this.activePanel==="settings"?null:"settings";break;case"notifications":this.activePanel=this.activePanel==="notifications"?null:"notifications";break;case"activity":this.activePanel=this.activePanel==="activity"?null:"activity";break;case"pin-mode":this.pinModeActive=!this.pinModeActive,this.pinModeActive?(i=this.commentPins)==null||i.enterPinMode():(s=this.commentPins)==null||s.exitPinMode();break;case"draw-mode":this.drawModeActive=!this.drawModeActive,this.drawModeActive?(r=this.drawingOverlay)==null||r.enableDrawMode():(o=this.drawingOverlay)==null||o.disableDrawMode();break}}handleFollow(e){const t=e.detail;this.followingUserId===t?this.followingUserId=null:this.followingUserId=t}handleSettingsChange(e){const t=e.detail;this.settings=t,as(this.room,t),this.applySettings(t)}applySettings(e){var t,i,s,r,o,l,a,c,h,p,m,f,b,y,E,k,$;if(!e.enabled){(t=this.cursorOverlay)==null||t.disable(),(i=this.viewportOverlay)==null||i.disable(),(s=this.selectionOverlay)==null||s.disable(),(r=this.drawingOverlay)==null||r.disable(),this.drawModeActive&&((o=this.drawingOverlay)==null||o.disableDrawMode(),this.drawModeActive=!1),(l=this.client)==null||l.setAppearOffline(!0),(a=this.commentPins)==null||a.setVisible(!1),this.followingUserId=null,this.pinModeActive&&((c=this.commentPins)==null||c.exitPinMode(),this.pinModeActive=!1),this.activePanel=this.activePanel==="settings"?"settings":null,this.highlightThreadId=null;return}this.applyCursorSettings(e),(h=this.client)==null||h.setAppearOffline(e.appearOffline),(p=this.commentPins)==null||p.setVisible(e.showCommentPins),e.showViewportIndicators?(m=this.viewportOverlay)==null||m.enable():(f=this.viewportOverlay)==null||f.disable(),e.showSelections?(b=this.selectionOverlay)==null||b.enable():(y=this.selectionOverlay)==null||y.disable(),e.showDrawings?(E=this.drawingOverlay)==null||E.enable():((k=this.drawingOverlay)==null||k.disable(),this.drawModeActive&&(($=this.drawingOverlay)==null||$.disableDrawMode(),this.drawModeActive=!1))}applyCursorSettings(e){if(!this.cursorOverlay)return;e.showMyCursor||e.showOthersCursors?(this.cursorOverlay.enable(),this.cursorOverlay.setSending(e.showMyCursor),this.cursorOverlay.setReceiving(e.showOthersCursors)):this.cursorOverlay.disable()}updated(e){(e.has("room")||e.has("token")||e.has("apiKey")||e.has("endpoint"))&&this.apiKey&&this.token&&this.room&&this.getConfigKey()!==this.clientConfigKey&&(this.teardownClient(),this.initClient(),this.activePanel=null,this.highlightThreadId=null,this.pinModeActive=!1),(e.has("activePanel")||e.has("collapsed"))&&requestAnimationFrame(()=>this.positionPopups())}positionPopups(){var y,E,k,$;const e=this.display==="inline",t=(y=this.shadowRoot)==null?void 0:y.querySelector(".inline-trigger"),i=(E=this.shadowRoot)==null?void 0:E.querySelector("pulse-widget-toolbar"),s=e?t:i;if(!s)return;const r=s.getBoundingClientRect(),o=window.innerWidth,l=window.innerHeight,a=8,c=(k=this.shadowRoot)==null?void 0:k.querySelector(".toolbar-popover");if(c){Object.assign(c.style,{top:"auto",left:"auto"});const S=c.getBoundingClientRect(),x=this.computePosition(r,S,o,l,a);c.style.top=`${x.top}px`,c.style.left=`${x.left}px`}const h=($=this.shadowRoot)==null?void 0:$.querySelector(".panel-container");if(!h)return;Object.assign(h.style,{top:"auto",left:"auto"});const p=c??i;if(!p)return;const m=p.getBoundingClientRect(),f=h.getBoundingClientRect(),b=this.computePosition(m,f,o,l,a);h.style.top=`${b.top}px`,h.style.left=`${b.left}px`}computePosition(e,t,i,s,r){const o=e.top,l=s-e.bottom;let a;o>=t.height+r?a=e.top-t.height-r:l>=t.height+r?a=e.bottom+r:a=o>=l?Math.max(r,e.top-t.height-r):e.bottom+r;let c;const h=e.right-t.width;return h>=r?c=h:e.left+t.width+r<=i?c=e.left:c=Math.max(r,Math.min(i-t.width-r,e.left)),a=Math.max(r,Math.min(s-t.height-r,a)),c=Math.max(r,Math.min(i-t.width-r,c)),{top:a,left:c}}getFollowUserName(){var t;if(!this.followingUserId)return"";const e=(t=this.client)==null?void 0:t.state.presence.find(i=>i.user.id===this.followingUserId);return(e==null?void 0:e.user.name)??"user"}renderConnectionBanner(){return this.showConnectedFlash?d`<div class="connection-banner connected">
2602
2756
  <span class="connection-dot"></span>Connected
2603
2757
  </div>`:this.connectionState==="connecting"?d`<div class="connection-banner connecting">
2604
2758
  <span class="connection-dot"></span>Reconnecting...
@@ -2674,7 +2828,7 @@
2674
2828
  @toolbar-follow=${this.handleFollow}
2675
2829
  ></pulse-widget-toolbar>
2676
2830
  </div>
2677
- `}};exports.PulseWidget.styles=[K,S`
2831
+ `}};exports.PulseWidget.styles=[K,A`
2678
2832
  :host {
2679
2833
  display: block;
2680
2834
  }
@@ -2848,4 +3002,4 @@
2848
3002
  from { opacity: 1; }
2849
3003
  to { opacity: 0; }
2850
3004
  }
2851
- `];_([m({attribute:"api-key"})],exports.PulseWidget.prototype,"apiKey",2);_([m()],exports.PulseWidget.prototype,"token",2);_([m()],exports.PulseWidget.prototype,"room",2);_([m()],exports.PulseWidget.prototype,"endpoint",2);_([m({reflect:!0})],exports.PulseWidget.prototype,"position",2);_([m({reflect:!0})],exports.PulseWidget.prototype,"display",2);_([b()],exports.PulseWidget.prototype,"collapsed",2);_([b()],exports.PulseWidget.prototype,"activePanel",2);_([b()],exports.PulseWidget.prototype,"pinModeActive",2);_([b()],exports.PulseWidget.prototype,"highlightThreadId",2);_([b()],exports.PulseWidget.prototype,"settings",2);_([b()],exports.PulseWidget.prototype,"followingUserId",2);_([b()],exports.PulseWidget.prototype,"drawModeActive",2);_([b()],exports.PulseWidget.prototype,"connectionState",2);_([b()],exports.PulseWidget.prototype,"showConnectedFlash",2);exports.PulseWidget=_([I("pulse-widget")],exports.PulseWidget);
3005
+ `];T([g({attribute:"api-key"})],exports.PulseWidget.prototype,"apiKey",2);T([g()],exports.PulseWidget.prototype,"token",2);T([g()],exports.PulseWidget.prototype,"room",2);T([g()],exports.PulseWidget.prototype,"endpoint",2);T([g({reflect:!0})],exports.PulseWidget.prototype,"position",2);T([g({reflect:!0})],exports.PulseWidget.prototype,"display",2);T([v()],exports.PulseWidget.prototype,"collapsed",2);T([v()],exports.PulseWidget.prototype,"activePanel",2);T([v()],exports.PulseWidget.prototype,"pinModeActive",2);T([v()],exports.PulseWidget.prototype,"highlightThreadId",2);T([v()],exports.PulseWidget.prototype,"settings",2);T([v()],exports.PulseWidget.prototype,"followingUserId",2);T([v()],exports.PulseWidget.prototype,"drawModeActive",2);T([v()],exports.PulseWidget.prototype,"connectionState",2);T([v()],exports.PulseWidget.prototype,"showConnectedFlash",2);exports.PulseWidget=T([O("pulse-widget")],exports.PulseWidget);