isometrik-plugin-chat-sdk 2.0.22 → 2.0.24

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.
Files changed (181) hide show
  1. package/dist/cjs/{app-globals-0e7848be.js → app-globals-f55c4dba.js} +4 -4
  2. package/dist/cjs/{app-globals-0e7848be.js.map → app-globals-f55c4dba.js.map} +1 -1
  3. package/dist/cjs/attachment-preview_23.cjs.entry.js +98 -97
  4. package/dist/cjs/attachment-preview_23.cjs.entry.js.map +1 -1
  5. package/dist/cjs/{chat-tile_3.cjs.entry.js → chat-tile_2.cjs.entry.js} +1 -66
  6. package/dist/cjs/chat-tile_2.cjs.entry.js.map +1 -0
  7. package/dist/cjs/forward-memebers.cjs.entry.js +24 -5
  8. package/dist/cjs/forward-memebers.cjs.entry.js.map +1 -1
  9. package/dist/cjs/groupcast-9456b0c7.js +356 -0
  10. package/dist/cjs/groupcast-9456b0c7.js.map +1 -0
  11. package/dist/cjs/index.cjs.js +9 -9
  12. package/dist/cjs/iso-group-info.cjs.entry.js +74 -0
  13. package/dist/cjs/iso-group-info.cjs.entry.js.map +1 -0
  14. package/dist/cjs/isometrik-webchat.cjs.js +5 -5
  15. package/dist/cjs/loader.cjs.js +5 -5
  16. package/dist/cjs/login-page_3.cjs.entry.js +177 -69
  17. package/dist/cjs/login-page_3.cjs.entry.js.map +1 -1
  18. package/dist/cjs/member-add.cjs.entry.js +23 -5
  19. package/dist/cjs/member-add.cjs.entry.js.map +1 -1
  20. package/dist/cjs/{runtime-controls-a70872fe.js → runtime-controls-6d4fd7ed.js} +8 -7
  21. package/dist/cjs/runtime-controls-6d4fd7ed.js.map +1 -0
  22. package/dist/cjs/{groupcast-bb393c81.js → session-d44ca719.js} +1 -20
  23. package/dist/cjs/session-d44ca719.js.map +1 -0
  24. package/dist/collection/api/groupcast.js +42 -4
  25. package/dist/collection/components/ChatUIComponent/AddMember.js +24 -5
  26. package/dist/collection/components/ChatUIComponent/AddMember.js.map +1 -1
  27. package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js +25 -2
  28. package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js.map +1 -1
  29. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js +58 -3
  30. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js.map +1 -1
  31. package/dist/collection/components/ChatUIComponent/Header/WebChatHeader.js +15 -6
  32. package/dist/collection/components/ChatUIComponent/Header/WebChatHeader.js.map +1 -1
  33. package/dist/collection/components/ChatUIComponent/shared/ForwardMessageList/ForwardMessageList.js +24 -5
  34. package/dist/collection/components/ChatUIComponent/shared/ForwardMessageList/ForwardMessageList.js.map +1 -1
  35. package/dist/collection/components/ChatUIComponent/shared/GroupCast/GroupCast.js +29 -110
  36. package/dist/collection/components/ChatUIComponent/shared/GroupCast/GroupCast.js.map +1 -1
  37. package/dist/collection/components/ChatUIComponent/shared/contact-info/contact-info.js +4 -2
  38. package/dist/collection/components/ChatUIComponent/shared/contact-info/contact-info.js.map +1 -1
  39. package/dist/collection/components/ChatUIComponent/shared/message-search/message-search.js +4 -4
  40. package/dist/collection/components/ChatUIComponent/shared/message-search/message-search.js.map +1 -1
  41. package/dist/collection/components/my-component/web-chat/WebChat.js +49 -4
  42. package/dist/collection/components/my-component/web-chat/WebChat.js.map +1 -1
  43. package/dist/collection/components/my-component/web-chat/bootstrap.js +4 -0
  44. package/dist/collection/components/my-component/web-chat/bootstrap.js.map +1 -1
  45. package/dist/collection/components/my-component/web-chat/data-fetch.js +2 -2
  46. package/dist/collection/components/my-component/web-chat/data-fetch.js.map +1 -1
  47. package/dist/collection/components/my-component/web-chat/event-handlers.js +23 -6
  48. package/dist/collection/components/my-component/web-chat/event-handlers.js.map +1 -1
  49. package/dist/collection/components/my-component/web-chat/groupcast-draft.js +67 -0
  50. package/dist/collection/components/my-component/web-chat/groupcast-draft.js.map +1 -0
  51. package/dist/collection/components/my-component/web-chat/shell-render.js +2 -6
  52. package/dist/collection/components/my-component/web-chat/shell-render.js.map +1 -1
  53. package/dist/collection/lib/chat/groupcast.js +81 -1
  54. package/dist/collection/lib/chat/groupcast.js.map +1 -1
  55. package/dist/collection/lib/chat/index.js +1 -1
  56. package/dist/collection/lib/chat/index.js.map +1 -1
  57. package/dist/components/ChatFooter.js +41 -5
  58. package/dist/components/ChatFooter.js.map +1 -1
  59. package/dist/components/ChatSidebar.js +26 -3
  60. package/dist/components/ChatSidebar.js.map +1 -1
  61. package/dist/components/{GroupCast2.js → GroupCast3.js} +21 -98
  62. package/dist/components/GroupCast3.js.map +1 -0
  63. package/dist/components/WebChat.js +172 -62
  64. package/dist/components/WebChat.js.map +1 -1
  65. package/dist/components/WebChatBody.js +2 -2
  66. package/dist/components/WebChatHeader.js +15 -6
  67. package/dist/components/WebChatHeader.js.map +1 -1
  68. package/dist/components/chat-app.js +1 -1
  69. package/dist/components/client.js +1 -17
  70. package/dist/components/client.js.map +1 -1
  71. package/dist/components/contact-info2.js +4 -2
  72. package/dist/components/contact-info2.js.map +1 -1
  73. package/dist/components/forward-memebers.js +24 -5
  74. package/dist/components/forward-memebers.js.map +1 -1
  75. package/dist/components/group-cast.js +1 -1
  76. package/dist/components/groupcast.js +94 -192
  77. package/dist/components/groupcast.js.map +1 -1
  78. package/dist/{esm/groupcast-c6da3918.js → components/groupcast2.js} +45 -7
  79. package/dist/components/groupcast2.js.map +1 -0
  80. package/dist/components/helpers.js +1 -1
  81. package/dist/components/index.js +3 -2
  82. package/dist/components/index.js.map +1 -1
  83. package/dist/components/member-add.js +24 -5
  84. package/dist/components/member-add.js.map +1 -1
  85. package/dist/components/message-search2.js +4 -4
  86. package/dist/components/message-search2.js.map +1 -1
  87. package/dist/esm/{app-globals-eba1ca0c.js → app-globals-5dd18915.js} +3 -3
  88. package/dist/esm/{app-globals-eba1ca0c.js.map → app-globals-5dd18915.js.map} +1 -1
  89. package/dist/esm/attachment-preview_23.entry.js +99 -98
  90. package/dist/esm/attachment-preview_23.entry.js.map +1 -1
  91. package/dist/esm/audio-bubble_4.entry.js +1 -1
  92. package/dist/esm/{chat-tile_3.entry.js → chat-tile_2.entry.js} +3 -67
  93. package/dist/esm/chat-tile_2.entry.js.map +1 -0
  94. package/dist/esm/forward-memebers.entry.js +24 -5
  95. package/dist/esm/forward-memebers.entry.js.map +1 -1
  96. package/dist/esm/group-chat-contacts.entry.js +1 -1
  97. package/dist/esm/groupcast-e32d3b10.js +331 -0
  98. package/dist/esm/groupcast-e32d3b10.js.map +1 -0
  99. package/dist/esm/{helpers-1632a4c7.js → helpers-d452bc0f.js} +2 -2
  100. package/dist/esm/{helpers-1632a4c7.js.map → helpers-d452bc0f.js.map} +1 -1
  101. package/dist/esm/index.js +4 -4
  102. package/dist/esm/iso-group-info.entry.js +70 -0
  103. package/dist/esm/iso-group-info.entry.js.map +1 -0
  104. package/dist/esm/isometrik-webchat.js +5 -5
  105. package/dist/esm/loader.js +5 -5
  106. package/dist/esm/login-page_3.entry.js +168 -60
  107. package/dist/esm/login-page_3.entry.js.map +1 -1
  108. package/dist/esm/member-add.entry.js +25 -7
  109. package/dist/esm/member-add.entry.js.map +1 -1
  110. package/dist/esm/new-chat-sidebar.entry.js +1 -1
  111. package/dist/esm/{runtime-controls-bdb84aeb.js → runtime-controls-6dafba73.js} +3 -2
  112. package/dist/esm/runtime-controls-6dafba73.js.map +1 -0
  113. package/dist/esm/{groupcast-4f15b050.js → session-ed7217a7.js} +2 -18
  114. package/dist/esm/session-ed7217a7.js.map +1 -0
  115. package/dist/isometrik-webchat/index.esm.js +1 -1
  116. package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
  117. package/dist/isometrik-webchat/isometrik-webchat.esm.js.map +1 -1
  118. package/dist/isometrik-webchat/p-056f6809.entry.js +2 -0
  119. package/dist/isometrik-webchat/p-056f6809.entry.js.map +1 -0
  120. package/dist/isometrik-webchat/p-05b33578.js +2 -0
  121. package/dist/isometrik-webchat/{p-57f97cef.entry.js → p-0649db69.entry.js} +2 -2
  122. package/dist/isometrik-webchat/p-068abd0a.entry.js +2 -0
  123. package/dist/isometrik-webchat/p-068abd0a.entry.js.map +1 -0
  124. package/dist/isometrik-webchat/p-22404d0d.entry.js +2 -0
  125. package/dist/isometrik-webchat/p-22404d0d.entry.js.map +1 -0
  126. package/dist/isometrik-webchat/p-7d01ccbb.js +2 -0
  127. package/dist/isometrik-webchat/p-7d01ccbb.js.map +1 -0
  128. package/dist/isometrik-webchat/p-90c38a4e.entry.js +2 -0
  129. package/dist/isometrik-webchat/p-90c38a4e.entry.js.map +1 -0
  130. package/dist/isometrik-webchat/{p-0bb42151.entry.js → p-94f0c983.entry.js} +2 -2
  131. package/dist/isometrik-webchat/p-ac671eb5.js +2 -0
  132. package/dist/isometrik-webchat/p-ac671eb5.js.map +1 -0
  133. package/dist/isometrik-webchat/p-b884d9ee.entry.js +2 -0
  134. package/dist/isometrik-webchat/p-b884d9ee.entry.js.map +1 -0
  135. package/dist/isometrik-webchat/p-c4333279.entry.js +2 -0
  136. package/dist/isometrik-webchat/p-c4333279.entry.js.map +1 -0
  137. package/dist/isometrik-webchat/p-cce7d971.js +2 -0
  138. package/dist/isometrik-webchat/{p-a83932d4.js.map → p-cce7d971.js.map} +1 -1
  139. package/dist/isometrik-webchat/{p-02db2116.entry.js → p-ec03caec.entry.js} +2 -2
  140. package/dist/isometrik-webchat/{p-3dca1e56.js → p-f97e3f6d.js} +2 -2
  141. package/dist/types/components/ChatUIComponent/AddMember.d.ts +1 -0
  142. package/dist/types/components/ChatUIComponent/Footer/ChatFooter.d.ts +3 -1
  143. package/dist/types/components/ChatUIComponent/shared/ForwardMessageList/ForwardMessageList.d.ts +3 -0
  144. package/dist/types/components/ChatUIComponent/shared/GroupCast/GroupCast.d.ts +2 -11
  145. package/dist/types/components/my-component/web-chat/WebChat.d.ts +23 -0
  146. package/dist/types/components/my-component/web-chat/groupcast-draft.d.ts +23 -0
  147. package/dist/types/components.d.ts +13 -2
  148. package/dist/types/lib/chat/groupcast.d.ts +66 -0
  149. package/dist/types/lib/chat/index.d.ts +1 -1
  150. package/package.json +1 -1
  151. package/dist/cjs/chat-tile_3.cjs.entry.js.map +0 -1
  152. package/dist/cjs/groupcast-bb393c81.js.map +0 -1
  153. package/dist/cjs/groupcast-e1e52bd1.js +0 -213
  154. package/dist/cjs/groupcast-e1e52bd1.js.map +0 -1
  155. package/dist/cjs/runtime-controls-a70872fe.js.map +0 -1
  156. package/dist/components/GroupCast2.js.map +0 -1
  157. package/dist/esm/chat-tile_3.entry.js.map +0 -1
  158. package/dist/esm/groupcast-4f15b050.js.map +0 -1
  159. package/dist/esm/groupcast-c6da3918.js.map +0 -1
  160. package/dist/esm/runtime-controls-bdb84aeb.js.map +0 -1
  161. package/dist/isometrik-webchat/p-03933431.entry.js +0 -2
  162. package/dist/isometrik-webchat/p-03933431.entry.js.map +0 -1
  163. package/dist/isometrik-webchat/p-1f0e8230.entry.js +0 -2
  164. package/dist/isometrik-webchat/p-1f0e8230.entry.js.map +0 -1
  165. package/dist/isometrik-webchat/p-3a0409fc.js +0 -2
  166. package/dist/isometrik-webchat/p-3a0409fc.js.map +0 -1
  167. package/dist/isometrik-webchat/p-46be73c5.js +0 -2
  168. package/dist/isometrik-webchat/p-46be73c5.js.map +0 -1
  169. package/dist/isometrik-webchat/p-605cb14e.entry.js +0 -2
  170. package/dist/isometrik-webchat/p-605cb14e.entry.js.map +0 -1
  171. package/dist/isometrik-webchat/p-69d953cb.entry.js +0 -2
  172. package/dist/isometrik-webchat/p-69d953cb.entry.js.map +0 -1
  173. package/dist/isometrik-webchat/p-6c5eb178.js +0 -2
  174. package/dist/isometrik-webchat/p-a83932d4.js +0 -2
  175. package/dist/isometrik-webchat/p-b0f6f9ab.entry.js +0 -2
  176. package/dist/isometrik-webchat/p-b0f6f9ab.entry.js.map +0 -1
  177. /package/dist/isometrik-webchat/{p-6c5eb178.js.map → p-05b33578.js.map} +0 -0
  178. /package/dist/isometrik-webchat/{p-57f97cef.entry.js.map → p-0649db69.entry.js.map} +0 -0
  179. /package/dist/isometrik-webchat/{p-0bb42151.entry.js.map → p-94f0c983.entry.js.map} +0 -0
  180. /package/dist/isometrik-webchat/{p-02db2116.entry.js.map → p-ec03caec.entry.js.map} +0 -0
  181. /package/dist/isometrik-webchat/{p-3dca1e56.js.map → p-f97e3f6d.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{r as t,a as i,h as s,g as e}from"./p-17a96a2a.js";import{i as n}from"./p-3dca1e56.js";import{r,e as o}from"./p-d28c5548.js";import{i as h,j as a,k as l,l as c}from"./p-c06ad586.js";import{D as d,d as u}from"./p-782d1bd2.js";import"./p-5162774c.js";class f{constructor(){this.listeners={}}on(t,i,s){if(!this.listeners[t]){this.listeners[t]=new Set}if(s===null||s===void 0?void 0:s.once){const s=(...e)=>{this.un(t,s);i(...e)};this.listeners[t].add(s);return()=>this.un(t,s)}this.listeners[t].add(i);return()=>this.un(t,i)}un(t,i){var s;(s=this.listeners[t])===null||s===void 0?void 0:s.delete(i)}once(t,i){return this.on(t,i,{once:true})}unAll(){this.listeners={}}emit(t,...i){if(this.listeners[t]){this.listeners[t].forEach((t=>t(...i)))}}}class p extends f{constructor(t){super();this.subscriptions=[];this.isDestroyed=false;this.options=t}onInit(){return}_init(t){if(this.isDestroyed){this.subscriptions=[];this.isDestroyed=false}this.wavesurfer=t;this.onInit()}destroy(){this.emit("destroy");this.subscriptions.forEach((t=>t()));this.subscriptions=[];this.isDestroyed=true;this.wavesurfer=undefined}}var v=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};function g(t,i){return v(this,void 0,void 0,(function*(){const s=new AudioContext({sampleRate:i});try{return yield s.decodeAudioData(t)}finally{if(s.state!=="closed"){yield s.close().catch((()=>undefined))}}}))}function b(t){const i=t[0];if(i.some((t=>t>1||t<-1))){const s=i.length;let e=0;for(let t=0;t<s;t++){const s=Math.abs(i[t]);if(s>e)e=s}for(const i of t){for(let t=0;t<s;t++){i[t]/=e}}}return t}function m(t,i){if(!t||t.length===0){throw new Error("channelData must be a non-empty array")}if(i<=0){throw new Error("duration must be greater than 0")}if(typeof t[0]==="number")t=[t];if(!t[0]||t[0].length===0){throw new Error("channelData must contain non-empty channel arrays")}b(t);const s=t.map((t=>t instanceof Float32Array?t:Float32Array.from(t)));return{duration:i,length:s[0].length,sampleRate:s[0].length/i,numberOfChannels:s.length,getChannelData:t=>{const i=s[t];if(!i){throw new Error(`Channel ${t} not found`)}return i},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}const y={decode:g,createBuffer:m};function x(t,i){const s=i.xmlns?document.createElementNS(i.xmlns,t):document.createElement(t);for(const[t,e]of Object.entries(i)){if(t==="children"&&e){for(const[t,i]of Object.entries(e)){if(i instanceof Node){s.appendChild(i)}else if(typeof i==="string"){s.appendChild(document.createTextNode(i))}else{s.appendChild(x(t,i))}}}else if(t==="style"){Object.assign(s.style,e)}else if(t==="textContent"){s.textContent=e}else{s.setAttribute(t,e.toString())}}return s}function w(t,i,s){const e=x(t,i||{});s===null||s===void 0?void 0:s.appendChild(e);return e}function k(t){if(t instanceof HTMLElement)return true;return typeof t==="object"&&t!==null&&t.nodeType===Node.ELEMENT_NODE&&typeof t.style==="object"}const M=Object.freeze({__proto__:null,createElement:w,isHTMLElement:k,default:w});var S=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};function C(t,i,s){return S(this,void 0,void 0,(function*(){var e;if(!t.body||!t.headers)return;const n=t.body.getReader();const r=Number(t.headers.get("Content-Length"))||0;let o=0;const h=()=>{n.cancel()};if(s){if(s.aborted){n.cancel();return}s.addEventListener("abort",h,{once:true})}try{while(true){const t=yield n.read();if(t.done){break}o+=((e=t.value)===null||e===void 0?void 0:e.length)||0;if(r>0){const t=Math.round(o/r*100);i(t)}}}catch(t){if(t instanceof DOMException&&t.name==="AbortError")return;console.warn("Progress tracking error:",t)}finally{if(s){s.removeEventListener("abort",h)}}}))}function P(t,i,s){return S(this,void 0,void 0,(function*(){var e;const n=yield fetch(t,s);if(n.status>=400){throw new Error(`Failed to fetch ${t}: ${n.status} (${n.statusText})`)}C(n.clone(),i,(e=s===null||s===void 0?void 0:s.signal)!==null&&e!==void 0?e:undefined);return n.blob()}))}const R={fetchBlob:P};function W(t){let i=t;const s=new Set;return{get value(){return i},set(t){if(!Object.is(i,t)){i=t;s.forEach((t=>t(i)))}},update(t){this.set(t(i))},subscribe(t){s.add(t);return()=>s.delete(t)}}}function A(t,i){const s=W(t());i.forEach((i=>i.subscribe((()=>{const i=t();if(!Object.is(s.value,i)){s.set(i)}}))));return{get value(){return s.value},subscribe(t){return s.subscribe(t)}}}function D(t,i){let s;const e=()=>{if(s){s();s=undefined}s=t()};const n=i.map((t=>t.subscribe(e)));e();return()=>{if(s){s();s=undefined}n.forEach((t=>t()))}}var H=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};class j extends f{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(t){super();this.isExternalMedia=false;this._ownBlobUrl=null;this.reactiveMediaEventCleanups=[];if(t.media){this.media=t.media;this.isExternalMedia=true}else{this.media=document.createElement("audio")}this._isPlaying=W(false);this._currentTime=W(0);this._duration=W(0);this._volume=W(this.media.volume);this._muted=W(this.media.muted);this._playbackRate=W(this.media.playbackRate||1);this._seeking=W(false);this.setupReactiveMediaEvents();if(t.mediaControls){this.media.controls=true}if(t.autoplay){this.media.autoplay=true}if(t.playbackRate!=null){this.onMediaEvent("canplay",(()=>{if(t.playbackRate!=null){this.media.playbackRate=t.playbackRate}}),{once:true})}}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",(()=>{this._isPlaying.set(true)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",(()=>{this._isPlaying.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",(()=>{this._isPlaying.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",(()=>{this._currentTime.set(this.media.currentTime)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",(()=>{this._duration.set(this.media.duration||0)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",(()=>{this._duration.set(this.media.duration||0)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",(()=>{this._seeking.set(true)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",(()=>{this._seeking.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",(()=>{this._volume.set(this.media.volume);this._muted.set(this.media.muted)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",(()=>{this._playbackRate.set(this.media.playbackRate)})))}onMediaEvent(t,i,s){this.media.addEventListener(t,i,s);return()=>this.media.removeEventListener(t,i,s)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){if(this._ownBlobUrl){URL.revokeObjectURL(this._ownBlobUrl);this._ownBlobUrl=null}}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,i){const s=this.getSrc();if(t&&s===t)return;this.revokeSrc();const e=i instanceof Blob&&(this.canPlayType(i.type)||!t)?URL.createObjectURL(i):t;if(e!==t){this._ownBlobUrl=e}if(s){this.media.removeAttribute("src")}if(e||t){try{this.media.src=e}catch(i){this.media.src=t}}}destroy(){this.reactiveMediaEventCleanups.forEach((t=>t()));this.reactiveMediaEventCleanups=[];this.revokeSrc();this.unAll();if(this.isExternalMedia)return;this.media.pause();this.media.removeAttribute("src");this.media.load();this.media.remove()}setMediaElement(t){this.reactiveMediaEventCleanups.forEach((t=>t()));this.reactiveMediaEventCleanups=[];this.media=t;this.setupReactiveMediaEvents()}play(){return H(this,void 0,void 0,(function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&t.name==="AbortError"){return}throw t}}))}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,i){if(i!=null){this.media.preservesPitch=i}this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){const i=this.media;return i.setSinkId(t)}}const E=128;const z=8e3;const T=10;function O(t){if(t<0)return 0;if(t>1)return 1;return t}function L({width:t,height:i,length:s,options:e,pixelRatio:n}){const r=i/2;const o=e.barWidth?e.barWidth*n:1;const h=e.barGap?e.barGap*n:e.barWidth?o/2:0;const a=e.barRadius||0;const l=e.barMinHeight?e.barMinHeight*n:0;const c=o+h||1;const d=s>0?t/c/s:0;return{halfHeight:r,barWidth:o,barGap:h,barRadius:a,barMinHeight:l,barIndexScale:d,barSpacing:c}}function $({maxTop:t,maxBottom:i,halfHeight:s,vScale:e,barMinHeight:n=0,barAlign:r}){let o=Math.round(t*s*e);const h=Math.round(i*s*e);let a=o+h||1;if(a<n){a=n;if(!r){o=a/2}}return{topHeight:o,totalHeight:a}}function I({barAlign:t,halfHeight:i,topHeight:s,totalHeight:e,canvasHeight:n}){if(t==="top")return 0;if(t==="bottom")return n-e;return i-s}function F({channelData:t,barIndexScale:i,barSpacing:s,barWidth:e,halfHeight:n,vScale:r,canvasHeight:o,barAlign:h,barMinHeight:a}){const l=t[0]||[];const c=t[1]||l;const d=l.length;const u=[];let f=0;let p=0;let v=0;for(let t=0;t<=d;t++){const d=Math.round(t*i);if(d>f){const{topHeight:t,totalHeight:i}=$({maxTop:p,maxBottom:v,halfHeight:n,vScale:r,barMinHeight:a,barAlign:h});const l=I({barAlign:h,halfHeight:n,topHeight:t,totalHeight:i,canvasHeight:o});u.push({x:f*s,y:l,width:e,height:i});f=d;p=0;v=0}const g=Math.abs(l[t]||0);const b=Math.abs(c[t]||0);if(g>p)p=g;if(b>v)v=b}return u}function _(t,i,s){const e=i-t.left;const n=s-t.top;const r=e/t.width;const o=n/t.height;return[r,o]}function B({optionsHeight:t,optionsSplitChannels:i,parentHeight:s,numberOfChannels:e,defaultHeight:n=E}){if(t==null)return n;const r=Number(t);if(!isNaN(r))return r;if(t==="auto"){const t=s||n;if(i===null||i===void 0?void 0:i.every((t=>!t.overlay))){return t/e}return t}return n}function N(t){return Math.max(1,t||1)}function U(t){return Boolean(t.barWidth||t.barGap||t.barAlign)}function V(t,i,s){if(!Array.isArray(t))return t||"";if(t.length===0)return"#999";if(t.length<2)return t[0]||"";const e=document.createElement("canvas");const n=e.getContext("2d");if(!n)return t[0]||"";const r=s||e.height*i;const o=n.createLinearGradient(0,0,0,r);const h=1/(t.length-1);t.forEach(((t,i)=>{o.addColorStop(i*h,t)}));return o}function X({duration:t,minPxPerSec:i=0,parentWidth:s,fillParent:e,pixelRatio:n}){const r=Math.ceil(t*i);const o=r>s;const h=Boolean(e&&!o);const a=(h?s:r)*n;return{scrollWidth:r,isScrollable:o,useParentWidth:h,width:a}}function G(t,i){if(!U(i))return t;const s=i.barWidth||.5;const e=i.barGap||s/2;const n=s+e;if(n===0)return t;return Math.floor(t/n)*n}function q({clientWidth:t,totalWidth:i,options:s}){const e=Math.min(z,t,i);return G(e,s)}function K({channelData:t,offset:i,clampedWidth:s,totalWidth:e}){return t.map((t=>{const n=Math.floor(i/e*t.length);const r=Math.floor((i+s)/e*t.length);return t.slice(n,r)}))}function Y(t){return t>T}function Z({scrollLeft:t,totalWidth:i,numCanvases:s}){if(i===0)return[0];const e=t/i;const n=Math.floor(e*s);return[n-1,n,n+1]}function J({channelData:t,barHeight:i,normalize:s,maxPeak:e}){var n;const r=i||1;if(!s)return r;const o=t[0];if(!o||o.length===0)return r;let h=e!==null&&e!==void 0?e:0;if(!e){for(let t=0;t<o.length;t++){const i=(n=o[t])!==null&&n!==void 0?n:0;const s=Math.abs(i);if(s>h)h=s}}if(!h)return r;return r/h}function Q({channelData:t,width:i,height:s,vScale:e}){const n=s/2;const r=t[0]||[];const o=t[1]||r;const h=[r,o];return h.map(((t,s)=>{const r=t.length;const o=r?i/r:0;const h=n;const a=s===0?-1:1;const l=[{x:0,y:h}];let c=0;let d=0;for(let i=0;i<=r;i++){const s=Math.round(i*o);if(s>c){const t=Math.round(d*n*e)||1;const i=h+t*a;l.push({x:c,y:i});c=s;d=0}const r=Math.abs(t[i]||0);if(r>d)d=r}l.push({x:c,y:h});return l}))}function tt(t){const i=t*2;const s=i<0?Math.floor(i):Math.ceil(i);return s/2}function it(t){const i=t._cleanup;if(typeof i==="function"){i()}}function st(t,i={}){const{threshold:s=3,mouseButton:e=0,touchDelay:n=100}=i;const r=W(null);const o=new Map;const h=matchMedia("(pointer: coarse)").matches;let a=()=>void 0;const l=i=>{if(i.button!==e)return;if(o.has(i.pointerId))return;o.set(i.pointerId,i);if(o.size>1){return}const l=i.pointerId;let c=i.clientX;let d=i.clientY;let u=false;const f=Date.now();const p=t.getBoundingClientRect();const{left:v,top:g}=p;const b=t=>{if(t.pointerId!==l)return;if(t.defaultPrevented||o.size>1){return}if(h&&Date.now()-f<n)return;const i=t.clientX;const e=t.clientY;const a=i-c;const p=e-d;if(u||Math.abs(a)>s||Math.abs(p)>s){t.preventDefault();t.stopPropagation();if(!u){r.set({type:"start",x:c-v,y:d-g});u=true}r.set({type:"move",x:i-v,y:e-g,deltaX:a,deltaY:p});c=i;d=e}};const m=t=>{if(!o.delete(t.pointerId))return;if(t.pointerId===l&&u){const i=t.clientX;const s=t.clientY;r.set({type:"end",x:i-v,y:s-g})}if(o.size===0){a()}};const y=t=>{if(!t.relatedTarget||t.relatedTarget===document.documentElement){m(t)}};const x=t=>{if(u){t.stopPropagation();t.preventDefault()}};const w=t=>{if(t.defaultPrevented||o.size>1){return}if(u){t.preventDefault()}};document.addEventListener("pointermove",b);document.addEventListener("pointerup",m);document.addEventListener("pointerout",y);document.addEventListener("pointercancel",y);document.addEventListener("touchmove",w,{passive:false});document.addEventListener("click",x,{capture:true});a=()=>{document.removeEventListener("pointermove",b);document.removeEventListener("pointerup",m);document.removeEventListener("pointerout",y);document.removeEventListener("pointercancel",y);document.removeEventListener("touchmove",w);setTimeout((()=>{document.removeEventListener("click",x,{capture:true})}),10)}};t.addEventListener("pointerdown",l);const c=()=>{a();t.removeEventListener("pointerdown",l);o.clear();it(r)};return{signal:r,cleanup:c}}function et(t){const{scrollLeft:i,scrollWidth:s,clientWidth:e}=t;if(s===0){return{startX:0,endX:1}}const n=i/s;const r=(i+e)/s;return{startX:Math.max(0,Math.min(1,n)),endX:Math.max(0,Math.min(1,r))}}function nt(t){return{left:t.scrollLeft,right:t.scrollLeft+t.clientWidth}}function rt(t){const i=W({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth});const s=A((()=>et(i.value)),[i]);const e=A((()=>nt(i.value)),[i]);const n=()=>{i.set({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})};t.addEventListener("scroll",n,{passive:true});const r=()=>{t.removeEventListener("scroll",n);it(i)};return{scrollData:i,percentages:s,bounds:e,cleanup:r}}var ot=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};var ht=undefined&&undefined.__rest||function(t,i){var s={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0)s[e]=t[e];if(t!=null&&typeof Object.getOwnPropertySymbols==="function")for(var n=0,e=Object.getOwnPropertySymbols(t);n<e.length;n++){if(i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n]))s[e[n]]=t[e[n]]}return s};const at=60;const lt=10;const ct=lt*at;class dt extends f{constructor(t,i){super();this.timeouts=[];this.isScrollable=false;this.audioData=null;this.resizeObserver=null;this.lastContainerWidth=0;this.isDragging=false;this.subscriptions=[];this.unsubscribeOnScroll=[];this.dragStream=null;this.scrollStream=null;this.containerInlinePadding=0;this.onClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=_(i,t.clientX,t.clientY);this.emit("click",s,e)};this.onDblClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=_(i,t.clientX,t.clientY);this.emit("dblclick",s,e)};this.subscriptions=[];this.options=t;const s=this.parentFromOptionsContainer(t.container);this.parent=s;const[e,n]=this.initHtml();s.appendChild(e);this.container=e;this.scrollContainer=n.querySelector(".scroll");this.wrapper=n.querySelector(".wrapper");this.canvasWrapper=n.querySelector(".canvases");this.progressWrapper=n.querySelector(".progress");this.cursor=n.querySelector(".cursor");this.calculateInlinePadding();if(i){n.appendChild(i)}this.initEvents()}parentFromOptionsContainer(t){let i;if(typeof t==="string"){i=document.querySelector(t)}else if(k(t)){i=t}if(!i){throw new Error("Container not found")}return i}initEvents(){this.wrapper.addEventListener("click",this.onClickWrapper);this.wrapper.addEventListener("dblclick",this.onDblClickWrapper);if(this.options.dragToSeek===true||typeof this.options.dragToSeek==="object"){this.initDrag()}this.scrollStream=rt(this.scrollContainer);const t=D((()=>{const{startX:t,endX:i}=this.scrollStream.percentages.value;const{left:s,right:e}=this.scrollStream.bounds.value;this.emit("scroll",t,i,s,e)}),[this.scrollStream.percentages,this.scrollStream.bounds]);this.subscriptions.push(t);if(typeof ResizeObserver==="function"){const t=this.createDelay(100);this.resizeObserver=new ResizeObserver((()=>{t().then((()=>this.onContainerResize())).catch((()=>undefined))}));this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;this.calculateInlinePadding();if(t===this.lastContainerWidth&&this.options.height!=="auto")return;this.lastContainerWidth=t;this.reRender();this.emit("resize")}initDrag(){if(this.dragStream)return;this.dragStream=st(this.wrapper);const t=D((()=>{const t=this.dragStream.signal.value;if(!t)return;const i=this.wrapper.getBoundingClientRect().width;const s=O(t.x/i);if(t.type==="start"){this.isDragging=true;this.emit("dragstart",s)}else if(t.type==="move"){this.emit("drag",s)}else if(t.type==="end"){this.isDragging=false;this.emit("dragend",s)}}),[this.dragStream.signal]);this.subscriptions.push(t)}calculateInlinePadding(){const{paddingLeft:t,paddingRight:i}=getComputedStyle(this.scrollContainer);const s=parseFloat(t)+parseFloat(i);this.containerInlinePadding=Number.isNaN(s)?0:s}initHtml(){const t=document.createElement("div");const i=t.attachShadow({mode:"open"});const s=this.options.cspNonce&&typeof this.options.cspNonce==="string"?this.options.cspNonce.replace(/"/g,""):"";i.innerHTML=`\n <style${s?` nonce="${s}"`:""}>\n :host {\n user-select: none;\n min-width: 1px;\n }\n :host audio {\n display: block;\n width: 100%;\n }\n :host .scroll {\n overflow-x: auto;\n overflow-y: hidden;\n width: 100%;\n position: relative;\n }\n :host .noScrollbar {\n scrollbar-color: transparent;\n scrollbar-width: none;\n }\n :host .noScrollbar::-webkit-scrollbar {\n display: none;\n -webkit-appearance: none;\n }\n :host .wrapper {\n position: relative;\n overflow: visible;\n z-index: 2;\n }\n :host .canvases {\n min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;\n pointer-events: none;\n }\n :host .canvases > div {\n position: relative;\n }\n :host canvas {\n display: block;\n position: absolute;\n top: 0;\n image-rendering: pixelated;\n }\n :host .progress {\n pointer-events: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n overflow: hidden;\n }\n :host .progress > div {\n position: relative;\n }\n :host .cursor {\n pointer-events: none;\n position: absolute;\n z-index: 5;\n top: 0;\n left: 0;\n height: 100%;\n border-radius: 2px;\n }\n </style>\n\n <div class="scroll" part="scroll">\n <div class="wrapper" part="wrapper">\n <div class="canvases" part="canvases"></div>\n <div class="progress" part="progress"></div>\n <div class="cursor" part="cursor"></div>\n </div>\n </div>\n `;return[t,i]}setOptions(t){var i;if(this.options.container!==t.container){const i=this.parentFromOptionsContainer(t.container);i.appendChild(this.container);this.parent=i}if(t.dragToSeek===true||typeof this.options.dragToSeek==="object"){this.initDrag()}else{(i=this.dragStream)===null||i===void 0?void 0:i.cleanup();this.dragStream=null}this.options=t;this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth-this.containerInlinePadding}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:i}=this.scrollContainer;const s=i*t;this.setScroll(s)}destroy(){var t;this.wrapper.removeEventListener("click",this.onClickWrapper);this.wrapper.removeEventListener("dblclick",this.onDblClickWrapper);this.timeouts.forEach((t=>t()));this.timeouts=[];this.subscriptions.forEach((t=>t()));this.container.remove();if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null}(t=this.unsubscribeOnScroll)===null||t===void 0?void 0:t.forEach((t=>t()));this.unsubscribeOnScroll=[];if(this.dragStream){this.dragStream.cleanup();this.dragStream=null}if(this.scrollStream){this.scrollStream.cleanup();this.scrollStream=null}}createDelay(t=10){let i;let s;const e=()=>{if(i){clearTimeout(i);i=undefined}if(s){s();s=undefined}};this.timeouts.push(e);return()=>new Promise(((n,r)=>{e();s=r;i=setTimeout((()=>{i=undefined;s=undefined;n()}),t)}))}getHeight(t,i){var s;const e=((s=this.audioData)===null||s===void 0?void 0:s.numberOfChannels)||1;return B({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:e,defaultHeight:E})}convertColorValues(t,i){return V(t,this.getPixelRatio(),i===null||i===void 0?void 0:i.canvas.height)}getPixelRatio(){return N(window.devicePixelRatio)}renderBarWaveform(t,i,s,e){const{width:n,height:r}=s.canvas;const{halfHeight:o,barWidth:h,barRadius:a,barIndexScale:l,barSpacing:c,barMinHeight:d}=L({width:n,height:r,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()});const u=F({channelData:t,barIndexScale:l,barSpacing:c,barWidth:h,halfHeight:o,vScale:e,canvasHeight:r,barAlign:i.barAlign,barMinHeight:d});s.beginPath();for(const t of u){if(a&&"roundRect"in s){s.roundRect(t.x,t.y,t.width,t.height,a)}else{s.rect(t.x,t.y,t.width,t.height)}}s.fill();s.closePath()}renderLineWaveform(t,i,s,e){const{width:n,height:r}=s.canvas;const o=Q({channelData:t,width:n,height:r,vScale:e});s.beginPath();for(const t of o){if(!t.length)continue;s.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++){const e=t[i];s.lineTo(e.x,e.y)}}s.fill();s.closePath()}renderWaveform(t,i,s){s.fillStyle=this.convertColorValues(i.waveColor,s);if(i.renderFunction){i.renderFunction(t,s);return}const e=J({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});if(U(i)){this.renderBarWaveform(t,i,s,e);return}this.renderLineWaveform(t,i,s,e)}renderSingleCanvas(t,i,s,e,n,r,o){const h=this.getPixelRatio();const a=document.createElement("canvas");a.width=Math.round(s*h);a.height=Math.round(e*h);a.style.width=`${s}px`;a.style.height=`${e}px`;a.style.left=`${Math.round(n)}px`;r.appendChild(a);const l=a.getContext("2d");if(i.renderFunction){l.fillStyle=this.convertColorValues(i.waveColor,l);i.renderFunction(t,l)}else{this.renderWaveform(t,i,l)}if(a.width>0&&a.height>0){const t=a.cloneNode();const s=t.getContext("2d");s.drawImage(a,0,0);s.globalCompositeOperation="source-in";s.fillStyle=this.convertColorValues(i.progressColor,s);s.fillRect(0,0,a.width,a.height);o.appendChild(t)}}renderMultiCanvas(t,i,s,e,n,r){const o=this.getPixelRatio();const{clientWidth:h}=this.scrollContainer;const a=s/o;const l=q({clientWidth:h,totalWidth:a,options:i});let c={};if(l===0)return;const d=s=>{if(s<0||s>=f)return;if(c[s])return;c[s]=true;const o=s*l;let h=Math.min(a-o,l);h=G(h,i);if(h<=0)return;const d=K({channelData:t,offset:o,clampedWidth:h,totalWidth:a});this.renderSingleCanvas(d,i,h,e,o,n,r)};const u=()=>{if(Y(Object.keys(c).length)){n.innerHTML="";r.innerHTML="";c={}}};const f=Math.ceil(a/l);if(!this.isScrollable){for(let t=0;t<f;t++){d(t)}return}const p=Z({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:a,numCanvases:f});p.forEach((t=>d(t)));if(f>1){const t=this.on("scroll",(()=>{const{scrollLeft:t}=this.scrollContainer;u();Z({scrollLeft:t,totalWidth:a,numCanvases:f}).forEach((t=>d(t)))}));this.unsubscribeOnScroll.push(t)}}renderChannel(t,i,s,e){var{overlay:n}=i,r=ht(i,["overlay"]);const o=document.createElement("div");const h=this.getHeight(r.height,r.splitChannels);o.style.height=`${h}px`;if(n&&e>0){o.style.marginTop=`-${h}px`}this.canvasWrapper.style.minHeight=`${h}px`;this.canvasWrapper.appendChild(o);const a=o.cloneNode();this.progressWrapper.appendChild(a);this.renderMultiCanvas(t,r,s,h,o,a)}render(t){return ot(this,void 0,void 0,(function*(){var i;this.timeouts.forEach((t=>t()));this.timeouts=[];this.unsubscribeOnScroll.forEach((t=>t()));this.unsubscribeOnScroll=[];this.canvasWrapper.innerHTML="";this.progressWrapper.innerHTML="";if(this.options.width!=null){this.scrollContainer.style.width=typeof this.options.width==="number"?`${this.options.width}px`:this.options.width}const s=this.getPixelRatio();const e=this.scrollContainer.clientWidth-this.containerInlinePadding;const{scrollWidth:n,isScrollable:r,useParentWidth:o,width:h}=X({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:e,fillParent:this.options.fillParent,pixelRatio:s});this.isScrollable=r;this.wrapper.style.width=o?"100%":`${n}px`;this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden";this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar);this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`;this.cursor.style.width=`${this.options.cursorWidth}px`;this.audioData=t;this.emit("render");if(this.options.splitChannels){for(let s=0;s<t.numberOfChannels;s++){const e=Object.assign(Object.assign({},this.options),(i=this.options.splitChannels)===null||i===void 0?void 0:i[s]);this.renderChannel([t.getChannelData(s)],e,h,s)}}else{const i=[t.getChannelData(0)];if(t.numberOfChannels>1)i.push(t.getChannelData(1));this.renderChannel(i,this.options,h,0)}Promise.resolve().then((()=>this.emit("rendered")))}))}reRender(){this.unsubscribeOnScroll.forEach((t=>t()));this.unsubscribeOnScroll=[];if(!this.audioData)return;const{scrollWidth:t}=this.scrollContainer;const{right:i}=this.progressWrapper.getBoundingClientRect();this.render(this.audioData);if(!this.isScrollable&&this.scrollContainer.scrollLeft){this.scrollContainer.scrollLeft=0}else if(this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:t}=this.progressWrapper.getBoundingClientRect();const s=tt(t-i);this.scrollContainer.scrollLeft+=s}}zoom(t){this.options.minPxPerSec=t;this.reRender()}scrollIntoView(t,i=false){var s;const{scrollLeft:e,scrollWidth:n,clientWidth:r}=this.scrollContainer;const o=t*n;const h=e;const a=e+r;const l=r/2;if(this.isDragging){const t=30;if(o+t>a){this.scrollContainer.scrollLeft+=t}else if(o-t<h){this.scrollContainer.scrollLeft-=t}}else{if(o<h||o>a){this.scrollContainer.scrollLeft=o-(this.options.autoCenter?l:0)}const t=o-e-l;if(i&&this.options.autoCenter&&t>0){const i=(s=this.audioData)===null||s===void 0?void 0:s.duration;if(i===undefined||i<=0){this.scrollContainer.scrollLeft+=t;return}const e=n/i;if(e<=ct){this.scrollContainer.scrollLeft+=Math.min(t,lt)}else{this.scrollContainer.scrollLeft+=t}}}}renderProgress(t,i){if(isNaN(t))return;const s=t*100;this.canvasWrapper.style.clipPath=`polygon(${s}% 0%, 100% 0%, 100% 100%, ${s}% 100%)`;this.progressWrapper.style.width=`${s}%`;this.cursor.style.left=`${s}%`;this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"";if(this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0){this.scrollIntoView(t,i)}}exportImage(t,i,s){return ot(this,void 0,void 0,(function*(){const e=this.canvasWrapper.querySelectorAll("canvas");if(!e.length){throw new Error("No waveform data")}if(s==="dataURL"){const s=Array.from(e).map((s=>s.toDataURL(t,i)));return Promise.resolve(s)}return Promise.all(Array.from(e).map((s=>new Promise(((e,n)=>{s.toBlob((t=>{if(t){e(t)}else{n(new Error("Could not export image"))}}),t,i)})))))}))}}class ut extends f{constructor(){super(...arguments);this.animationFrameId=null;this.isRunning=false}start(){if(this.isRunning)return;this.isRunning=true;const t=()=>{if(!this.isRunning)return;this.emit("tick");this.animationFrameId=requestAnimationFrame(t)};t()}stop(){this.isRunning=false;if(this.animationFrameId!==null){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}}destroy(){this.stop();this.unAll()}}var ft=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};function pt(){const t=globalThis.navigator;if(!(t===null||t===void 0?void 0:t.audioSession))return;try{t.audioSession.type="playback"}catch(t){console.warn("Setting navigator.audioSession.type failed:",t)}}class vt extends f{constructor(t){super();this.bufferNode=null;this.playStartTime=0;this.playbackPosition=0;this._muted=false;this._playbackRate=1;this._duration=undefined;this.buffer=null;this.currentSrc="";this.paused=true;this.crossOrigin=null;this.seeking=false;this.autoplay=false;this.addEventListener=this.on;this.removeEventListener=this.un;this._destroyed=false;pt();this.audioContext=t||new AudioContext;this.gainNode=this.audioContext.createGain();this.gainNode.connect(this.audioContext.destination)}load(){return ft(this,void 0,void 0,(function*(){return}))}remove(){this.destroy()}destroy(){if(this._destroyed)return;this._destroyed=true;this.currentSrc="";if(this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}this.bufferNode.disconnect();this.bufferNode=null}this.gainNode.disconnect();if(typeof this.audioContext.close==="function"){Promise.resolve(this.audioContext.close.call(this.audioContext)).catch((()=>undefined))}this.buffer=null;this.unAll()}get src(){return this.currentSrc}set src(t){this.currentSrc=t;this._duration=undefined;if(!t){this.buffer=null;this.emit("emptied");return}fetch(t).then((i=>{if(i.status>=400){throw new Error(`Failed to fetch ${t}: ${i.status} (${i.statusText})`)}return i.arrayBuffer()})).then((i=>{if(this.currentSrc!==t)return null;return this.audioContext.decodeAudioData(i)})).then((i=>{if(this.currentSrc!==t)return;this.buffer=i;this.emit("loadedmetadata");this.emit("canplay");if(this.autoplay)this.play()})).catch((t=>{console.error("WebAudioPlayer load error:",t)}))}_play(){if(!this.paused)return;this.paused=false;if(this.bufferNode){this.bufferNode.onended=null;this.bufferNode.disconnect()}this.bufferNode=this.audioContext.createBufferSource();if(this.buffer){this.bufferNode.buffer=this.buffer}this.bufferNode.playbackRate.value=this._playbackRate;this.bufferNode.connect(this.gainNode);let t=this.playbackPosition;if(t>=this.duration||t<0){t=0;this.playbackPosition=0}this.bufferNode.start(this.audioContext.currentTime,t);this.playStartTime=this.audioContext.currentTime;this.bufferNode.onended=()=>{if(!this.paused&&this.duration-this.currentTime<.01){this.pause();this.emit("ended")}}}_pause(){this.paused=true;if(this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}}this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return ft(this,void 0,void 0,(function*(){if(!this.paused)return;this._play();this.emit("play")}))}pause(){if(this.paused)return;this._pause();this.emit("pause")}stopAt(t){const i=(t-this.currentTime)/this._playbackRate;const s=this.bufferNode;s===null||s===void 0?void 0:s.stop(this.audioContext.currentTime+i);s===null||s===void 0?void 0:s.addEventListener("ended",(()=>{if(s===this.bufferNode){this.bufferNode=null;this.pause();this.playbackPosition=Math.min(t,this.duration);this.emit("timeupdate")}}),{once:true})}setSinkId(t){return ft(this,void 0,void 0,(function*(){const i=this.audioContext;return i.setSinkId(t)}))}get playbackRate(){return this._playbackRate}set playbackRate(t){const i=!this.paused;if(i)this._pause();this._playbackRate=t;if(i)this._play();if(this.bufferNode){this.bufferNode.playbackRate.value=t}}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){const i=!this.paused;if(i)this._pause();this.playbackPosition=t;if(i)this._play();this.emit("seeking");this.emit("timeupdate")}get duration(){var t,i;return(t=this._duration)!==null&&t!==void 0?t:((i=this.buffer)===null||i===void 0?void 0:i.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t;this.emit("volumechange")}get muted(){return this._muted}set muted(t){if(this._muted===t)return;this._muted=t;if(this._muted){this.gainNode.disconnect()}else{this.gainNode.connect(this.audioContext.destination)}}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const i=this.buffer.numberOfChannels;for(let s=0;s<i;s++){t.push(this.buffer.getChannelData(s))}return t}removeAttribute(t){switch(t){case"src":this.src="";break;case"playbackRate":this.playbackRate=0;break;case"currentTime":this.currentTime=0;break;case"duration":this.duration=0;break;case"volume":this.volume=0;break;case"muted":this.muted=false;break}}}function gt(t){var i,s,e,n,r,o;const h=(i=t===null||t===void 0?void 0:t.currentTime)!==null&&i!==void 0?i:W(0);const a=(s=t===null||t===void 0?void 0:t.duration)!==null&&s!==void 0?s:W(0);const l=(e=t===null||t===void 0?void 0:t.isPlaying)!==null&&e!==void 0?e:W(false);const c=(n=t===null||t===void 0?void 0:t.isSeeking)!==null&&n!==void 0?n:W(false);const d=(r=t===null||t===void 0?void 0:t.volume)!==null&&r!==void 0?r:W(1);const u=(o=t===null||t===void 0?void 0:t.playbackRate)!==null&&o!==void 0?o:W(1);const f=W(null);const p=W(null);const v=W("");const g=W(0);const b=W(0);const m=A((()=>!l.value),[l]);const y=A((()=>f.value!==null),[f]);const x=A((()=>y.value&&a.value>0),[y,a]);const w=A((()=>h.value),[h]);const k=A((()=>a.value>0?h.value/a.value:0),[h,a]);const M={currentTime:h,duration:a,isPlaying:l,isPaused:m,isSeeking:c,volume:d,playbackRate:u,audioBuffer:f,peaks:p,url:v,zoom:g,scrollPosition:b,canPlay:y,isReady:x,progress:w,progressPercent:k};const S={setCurrentTime:t=>{const i=Math.max(0,Math.min(a.value||Infinity,t));h.set(i)},setDuration:t=>{a.set(Math.max(0,t))},setPlaying:t=>{l.set(t)},setSeeking:t=>{c.set(t)},setVolume:t=>{const i=Math.max(0,Math.min(1,t));d.set(i)},setPlaybackRate:t=>{const i=Math.max(.1,Math.min(16,t));u.set(i)},setAudioBuffer:t=>{f.set(t);if(t){a.set(t.duration)}},setPeaks:t=>{p.set(t)},setUrl:t=>{v.set(t)},setZoom:t=>{g.set(Math.max(0,t))},setScrollPosition:t=>{b.set(Math.max(0,t))}};return{state:M,actions:S}}var bt=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};const mt={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:true,interact:true,dragToSeek:false,autoScroll:true,autoCenter:true,sampleRate:8e3};class yt extends j{static create(t){return new yt(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new vt:undefined);super({media:i,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate});this.plugins=[];this.decodedData=null;this.stopAtPosition=null;this.subscriptions=[];this.mediaSubscriptions=[];this.abortController=null;this._isDestroyed=false;this._loadVersion=0;this.options=Object.assign({},mt,t);const{state:s,actions:e}=gt({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=s;this.wavesurferActions=e;this.timer=new ut;const n=i?undefined:this.getMediaElement();this.renderer=new dt(this.options,n);this.initPlayerEvents();this.initRendererEvents();this.initTimerEvents();this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then((()=>{this.emit("init");const{peaks:t,duration:i}=this.options;if(r||t&&i){this.load(r,t,i).catch((()=>{}))}}))}updateProgress(t=this.getCurrentTime()){this.renderer.renderProgress(t/this.getDuration(),this.isPlaying());return t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",(()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t);this.emit("audioprocess",t);if(this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition){const t=this.stopAtPosition;this.pause();this.setTime(t)}}})))}initPlayerEvents(){if(this.isPlaying()){this.emit("play");this.timer.start()}this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",(()=>{const t=this.updateProgress();this.emit("timeupdate",t)})),this.onMediaEvent("play",(()=>{this.emit("play");this.timer.start()})),this.onMediaEvent("pause",(()=>{this.emit("pause");this.timer.stop();this.stopAtPosition=null})),this.onMediaEvent("emptied",(()=>{this.timer.stop();this.stopAtPosition=null})),this.onMediaEvent("ended",(()=>{this.emit("timeupdate",this.getDuration());this.emit("finish");this.stopAtPosition=null})),this.onMediaEvent("seeking",(()=>{this.emit("seeking",this.getCurrentTime())})),this.onMediaEvent("error",(()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error"));this.stopAtPosition=null})))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",((t,i)=>{if(this.options.interact){this.seekTo(t);this.emit("interaction",t*this.getDuration());this.emit("click",t,i)}})),this.renderer.on("dblclick",((t,i)=>{this.emit("dblclick",t,i)})),this.renderer.on("scroll",((t,i,s,e)=>{const n=this.getDuration();this.emit("scroll",t*n,i*n,s,e)})),this.renderer.on("render",(()=>{this.emit("redraw")})),this.renderer.on("rendered",(()=>{this.emit("redrawcomplete")})),this.renderer.on("dragstart",(t=>{this.emit("dragstart",t)})),this.renderer.on("dragend",(t=>{this.emit("dragend",t)})),this.renderer.on("resize",(()=>{this.emit("resize")})));{let t;const i=this.renderer.on("drag",(i=>{var s;if(!this.options.interact)return;this.renderer.renderProgress(i);clearTimeout(t);let e=0;const n=this.options.dragToSeek;if(this.isPlaying()){e=0}else if(n===true){e=200}else if(n&&typeof n==="object"){e=(s=n.debounceTime)!==null&&s!==void 0?s:200}t=setTimeout((()=>{this.seekTo(i)}),e);this.emit("interaction",i*this.getDuration());this.emit("drag",i)}));this.subscriptions.push((()=>{clearTimeout(t);i()}))}}initPlugins(){var t;if(!((t=this.options.plugins)===null||t===void 0?void 0:t.length))return;this.options.plugins.forEach((t=>{this.registerPlugin(t)}))}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach((t=>t()));this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t);if(t.duration&&!t.peaks){this.decodedData=y.createBuffer(this.exportPeaks(),t.duration)}if(t.peaks&&t.duration){this.decodedData=y.createBuffer(t.peaks,t.duration)}this.renderer.setOptions(this.options);if(t.audioRate){this.setPlaybackRate(t.audioRate)}if(t.mediaControls!=null){this.getMediaElement().controls=t.mediaControls}}registerPlugin(t){if(this.plugins.includes(t)){return t}t._init(this);this.plugins.push(t);const i=t.once("destroy",(()=>{this.plugins=this.plugins.filter((i=>i!==t));this.subscriptions=this.subscriptions.filter((t=>t!==i))}));this.subscriptions.push(i);return t}unregisterPlugin(t){this.plugins=this.plugins.filter((i=>i!==t));t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const i=t/this.getDuration();this.renderer.setScrollPercentage(i)}getActivePlugins(){return this.plugins}loadAudio(t,i,s,e){return bt(this,void 0,void 0,(function*(){var n;const r=++this._loadVersion;this._isDestroyed=false;this.emit("load",t);if(!this.options.media&&this.isPlaying())this.pause();this.decodedData=null;this.stopAtPosition=null;(n=this.abortController)===null||n===void 0?void 0:n.abort();this.abortController=null;if(!i&&!s){const s=this.options.fetchParams||{};if(window.AbortController&&!s.signal){this.abortController=new AbortController;s.signal=this.abortController.signal}const e=t=>this.emit("loading",t);i=yield R.fetchBlob(t,e,s);if(this._isDestroyed||r!==this._loadVersion)return;const n=this.options.blobMimeType;if(n){i=new Blob([i],{type:n})}}if(this._isDestroyed||r!==this._loadVersion)return;this.setSrc(t,i);const o=yield new Promise((t=>{const i=e||this.getDuration();if(i){t(i)}else{this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",(()=>t(this.getDuration())),{once:true}))}}));if(this._isDestroyed||r!==this._loadVersion)return;if(!t&&!i){const t=this.getMediaElement();if(t instanceof vt){t.duration=o}}if(s){this.decodedData=y.createBuffer(s,o||0)}else if(i){const t=yield i.arrayBuffer();if(this._isDestroyed||r!==this._loadVersion)return;this.decodedData=yield y.decode(t,this.options.sampleRate)}if(this._isDestroyed||r!==this._loadVersion)return;if(this.decodedData){this.emit("decode",this.getDuration());this.renderer.render(this.decodedData)}this.emit("ready",this.getDuration())}))}load(t,i,s){return bt(this,void 0,void 0,(function*(){try{return yield this.loadAudio(t,undefined,i,s)}catch(t){this.emit("error",t);throw t}}))}loadBlob(t,i,s){return bt(this,void 0,void 0,(function*(){try{return yield this.loadAudio("",t,i,s)}catch(t){this.emit("error",t);throw t}}))}zoom(t){if(!this.decodedData){throw new Error("No audio loaded")}this.renderer.zoom(t);this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:i=8e3,precision:s=1e4}={}){if(!this.decodedData){throw new Error("The audio has not been decoded yet")}const e=Math.min(t,this.decodedData.numberOfChannels);const n=[];for(let t=0;t<e;t++){const e=this.decodedData.getChannelData(t);const r=[];const o=e.length/i;for(let t=0;t<i;t++){const i=e.slice(Math.floor(t*o),Math.ceil((t+1)*o));let n=0;for(let t=0;t<i.length;t++){const s=i[t];if(Math.abs(s)>Math.abs(n))n=s}r.push(Math.round(n*s)/s)}n.push(r)}return n}getDuration(){let t=super.getDuration()||0;if((t===0||t===Infinity)&&this.decodedData){t=this.decodedData.duration}return t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null;super.setTime(t);this.updateProgress(t);this.emit("timeupdate",t)}seekTo(t){const i=this.getDuration()*t;this.setTime(i)}play(t,i){const s=Object.create(null,{play:{get:()=>super.play}});return bt(this,void 0,void 0,(function*(){if(t!=null){this.setTime(t)}const e=yield s.play.call(this);if(i!=null){if(this.media instanceof vt){this.media.stopAt(i)}else{this.stopAtPosition=i}}return e}))}playPause(){return bt(this,void 0,void 0,(function*(){return this.isPlaying()?this.pause():this.play()}))}stop(){this.pause();this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents();super.setMediaElement(t);this.initPlayerEvents()}exportImage(){return bt(this,arguments,void 0,(function*(t="image/png",i=1,s="dataURL"){return this.renderer.exportImage(t,i,s)}))}destroy(){var t;this._isDestroyed=true;this.emit("destroy");(t=this.abortController)===null||t===void 0?void 0:t.abort();this.plugins.forEach((t=>t.destroy()));this.subscriptions.forEach((t=>t()));this.unsubscribePlayerEvents();this.timer.destroy();this.renderer.destroy();super.destroy()}}yt.BasePlugin=p;yt.dom=M;function xt(t,i,s,e){return new(s||(s=Promise))((function(n,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e.throw(t))}catch(t){r(t)}}function a(t){var i;t.done?n(t.value):(i=t.value,i instanceof s?i:new s((function(t){t(i)}))).then(o,h)}a((e=e.apply(t,i||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class wt{constructor(){this.listeners={}}on(t,i,s){if(this.listeners[t]||(this.listeners[t]=new Set),null==s?void 0:s.once){const s=(...e)=>{this.un(t,s),i(...e)};return this.listeners[t].add(s),()=>this.un(t,s)}return this.listeners[t].add(i),()=>this.un(t,i)}un(t,i){var s;null===(s=this.listeners[t])||void 0===s||s.delete(i)}once(t,i){return this.on(t,i,{once:!0})}unAll(){this.listeners={}}emit(t,...i){this.listeners[t]&&this.listeners[t].forEach((t=>t(...i)))}}class kt extends wt{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((t=>t())),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}class Mt extends wt{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop(),this.unAll()}}const St=100,Ct=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class Pt extends kt{constructor(t){var i,s,e,n,r,o;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:null!==(i=t.audioBitsPerSecond)&&void 0!==i?i:128e3,scrollingWaveform:null!==(s=t.scrollingWaveform)&&void 0!==s&&s,scrollingWaveformWindow:null!==(e=t.scrollingWaveformWindow)&&void 0!==e?e:5,continuousWaveform:null!==(n=t.continuousWaveform)&&void 0!==n&&n,renderRecordedAudio:null===(r=t.renderRecordedAudio)||void 0===r||r,mediaRecorderTimeslice:null!==(o=t.mediaRecorderTimeslice)&&void 0!==o?o:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.micStream=null,this.recordedBlobUrl=null,this.timer=new Mt,this.subscriptions.push(this.timer.on("tick",(()=>{const t=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+t,this.emit("record-progress",this.duration)})))}static create(t){return new Pt(t||{})}renderMicStream(t){var i;const s=new AudioContext,e=s.createMediaStreamSource(t),n=s.createAnalyser();e.connect(n),(this.options.continuousWaveform||this.options.scrollingWaveform)&&(n.fftSize=32);const r=n.frequencyBinCount,o=new Float32Array(r);let h=0;this.wavesurfer&&(null!==(i=this.originalOptions)&&void 0!==i||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0,this.wavesurfer.options.normalize=!0,this.wavesurfer.options.maxPeak=1));const a=setInterval((()=>{var t,i,s,e;if(!this.isWaveformPaused){if(n.getFloatTimeDomainData(o),this.options.scrollingWaveform){const t=Math.floor((this.options.scrollingWaveformWindow||0)*St);let i=0;for(let t=0;t<r;t++){const s=Math.abs(o[t]);s>i&&(i=s)}this.dataWindow||(this.dataWindow=new Float32Array(t));const s=new Float32Array(t);if(this.dataWindow&&this.dataWindow.length>0){const i=t-1,e=this.dataWindow.slice(-i);s.set(e,0)}s[t-1]=i,this.dataWindow=s}else if(this.options.continuousWaveform){if(!this.dataWindow){const s=this.options.continuousWaveformDuration?Math.round(this.options.continuousWaveformDuration*St):(null!==(i=null===(t=this.wavesurfer)||void 0===t?void 0:t.getWidth())&&void 0!==i?i:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(s)}let s=0;for(let t=0;t<r;t++){const i=Math.abs(o[t]);i>s&&(s=i)}if(h+1>this.dataWindow.length){const t=new Float32Array(2*this.dataWindow.length);t.set(this.dataWindow,0),this.dataWindow=t}this.dataWindow[h]=s,h++}else this.dataWindow=o;if(this.wavesurfer){const t=(null!==(e=null===(s=this.dataWindow)||void 0===s?void 0:s.length)&&void 0!==e?e:0)/St;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:t).then((()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))})).catch((t=>{console.error("Error rendering real-time recording data:",t)}))}}}),10);return{onDestroy:()=>{clearInterval(a),null==e||e.disconnect(),null==s||s.close()},onEnd:()=>{this.isWaveformPaused=!0,this.stopMic()}}}startMic(t){return xt(this,void 0,void 0,(function*(){let i;this.micStream&&this.stopMic();try{i=yield navigator.mediaDevices.getUserMedia({audio:null==t||t})}catch(i){throw new Error("Error accessing the microphone: "+i.message)}const s=this.renderMicStream(i);return this.micStream=s,this.unsubscribeDestroy=this.once("destroy",s.onDestroy),this.unsubscribeRecordEnd=this.once("record-end",s.onEnd),this.stream=i,i}))}stopMic(){var t,i,s;null===(t=this.micStream)||void 0===t||t.onDestroy(),null===(i=this.unsubscribeDestroy)||void 0===i||i.call(this),null===(s=this.unsubscribeRecordEnd)||void 0===s||s.call(this),this.micStream=null,this.unsubscribeDestroy=void 0,this.unsubscribeRecordEnd=void 0,this.stream&&(this.stream.getTracks().forEach((t=>t.stop())),this.stream=null,this.mediaRecorder=null)}startRecording(t){return xt(this,void 0,void 0,(function*(){const i=this.stream||(yield this.startMic(t));this.dataWindow=null;const s=this.mediaRecorder||new MediaRecorder(i,{mimeType:this.options.mimeType||Ct.find((t=>MediaRecorder.isTypeSupported(t))),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=s,this.stopRecording();const e=[];s.ondataavailable=t=>{t.data.size>0&&e.push(t.data),this.emit("record-data-available",t.data)};const n=t=>{var i;const n=new Blob(e,{type:s.mimeType});this.emit(t,n),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),this.recordedBlobUrl&&URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=URL.createObjectURL(n),null===(i=this.wavesurfer)||void 0===i||i.load(this.recordedBlobUrl))};s.onpause=()=>n("record-pause"),s.onstop=()=>n("record-end"),s.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")}))}getDuration(){return this.duration}isRecording(){var t;return"recording"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isPaused(){var t;return"paused"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isActive(){var t;return"inactive"!==(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}stopRecording(){var t;this.isActive()&&(null===(t=this.mediaRecorder)||void 0===t||t.stop(),this.timer.stop())}pauseRecording(){var t,i;this.isRecording()&&(this.isWaveformPaused=!0,null===(t=this.mediaRecorder)||void 0===t||t.requestData(),null===(i=this.mediaRecorder)||void 0===i||i.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,null===(t=this.mediaRecorder)||void 0===t||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return xt(this,void 0,void 0,(function*(){return navigator.mediaDevices.enumerateDevices().then((t=>t.filter((t=>"audioinput"===t.kind))))}))}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic(),this.recordedBlobUrl&&(URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=null)}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}const Rt=40;const Wt=class{constructor(s){t(this,s);this.recordingProgress=i(this,"recordingProgress",7);this.recordingError=i(this,"recordingError",7);this.wavesurfer=null;this.recordPlugin=null;this.waveformContainer=null;this.loadAbortController=null;this.currentLoadingUrl=null;this.initializationInterval=null;this.pauseAudioHandler=()=>{if(!this.wavesurfer)return;this.isPlaying=false;this.wavesurfer.pause();this.audioDuration=n(Math.round(this.wavesurfer.getDuration()))};this.playAudioHandler=()=>{if(!this.wavesurfer){const t=this.initWaveSurfer();if(t){this.wavesurfer.once("ready",(()=>{this.isPlaying=true;this.wavesurfer.play()}))}return}this.isPlaying=true;this.wavesurfer.play()};this.audioUrl=undefined;this.audioWaveColor="#C5C5C5";this.audioProgressColor="#4A76FD";this.textColor="#4A76FD";this.isSelf=false;this.borderRadius="";this.bgColor="";this.time="";this.isRead=false;this.isDelivered=false;this.showFooter=false;this.messageId="";this.timeColor="";this.reactions={};this.messageType=undefined;this.liveRecord=false;this.isPlaying=false;this.audioDuration="0:00";this.currentAudioId=null;this.waveformContainerReady=false;this.initializationAttempts=0}componentWillLoad(){if(typeof yt!=="function"){console.error("WaveSurfer is not available as a function. Import may be failing.")}}componentDidLoad(){if(this.liveRecord){void this.startLiveRecording();return}if(this.initializationInterval){clearInterval(this.initializationInterval)}this.initializationInterval=setInterval((()=>{this.initializationAttempts++;if(this.waveformContainer&&this.audioUrl){this.initWaveSurfer();if(this.wavesurfer){clearInterval(this.initializationInterval)}}if(this.initializationAttempts>=10){clearInterval(this.initializationInterval)}}),500)}resolveWaveColor(){const t=(this.audioProgressColor||this.audioWaveColor||"").trim();if(t&&!t.startsWith("var("))return t;const i=getComputedStyle(this.el).getPropertyValue("--brand").trim();return i||"#2563eb"}ensureRecordWaveSurfer(){var t;if(!((t=this.waveformContainer)===null||t===void 0?void 0:t.isConnected))return false;if(this.wavesurfer&&this.recordPlugin)return true;if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null;this.recordPlugin=null}const i=Math.max(this.waveformContainer.clientWidth||0,this.el.clientWidth||0,160);const s=Math.max(this.waveformContainer.clientHeight||0,Rt);const e=this.resolveWaveColor();this.wavesurfer=yt.create({container:this.waveformContainer,waveColor:e,progressColor:e,height:s,width:i,barWidth:4,barGap:2,barRadius:3,barHeight:2.5,barMinHeight:3,normalize:true,interact:false,cursorWidth:0});this.recordPlugin=this.wavesurfer.registerPlugin(Pt.create({scrollingWaveform:true,renderRecordedAudio:false}));this.recordPlugin.on("record-progress",(t=>{this.recordingProgress.emit(t);this.audioDuration=n(Math.round(t/1e3))}));return true}async startLiveRecording(){var t;try{for(let i=0;i<20;i++){if(((t=this.waveformContainer)===null||t===void 0?void 0:t.isConnected)&&(this.waveformContainer.clientWidth>0||this.el.clientWidth>0)){break}await new Promise((t=>requestAnimationFrame((()=>t(null)))))}if(!this.ensureRecordWaveSurfer()){this.recordingError.emit("Waveform not ready");return false}await this.recordPlugin.startRecording();requestAnimationFrame((()=>{var t,i;const s=((t=this.waveformContainer)===null||t===void 0?void 0:t.clientWidth)||this.el.clientWidth;const e=Math.max(((i=this.waveformContainer)===null||i===void 0?void 0:i.clientHeight)||0,Rt);if(s&&this.wavesurfer){try{this.wavesurfer.setOptions({width:s,height:e})}catch(t){}}}));return true}catch(t){console.error(t);this.recordingError.emit((t===null||t===void 0?void 0:t.message)||"Microphone access denied");return false}}async pauseLiveRecording(){var t;(t=this.recordPlugin)===null||t===void 0?void 0:t.pauseRecording()}async resumeLiveRecording(){var t;(t=this.recordPlugin)===null||t===void 0?void 0:t.resumeRecording()}async stopLiveRecording(){if(!this.recordPlugin)return null;if(!this.recordPlugin.isRecording()&&!this.recordPlugin.isPaused()){this.cleanupRecord();return null}return new Promise((t=>{const i=i=>{this.cleanupRecord();t(i)};this.recordPlugin.once("record-end",(t=>i(t||null)));try{this.recordPlugin.stopRecording()}catch(t){i(null)}}))}async cancelLiveRecording(){var t,i,s,e;try{if(((i=(t=this.recordPlugin)===null||t===void 0?void 0:t.isRecording)===null||i===void 0?void 0:i.call(t))||((e=(s=this.recordPlugin)===null||s===void 0?void 0:s.isPaused)===null||e===void 0?void 0:e.call(s))){this.recordPlugin.stopRecording()}}catch(t){}this.cleanupRecord()}cleanupRecord(){var t,i;try{(i=(t=this.recordPlugin)===null||t===void 0?void 0:t.stopMic)===null||i===void 0?void 0:i.call(t)}catch(t){}if(this.wavesurfer){try{this.wavesurfer.destroy()}catch(t){}}this.wavesurfer=null;this.recordPlugin=null}initWaveSurfer(){if(!this.waveformContainer){console.error("Waveform container reference is missing");return false}if(!this.waveformContainer.isConnected){console.error("Waveform container is not connected to DOM");return false}if(!this.audioUrl){console.error("Audio URL is missing");return false}try{this.abortCurrentLoad();if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null}this.loadAbortController=new AbortController;this.currentLoadingUrl=this.audioUrl;this.wavesurfer=yt.create({container:this.waveformContainer,waveColor:this.isSelf?"#000000":this.audioWaveColor,progressColor:this.audioProgressColor,height:40,barHeight:1,barWidth:4,barRadius:3,barGap:4,normalize:true,sampleRate:6e4,fetchParams:{signal:this.loadAbortController.signal}});if(!this.wavesurfer){console.error("Failed to create WaveSurfer instance");return false}this.wavesurfer.load(this.audioUrl);this.wavesurfer.on("ready",(()=>{if(this.currentLoadingUrl===this.audioUrl){const t=this.wavesurfer.getDuration();const i=n(Math.round(t));this.audioDuration=i}}));this.wavesurfer.on("audioprocess",(()=>{const t=Math.max(0,this.wavesurfer.getDuration()-this.wavesurfer.getCurrentTime());this.audioDuration=n(Math.round(t))}));this.wavesurfer.on("finish",(()=>{this.isPlaying=false;this.wavesurfer.seekTo(0);this.audioDuration=n(Math.round(this.wavesurfer.getDuration()))}));this.wavesurfer.on("error",(t=>{if(t.name!=="AbortError"){console.error("WaveSurfer error:",t)}}));return true}catch(t){console.error("Error initializing WaveSurfer:",t);return false}}abortCurrentLoad(){if(this.loadAbortController){this.loadAbortController.abort();this.loadAbortController=null}this.currentLoadingUrl=null}disconnectedCallback(){this.abortCurrentLoad();this.cleanupRecord();if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null}this.isPlaying=false;if(this.initializationInterval){clearInterval(this.initializationInterval)}}chatChanged(t,i){if(t!==i){if(this.wavesurfer&&this.isPlaying){this.wavesurfer.pause();this.isPlaying=false}this.audioDuration="0:00";setTimeout((()=>{if(this.waveformContainer&&t){this.initWaveSurfer()}}),100)}}render(){const t=this.liveRecord;return s("div",{key:"9e4dfb7827f9ee6f3c34218128201ee2ce3b9910",style:{background:t?"transparent":this.bgColor||(this.isSelf?"var(--bg-outgoing-message)":"var(--bg-incoming-message)"),borderRadius:t?"0":this.borderRadius||"7.5px",color:this.textColor||"inherit",padding:t?"0":"10px",width:t?"100%":"336px",maxWidth:"100%",boxSizing:"border-box"}},s("div",{key:"a10a192919ca0ee6c4d7b5dfff2571600067fa24",style:{display:"flex",alignItems:"center",gap:t?"0":"10px",width:"100%"}},t?null:s("button",{type:"button","aria-label":this.isPlaying?"Pause":"Play",style:{border:"none",background:"transparent",cursor:"pointer",fontSize:"18px",color:"inherit"},onClick:()=>this.isPlaying?this.pauseAudioHandler():this.playAudioHandler()},this.isPlaying?"❚❚":"▶"),s("div",{key:"6e5505cd0ff554633ea9471ef9c51044d70e6173",class:"wave-host",ref:t=>{this.waveformContainer=t},style:{flex:"1",height:t?`${Rt}px`:"40px",minHeight:t?`${Rt}px`:"40px",minWidth:"0"}})),t?null:s("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"10px",marginTop:"4px"}},s("span",null,this.audioDuration),this.showFooter?s("span",{style:{color:this.timeColor}},this.time?(()=>{try{const t=new Date(Number(this.time));if(Number.isNaN(t.getTime()))return this.time;return new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit",hour12:true}).format(t)}catch(t){return this.time}})():"",this.isSelf?this.isRead?" ✓✓":this.isDelivered?" ✓✓":" ✓":""):null))}get el(){return e(this)}static get watchers(){return{audioUrl:["chatChanged"]}}};Wt.style=":host {\n display: block;\n width: 100%;\n height: 100%;\n min-width: 0;\n box-sizing: border-box;\n }\n .wave-host {\n width: 100%;\n height: 100%;\n min-width: 0;\n /* Stencil styles: literal 40px — keep in sync with LIVE_RECORD_WAVE_HEIGHT_PX */\n min-height: 40px;\n }";const At=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.openPreview=t=>{var i,s;(i=t===null||t===void 0?void 0:t.preventDefault)===null||i===void 0?void 0:i.call(t);(s=t===null||t===void 0?void 0:t.stopPropagation)===null||s===void 0?void 0:s.call(t);if(!this.href)return;if(this.isPdf()){this.showPdfPreview=true;return}window.open(this.href,"_blank","noopener,noreferrer")};this.closePreview=()=>{this.showPdfPreview=false};this.bgColor=undefined;this.borderRadius="6px";this.padding="10px";this.docName=undefined;this.width=undefined;this.height=undefined;this.documentNameBg=undefined;this.documentNamePadding=undefined;this.time=undefined;this.href=undefined;this.fileName=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.deliveryStatus=undefined;this.docType="";this.textColor=undefined;this.message=undefined;this.mentionedUsers=[];this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.showPdfPreview=false}truncateDocName(t){const i=t.lastIndexOf(".");const s=i!==-1?t.slice(0,i):t;const e=i!==-1?t.slice(i):"";const n=40-e.length;if(s.length<=n){return{firstLine:s.slice(0,Math.min(20,s.length)),secondLine:`${s.slice(20)}${e}`}}const r=s.slice(0,n-3)+"...";return{firstLine:r.slice(0,20),secondLine:`${r.slice(20)}${e}`}}isPdf(){const t=(this.docType||"").toLowerCase();const i=(this.docName||this.fileName||"").toLowerCase();return t.includes("pdf")||i.endsWith(".pdf")}iconSrc(){const t=(this.docType||"").toLowerCase();const i=(this.docName||this.fileName||"").toLowerCase();if(t.includes("pdf")||i.endsWith(".pdf"))return h;if(t.includes("spreadsheet")||t.includes("excel")||/\.xlsx?$/.test(i)||i.endsWith(".csv"))return a;if(t.includes("rtf")||i.endsWith(".rtf"))return l;if(t.includes("text/plain")||i.endsWith(".txt"))return c;return h}render(){const t=this.truncateDocName(this.docName||"Document");const i=(this.docName||this.fileName||"").trim();const e=String(this.message||"").trim();const n=(()=>{if(!e||!i)return false;if(e.localeCompare(i,undefined,{sensitivity:"accent"})===0)return true;const t=t=>(t.split(/[/\\]/).pop()||t).trim();return t(e).localeCompare(t(i),undefined,{sensitivity:"accent"})===0})();const h=e&&!e.includes("AttachmentMessage:")&&!n;const a=this.isPdf();return s("message-bubble",{isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,deliveryStatus:this.deliveryStatus,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor||"var(--bg-secondary)",borderRadius:this.borderRadius||"6px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{class:"doc-container",style:{backgroundColor:this.documentNameBg||"var(--bg-tertiary)",width:this.width||"auto"}},s("div",{class:"document-name",style:{padding:this.documentNamePadding||"5px 10px 5px 0"},onClick:this.openPreview,role:"button",tabIndex:0,onKeyDown:t=>{if(t.key==="Enter"||t.key===" ")this.openPreview(t)}},s("span",{class:"attachment-icon"},s("img",{src:this.iconSrc(),alt:""})),s("span",null,t.firstLine,s("br",null),t.secondLine)),s("div",{class:"doc-actions"},a&&this.href?s("button",{class:"preview-btn",type:"button",onClick:this.openPreview,"aria-label":"Preview PDF"},"View"):null,s("a",{class:"download-btn",href:this.href,download:this.fileName,target:"_blank",rel:"noopener noreferrer","aria-label":"Download"},s("img",{src:d,alt:""})))),h?s("div",{style:{fontSize:"8px",color:this.textColor,marginTop:"4px"}},r(this.message,this.mentionedUsers,(t=>o(this.tagUserClick,t)),!!this.isSelf)):null,this.showPdfPreview&&this.href?s("div",{class:"pdf-lightbox",onClick:this.closePreview},s("div",{class:"pdf-lightbox-bar",onClick:t=>t.stopPropagation()},s("span",{class:"pdf-lightbox-title"},this.docName||this.fileName||"PDF"),s("div",{style:{display:"flex",gap:"8px"}},s("a",{href:this.href,download:this.fileName||this.docName,target:"_blank",rel:"noopener noreferrer",style:{color:"#fff",fontSize:"12px",fontWeight:"600",textDecoration:"none",padding:"6px 12px",background:"rgba(255,255,255,0.15)",borderRadius:"8px"}},"Download"),s("button",{type:"button",onClick:this.closePreview},"Close"))),s("iframe",{src:`${this.href}#toolbar=1`,title:this.docName||"PDF preview",onClick:t=>t.stopPropagation()})):null)}};At.style=":host { display: block; }\n .doc-container {\n display: flex; align-items: center; justify-content: space-between; gap: 8px;\n border-radius: 8px; padding: 4px 8px;\n }\n .document-name {\n display: flex; align-items: center; gap: 8px; word-break: break-word;\n font-size: 12px; line-height: 1.35; min-width: 0; cursor: pointer;\n }\n .attachment-icon { display: flex; flex-shrink: 0; width: 24px; height: 30px; align-items: center; justify-content: center; }\n .attachment-icon img { width: 24px; height: 24px; object-fit: contain; display: block; }\n .doc-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }\n .download-btn, .preview-btn {\n display: flex; align-items: center; justify-content: center;\n flex-shrink: 0; line-height: 0; border: none; background: transparent; cursor: pointer; padding: 0;\n text-decoration: none; color: inherit; font: inherit;\n }\n .download-btn img, .preview-btn img {\n width: 28px; height: 28px; display: block;\n filter: var(--svg-icon-filter);\n }\n .preview-btn {\n font-size: 10px; font-weight: 700; letter-spacing: 0.04em;\n color: var(--brand, #2563eb); padding: 4px 6px; border-radius: 6px;\n background: color-mix(in srgb, var(--brand, #2563eb) 12%, transparent);\n }\n .pdf-lightbox {\n position: fixed; inset: 0; z-index: 9999;\n background: rgba(15, 23, 42, 0.72);\n display: flex; flex-direction: column;\n padding: 12px; box-sizing: border-box;\n }\n .pdf-lightbox-bar {\n display: flex; align-items: center; justify-content: space-between;\n gap: 12px; padding: 8px 4px 12px; color: #fff; flex-shrink: 0;\n }\n .pdf-lightbox-title {\n font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;\n }\n .pdf-lightbox-bar button {\n border: none; background: rgba(255,255,255,0.15); color: #fff;\n border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 12px; font-weight: 600;\n }\n .pdf-lightbox iframe {\n flex: 1; width: 100%; min-height: 0; border: 0; border-radius: 10px; background: #525659;\n }";const Dt=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.openGallery=t=>{var i;(i=this.onImageClick)===null||i===void 0?void 0:i.call(this,t);this.galleryOpen=true};this.downloadPreview=t=>{t.stopPropagation();const i=this.downloadUrl||this.imageSrc;if(!i)return;void u(i,this.downloadFileName,this.mimeType)};this.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.imageSrc=undefined;this.downloadUrl=undefined;this.downloadFileName=undefined;this.mimeType=undefined;this.message=undefined;this.height="220px";this.width="250px";this.time=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.deliveryStatus=undefined;this.textColor=undefined;this.allAttachments=undefined;this.isMediaGalleryOpen=undefined;this.onImageClick=undefined;this.mentionedUsers=[];this.totalMedia=0;this.mediaType=undefined;this.loadingMediaGallery=undefined;this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.galleryOpen=false}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("div",{key:"a5f207c46152f6985e004c890ae359fb806289d2"},s("message-bubble",{key:"7ac2761da95a06ef5081dcad7dbd665bdcbe911f",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,deliveryStatus:this.deliveryStatus,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor,borderRadius:this.borderRadius||"10px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"df99c21dcb4672c6ef9b8e0288d22e761dde6143",class:"image-container",style:{width:this.width||"250px",height:this.height||"220px",borderRadius:this.borderRadius},onClick:this.openGallery},s("img",{key:"bd79e700108db22923c5084c5c78ff60cfbac858",src:this.imageSrc,alt:"image"}),this.totalMedia>0?s("span",{class:"mediaCount"}," + ",this.totalMedia):null),t?s("div",{style:{fontSize:"14px",color:this.textColor,marginTop:"4px"}},r(this.message,this.mentionedUsers,(t=>o(this.tagUserClick,t)),!!this.isSelf)):null),this.galleryOpen?s("div",{class:"gallery-overlay",onClick:()=>this.galleryOpen=false},s("div",{class:"gallery-bar",onClick:t=>t.stopPropagation()},s("button",{type:"button",class:"gallery-action","aria-label":"Download",style:{["--download-icon"]:`url("${d}")`},onClick:t=>this.downloadPreview(t)},s("span",{class:"gallery-download-mask","aria-hidden":"true"})),s("button",{type:"button",class:"gallery-action","aria-label":"Close",onClick:()=>this.galleryOpen=false},s("span",{class:"gallery-close-icon"},"×"))),s("div",{class:"gallery-stage"},s("img",{src:this.imageSrc,alt:"full",onClick:t=>t.stopPropagation()}))):null)}};Dt.style=":host { display: block; font-family: var(--font-primary); }\n .image-container { cursor: pointer; overflow: hidden; position: relative; }\n .image-container img { width: var(--w-full); height: var(--h-full); object-fit: cover; display: block; }\n .mediaCount {\n position: absolute; right: var(--space-8); bottom: var(--space-8);\n background: var(--overlay); color: var(--text-on-brand);\n padding: var(--gap-2) var(--gap-6); border-radius: var(--rounded-8); font-size: var(--text-12);\n }\n .gallery-overlay {\n position: fixed; inset: 0; background: var(--overlay); z-index: 9999;\n display: flex; flex-direction: column;\n }\n .gallery-bar {\n display: flex; justify-content: flex-end; align-items: center; gap: var(--space-8);\n padding: var(--space-8) var(--space-12); flex-shrink: 0;\n }\n .gallery-bar .gallery-action {\n display: flex; align-items: center; justify-content: center;\n border: none; background: transparent; cursor: pointer; padding: 4px;\n color: var(--text-on-brand); line-height: 0;\n width: 28px; height: 28px;\n }\n .gallery-bar .gallery-download-mask {\n width: 20px; height: 20px; display: block;\n background-color: currentColor;\n -webkit-mask: var(--download-icon) center / contain no-repeat;\n mask: var(--download-icon) center / contain no-repeat;\n }\n .gallery-bar .gallery-close-icon {\n font-size: 20px; line-height: 1;\n }\n .gallery-stage {\n flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0;\n padding: 0 var(--space-16) var(--space-16);\n }\n .gallery-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }";const Ht=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.playVideo=()=>{const t=this.videoEl();if(!t)return;t.play();this.isPlaying=true};this.pauseVideo=()=>{const t=this.videoEl();if(!t)return;t.pause();this.isPlaying=false};this.toggle=()=>this.isPlaying?this.pauseVideo():this.playVideo();this.fullscreen=()=>{var t;const i=this.videoEl();(t=i===null||i===void 0?void 0:i.requestFullscreen)===null||t===void 0?void 0:t.call(i)};this.downloadVideo=t=>{t.preventDefault();t.stopPropagation();const i=this.resolveVideoUrl();if(!i)return;void u(i,this.downloadFileName,this.videoType||this.type)};this.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.videoSrc=undefined;this.downloadFileName=undefined;this.poster="";this.videoType="video/mp4";this.time=undefined;this.height="150px";this.width="150px";this.playing=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.deliveryStatus=undefined;this.textColor=undefined;this.message=undefined;this.mentionedUsers=[];this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.type=undefined;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.isPlaying=false}videoEl(){var t;return((t=this.el.shadowRoot)===null||t===void 0?void 0:t.querySelector("video"))||null}resolveVideoUrl(){var t;return this.videoSrc||((t=this.videoEl())===null||t===void 0?void 0:t.currentSrc)||""}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("message-bubble",{key:"4b672ea1d53be97115d7859b8cb61a2f31d17d6c",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,deliveryStatus:this.deliveryStatus,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor,borderRadius:this.borderRadius||"10px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"b615a7f4f55010ac4e1fee0c5a439f11bbf57d3b",class:"video-wrap"},s("video",{key:"ac3ac6918f714849828590b96fd36f70bfd0882c",style:{height:this.height||"150px",width:this.width||"150px",objectFit:"cover",borderRadius:this.borderRadius||"8px"},src:this.videoSrc||undefined,poster:this.poster||undefined,preload:this.poster?"none":"metadata",onClick:this.toggle},s("source",{key:"f43f9c615d1f1f3c4e4e8f941efb02a1fc7eb305",src:this.videoSrc,type:this.videoType||"video/mp4"})),s("div",{key:"db2ee6e3b7fea19634d07a15e0516d69488a1983",class:"controls"},!this.isPlaying?s("button",{type:"button",onClick:this.playVideo,"aria-label":"Play"},"▶"):s("button",{type:"button",onClick:this.pauseVideo,"aria-label":"Pause"},"❚❚")),s("button",{key:"e282ae6caf07832e49e6791d33ee950b7bd1ed91",type:"button",class:"video_corner video_download",onClick:t=>this.downloadVideo(t),"aria-label":"Download"},s("img",{key:"d0ed1fb8ce8b5d5b9c246c9a99e3a04e907ebbaf",src:d,alt:""})),s("button",{key:"4d777aaf7650d5bcdd9f51da470bc43837f19092",type:"button",class:"video_corner video_fullscreen",onClick:this.fullscreen,"aria-label":"Fullscreen"},"⛶")),t?s("div",{style:{fontSize:"14px",color:this.textColor,marginTop:"4px"}},r(this.message,this.mentionedUsers,(t=>o(this.tagUserClick,t)),!!this.isSelf)):null)}get el(){return e(this)}};Ht.style=":host { display: block; position: relative; }\n .video-wrap { position: relative; width: fit-content; }\n .controls {\n position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center;\n pointer-events: none;\n }\n .controls button {\n pointer-events: auto; border: none; background: var(--overlay); color: var(--text-on-brand);\n cursor: pointer; padding: 8px 10px; border-radius: 8px; margin: 0 4px;\n }\n .video_corner {\n position: absolute; bottom: 8px; z-index: 2; pointer-events: auto;\n border: none; background: var(--overlay); color: var(--text-on-brand);\n cursor: pointer; padding: 6px; border-radius: 8px; line-height: 0;\n width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;\n }\n .video_corner img {\n width: 16px; height: 16px; display: block; object-fit: contain;\n filter: brightness(0) invert(1);\n }\n .video_download { left: 8px; }\n .video_fullscreen { right: 8px; font-size: 14px; line-height: 1; }";export{Wt as audio_bubble,At as document_message,Dt as image_message,Ht as video_message};
2
- //# sourceMappingURL=p-0bb42151.entry.js.map
1
+ import{r as t,a as i,h as s,g as e}from"./p-17a96a2a.js";import{i as n}from"./p-f97e3f6d.js";import{r,e as o}from"./p-d28c5548.js";import{i as h,j as a,k as l,l as c}from"./p-c06ad586.js";import{D as d,d as u}from"./p-782d1bd2.js";import"./p-5162774c.js";class f{constructor(){this.listeners={}}on(t,i,s){if(!this.listeners[t]){this.listeners[t]=new Set}if(s===null||s===void 0?void 0:s.once){const s=(...e)=>{this.un(t,s);i(...e)};this.listeners[t].add(s);return()=>this.un(t,s)}this.listeners[t].add(i);return()=>this.un(t,i)}un(t,i){var s;(s=this.listeners[t])===null||s===void 0?void 0:s.delete(i)}once(t,i){return this.on(t,i,{once:true})}unAll(){this.listeners={}}emit(t,...i){if(this.listeners[t]){this.listeners[t].forEach((t=>t(...i)))}}}class p extends f{constructor(t){super();this.subscriptions=[];this.isDestroyed=false;this.options=t}onInit(){return}_init(t){if(this.isDestroyed){this.subscriptions=[];this.isDestroyed=false}this.wavesurfer=t;this.onInit()}destroy(){this.emit("destroy");this.subscriptions.forEach((t=>t()));this.subscriptions=[];this.isDestroyed=true;this.wavesurfer=undefined}}var v=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};function g(t,i){return v(this,void 0,void 0,(function*(){const s=new AudioContext({sampleRate:i});try{return yield s.decodeAudioData(t)}finally{if(s.state!=="closed"){yield s.close().catch((()=>undefined))}}}))}function b(t){const i=t[0];if(i.some((t=>t>1||t<-1))){const s=i.length;let e=0;for(let t=0;t<s;t++){const s=Math.abs(i[t]);if(s>e)e=s}for(const i of t){for(let t=0;t<s;t++){i[t]/=e}}}return t}function m(t,i){if(!t||t.length===0){throw new Error("channelData must be a non-empty array")}if(i<=0){throw new Error("duration must be greater than 0")}if(typeof t[0]==="number")t=[t];if(!t[0]||t[0].length===0){throw new Error("channelData must contain non-empty channel arrays")}b(t);const s=t.map((t=>t instanceof Float32Array?t:Float32Array.from(t)));return{duration:i,length:s[0].length,sampleRate:s[0].length/i,numberOfChannels:s.length,getChannelData:t=>{const i=s[t];if(!i){throw new Error(`Channel ${t} not found`)}return i},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}const y={decode:g,createBuffer:m};function x(t,i){const s=i.xmlns?document.createElementNS(i.xmlns,t):document.createElement(t);for(const[t,e]of Object.entries(i)){if(t==="children"&&e){for(const[t,i]of Object.entries(e)){if(i instanceof Node){s.appendChild(i)}else if(typeof i==="string"){s.appendChild(document.createTextNode(i))}else{s.appendChild(x(t,i))}}}else if(t==="style"){Object.assign(s.style,e)}else if(t==="textContent"){s.textContent=e}else{s.setAttribute(t,e.toString())}}return s}function w(t,i,s){const e=x(t,i||{});s===null||s===void 0?void 0:s.appendChild(e);return e}function k(t){if(t instanceof HTMLElement)return true;return typeof t==="object"&&t!==null&&t.nodeType===Node.ELEMENT_NODE&&typeof t.style==="object"}const M=Object.freeze({__proto__:null,createElement:w,isHTMLElement:k,default:w});var S=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};function C(t,i,s){return S(this,void 0,void 0,(function*(){var e;if(!t.body||!t.headers)return;const n=t.body.getReader();const r=Number(t.headers.get("Content-Length"))||0;let o=0;const h=()=>{n.cancel()};if(s){if(s.aborted){n.cancel();return}s.addEventListener("abort",h,{once:true})}try{while(true){const t=yield n.read();if(t.done){break}o+=((e=t.value)===null||e===void 0?void 0:e.length)||0;if(r>0){const t=Math.round(o/r*100);i(t)}}}catch(t){if(t instanceof DOMException&&t.name==="AbortError")return;console.warn("Progress tracking error:",t)}finally{if(s){s.removeEventListener("abort",h)}}}))}function P(t,i,s){return S(this,void 0,void 0,(function*(){var e;const n=yield fetch(t,s);if(n.status>=400){throw new Error(`Failed to fetch ${t}: ${n.status} (${n.statusText})`)}C(n.clone(),i,(e=s===null||s===void 0?void 0:s.signal)!==null&&e!==void 0?e:undefined);return n.blob()}))}const R={fetchBlob:P};function W(t){let i=t;const s=new Set;return{get value(){return i},set(t){if(!Object.is(i,t)){i=t;s.forEach((t=>t(i)))}},update(t){this.set(t(i))},subscribe(t){s.add(t);return()=>s.delete(t)}}}function A(t,i){const s=W(t());i.forEach((i=>i.subscribe((()=>{const i=t();if(!Object.is(s.value,i)){s.set(i)}}))));return{get value(){return s.value},subscribe(t){return s.subscribe(t)}}}function D(t,i){let s;const e=()=>{if(s){s();s=undefined}s=t()};const n=i.map((t=>t.subscribe(e)));e();return()=>{if(s){s();s=undefined}n.forEach((t=>t()))}}var H=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};class j extends f{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(t){super();this.isExternalMedia=false;this._ownBlobUrl=null;this.reactiveMediaEventCleanups=[];if(t.media){this.media=t.media;this.isExternalMedia=true}else{this.media=document.createElement("audio")}this._isPlaying=W(false);this._currentTime=W(0);this._duration=W(0);this._volume=W(this.media.volume);this._muted=W(this.media.muted);this._playbackRate=W(this.media.playbackRate||1);this._seeking=W(false);this.setupReactiveMediaEvents();if(t.mediaControls){this.media.controls=true}if(t.autoplay){this.media.autoplay=true}if(t.playbackRate!=null){this.onMediaEvent("canplay",(()=>{if(t.playbackRate!=null){this.media.playbackRate=t.playbackRate}}),{once:true})}}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",(()=>{this._isPlaying.set(true)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",(()=>{this._isPlaying.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",(()=>{this._isPlaying.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",(()=>{this._currentTime.set(this.media.currentTime)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",(()=>{this._duration.set(this.media.duration||0)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",(()=>{this._duration.set(this.media.duration||0)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",(()=>{this._seeking.set(true)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",(()=>{this._seeking.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",(()=>{this._volume.set(this.media.volume);this._muted.set(this.media.muted)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",(()=>{this._playbackRate.set(this.media.playbackRate)})))}onMediaEvent(t,i,s){this.media.addEventListener(t,i,s);return()=>this.media.removeEventListener(t,i,s)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){if(this._ownBlobUrl){URL.revokeObjectURL(this._ownBlobUrl);this._ownBlobUrl=null}}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,i){const s=this.getSrc();if(t&&s===t)return;this.revokeSrc();const e=i instanceof Blob&&(this.canPlayType(i.type)||!t)?URL.createObjectURL(i):t;if(e!==t){this._ownBlobUrl=e}if(s){this.media.removeAttribute("src")}if(e||t){try{this.media.src=e}catch(i){this.media.src=t}}}destroy(){this.reactiveMediaEventCleanups.forEach((t=>t()));this.reactiveMediaEventCleanups=[];this.revokeSrc();this.unAll();if(this.isExternalMedia)return;this.media.pause();this.media.removeAttribute("src");this.media.load();this.media.remove()}setMediaElement(t){this.reactiveMediaEventCleanups.forEach((t=>t()));this.reactiveMediaEventCleanups=[];this.media=t;this.setupReactiveMediaEvents()}play(){return H(this,void 0,void 0,(function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&t.name==="AbortError"){return}throw t}}))}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,i){if(i!=null){this.media.preservesPitch=i}this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){const i=this.media;return i.setSinkId(t)}}const E=128;const z=8e3;const T=10;function O(t){if(t<0)return 0;if(t>1)return 1;return t}function L({width:t,height:i,length:s,options:e,pixelRatio:n}){const r=i/2;const o=e.barWidth?e.barWidth*n:1;const h=e.barGap?e.barGap*n:e.barWidth?o/2:0;const a=e.barRadius||0;const l=e.barMinHeight?e.barMinHeight*n:0;const c=o+h||1;const d=s>0?t/c/s:0;return{halfHeight:r,barWidth:o,barGap:h,barRadius:a,barMinHeight:l,barIndexScale:d,barSpacing:c}}function $({maxTop:t,maxBottom:i,halfHeight:s,vScale:e,barMinHeight:n=0,barAlign:r}){let o=Math.round(t*s*e);const h=Math.round(i*s*e);let a=o+h||1;if(a<n){a=n;if(!r){o=a/2}}return{topHeight:o,totalHeight:a}}function I({barAlign:t,halfHeight:i,topHeight:s,totalHeight:e,canvasHeight:n}){if(t==="top")return 0;if(t==="bottom")return n-e;return i-s}function F({channelData:t,barIndexScale:i,barSpacing:s,barWidth:e,halfHeight:n,vScale:r,canvasHeight:o,barAlign:h,barMinHeight:a}){const l=t[0]||[];const c=t[1]||l;const d=l.length;const u=[];let f=0;let p=0;let v=0;for(let t=0;t<=d;t++){const d=Math.round(t*i);if(d>f){const{topHeight:t,totalHeight:i}=$({maxTop:p,maxBottom:v,halfHeight:n,vScale:r,barMinHeight:a,barAlign:h});const l=I({barAlign:h,halfHeight:n,topHeight:t,totalHeight:i,canvasHeight:o});u.push({x:f*s,y:l,width:e,height:i});f=d;p=0;v=0}const g=Math.abs(l[t]||0);const b=Math.abs(c[t]||0);if(g>p)p=g;if(b>v)v=b}return u}function _(t,i,s){const e=i-t.left;const n=s-t.top;const r=e/t.width;const o=n/t.height;return[r,o]}function B({optionsHeight:t,optionsSplitChannels:i,parentHeight:s,numberOfChannels:e,defaultHeight:n=E}){if(t==null)return n;const r=Number(t);if(!isNaN(r))return r;if(t==="auto"){const t=s||n;if(i===null||i===void 0?void 0:i.every((t=>!t.overlay))){return t/e}return t}return n}function N(t){return Math.max(1,t||1)}function U(t){return Boolean(t.barWidth||t.barGap||t.barAlign)}function V(t,i,s){if(!Array.isArray(t))return t||"";if(t.length===0)return"#999";if(t.length<2)return t[0]||"";const e=document.createElement("canvas");const n=e.getContext("2d");if(!n)return t[0]||"";const r=s||e.height*i;const o=n.createLinearGradient(0,0,0,r);const h=1/(t.length-1);t.forEach(((t,i)=>{o.addColorStop(i*h,t)}));return o}function X({duration:t,minPxPerSec:i=0,parentWidth:s,fillParent:e,pixelRatio:n}){const r=Math.ceil(t*i);const o=r>s;const h=Boolean(e&&!o);const a=(h?s:r)*n;return{scrollWidth:r,isScrollable:o,useParentWidth:h,width:a}}function G(t,i){if(!U(i))return t;const s=i.barWidth||.5;const e=i.barGap||s/2;const n=s+e;if(n===0)return t;return Math.floor(t/n)*n}function q({clientWidth:t,totalWidth:i,options:s}){const e=Math.min(z,t,i);return G(e,s)}function K({channelData:t,offset:i,clampedWidth:s,totalWidth:e}){return t.map((t=>{const n=Math.floor(i/e*t.length);const r=Math.floor((i+s)/e*t.length);return t.slice(n,r)}))}function Y(t){return t>T}function Z({scrollLeft:t,totalWidth:i,numCanvases:s}){if(i===0)return[0];const e=t/i;const n=Math.floor(e*s);return[n-1,n,n+1]}function J({channelData:t,barHeight:i,normalize:s,maxPeak:e}){var n;const r=i||1;if(!s)return r;const o=t[0];if(!o||o.length===0)return r;let h=e!==null&&e!==void 0?e:0;if(!e){for(let t=0;t<o.length;t++){const i=(n=o[t])!==null&&n!==void 0?n:0;const s=Math.abs(i);if(s>h)h=s}}if(!h)return r;return r/h}function Q({channelData:t,width:i,height:s,vScale:e}){const n=s/2;const r=t[0]||[];const o=t[1]||r;const h=[r,o];return h.map(((t,s)=>{const r=t.length;const o=r?i/r:0;const h=n;const a=s===0?-1:1;const l=[{x:0,y:h}];let c=0;let d=0;for(let i=0;i<=r;i++){const s=Math.round(i*o);if(s>c){const t=Math.round(d*n*e)||1;const i=h+t*a;l.push({x:c,y:i});c=s;d=0}const r=Math.abs(t[i]||0);if(r>d)d=r}l.push({x:c,y:h});return l}))}function tt(t){const i=t*2;const s=i<0?Math.floor(i):Math.ceil(i);return s/2}function it(t){const i=t._cleanup;if(typeof i==="function"){i()}}function st(t,i={}){const{threshold:s=3,mouseButton:e=0,touchDelay:n=100}=i;const r=W(null);const o=new Map;const h=matchMedia("(pointer: coarse)").matches;let a=()=>void 0;const l=i=>{if(i.button!==e)return;if(o.has(i.pointerId))return;o.set(i.pointerId,i);if(o.size>1){return}const l=i.pointerId;let c=i.clientX;let d=i.clientY;let u=false;const f=Date.now();const p=t.getBoundingClientRect();const{left:v,top:g}=p;const b=t=>{if(t.pointerId!==l)return;if(t.defaultPrevented||o.size>1){return}if(h&&Date.now()-f<n)return;const i=t.clientX;const e=t.clientY;const a=i-c;const p=e-d;if(u||Math.abs(a)>s||Math.abs(p)>s){t.preventDefault();t.stopPropagation();if(!u){r.set({type:"start",x:c-v,y:d-g});u=true}r.set({type:"move",x:i-v,y:e-g,deltaX:a,deltaY:p});c=i;d=e}};const m=t=>{if(!o.delete(t.pointerId))return;if(t.pointerId===l&&u){const i=t.clientX;const s=t.clientY;r.set({type:"end",x:i-v,y:s-g})}if(o.size===0){a()}};const y=t=>{if(!t.relatedTarget||t.relatedTarget===document.documentElement){m(t)}};const x=t=>{if(u){t.stopPropagation();t.preventDefault()}};const w=t=>{if(t.defaultPrevented||o.size>1){return}if(u){t.preventDefault()}};document.addEventListener("pointermove",b);document.addEventListener("pointerup",m);document.addEventListener("pointerout",y);document.addEventListener("pointercancel",y);document.addEventListener("touchmove",w,{passive:false});document.addEventListener("click",x,{capture:true});a=()=>{document.removeEventListener("pointermove",b);document.removeEventListener("pointerup",m);document.removeEventListener("pointerout",y);document.removeEventListener("pointercancel",y);document.removeEventListener("touchmove",w);setTimeout((()=>{document.removeEventListener("click",x,{capture:true})}),10)}};t.addEventListener("pointerdown",l);const c=()=>{a();t.removeEventListener("pointerdown",l);o.clear();it(r)};return{signal:r,cleanup:c}}function et(t){const{scrollLeft:i,scrollWidth:s,clientWidth:e}=t;if(s===0){return{startX:0,endX:1}}const n=i/s;const r=(i+e)/s;return{startX:Math.max(0,Math.min(1,n)),endX:Math.max(0,Math.min(1,r))}}function nt(t){return{left:t.scrollLeft,right:t.scrollLeft+t.clientWidth}}function rt(t){const i=W({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth});const s=A((()=>et(i.value)),[i]);const e=A((()=>nt(i.value)),[i]);const n=()=>{i.set({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})};t.addEventListener("scroll",n,{passive:true});const r=()=>{t.removeEventListener("scroll",n);it(i)};return{scrollData:i,percentages:s,bounds:e,cleanup:r}}var ot=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};var ht=undefined&&undefined.__rest||function(t,i){var s={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0)s[e]=t[e];if(t!=null&&typeof Object.getOwnPropertySymbols==="function")for(var n=0,e=Object.getOwnPropertySymbols(t);n<e.length;n++){if(i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n]))s[e[n]]=t[e[n]]}return s};const at=60;const lt=10;const ct=lt*at;class dt extends f{constructor(t,i){super();this.timeouts=[];this.isScrollable=false;this.audioData=null;this.resizeObserver=null;this.lastContainerWidth=0;this.isDragging=false;this.subscriptions=[];this.unsubscribeOnScroll=[];this.dragStream=null;this.scrollStream=null;this.containerInlinePadding=0;this.onClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=_(i,t.clientX,t.clientY);this.emit("click",s,e)};this.onDblClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=_(i,t.clientX,t.clientY);this.emit("dblclick",s,e)};this.subscriptions=[];this.options=t;const s=this.parentFromOptionsContainer(t.container);this.parent=s;const[e,n]=this.initHtml();s.appendChild(e);this.container=e;this.scrollContainer=n.querySelector(".scroll");this.wrapper=n.querySelector(".wrapper");this.canvasWrapper=n.querySelector(".canvases");this.progressWrapper=n.querySelector(".progress");this.cursor=n.querySelector(".cursor");this.calculateInlinePadding();if(i){n.appendChild(i)}this.initEvents()}parentFromOptionsContainer(t){let i;if(typeof t==="string"){i=document.querySelector(t)}else if(k(t)){i=t}if(!i){throw new Error("Container not found")}return i}initEvents(){this.wrapper.addEventListener("click",this.onClickWrapper);this.wrapper.addEventListener("dblclick",this.onDblClickWrapper);if(this.options.dragToSeek===true||typeof this.options.dragToSeek==="object"){this.initDrag()}this.scrollStream=rt(this.scrollContainer);const t=D((()=>{const{startX:t,endX:i}=this.scrollStream.percentages.value;const{left:s,right:e}=this.scrollStream.bounds.value;this.emit("scroll",t,i,s,e)}),[this.scrollStream.percentages,this.scrollStream.bounds]);this.subscriptions.push(t);if(typeof ResizeObserver==="function"){const t=this.createDelay(100);this.resizeObserver=new ResizeObserver((()=>{t().then((()=>this.onContainerResize())).catch((()=>undefined))}));this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;this.calculateInlinePadding();if(t===this.lastContainerWidth&&this.options.height!=="auto")return;this.lastContainerWidth=t;this.reRender();this.emit("resize")}initDrag(){if(this.dragStream)return;this.dragStream=st(this.wrapper);const t=D((()=>{const t=this.dragStream.signal.value;if(!t)return;const i=this.wrapper.getBoundingClientRect().width;const s=O(t.x/i);if(t.type==="start"){this.isDragging=true;this.emit("dragstart",s)}else if(t.type==="move"){this.emit("drag",s)}else if(t.type==="end"){this.isDragging=false;this.emit("dragend",s)}}),[this.dragStream.signal]);this.subscriptions.push(t)}calculateInlinePadding(){const{paddingLeft:t,paddingRight:i}=getComputedStyle(this.scrollContainer);const s=parseFloat(t)+parseFloat(i);this.containerInlinePadding=Number.isNaN(s)?0:s}initHtml(){const t=document.createElement("div");const i=t.attachShadow({mode:"open"});const s=this.options.cspNonce&&typeof this.options.cspNonce==="string"?this.options.cspNonce.replace(/"/g,""):"";i.innerHTML=`\n <style${s?` nonce="${s}"`:""}>\n :host {\n user-select: none;\n min-width: 1px;\n }\n :host audio {\n display: block;\n width: 100%;\n }\n :host .scroll {\n overflow-x: auto;\n overflow-y: hidden;\n width: 100%;\n position: relative;\n }\n :host .noScrollbar {\n scrollbar-color: transparent;\n scrollbar-width: none;\n }\n :host .noScrollbar::-webkit-scrollbar {\n display: none;\n -webkit-appearance: none;\n }\n :host .wrapper {\n position: relative;\n overflow: visible;\n z-index: 2;\n }\n :host .canvases {\n min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;\n pointer-events: none;\n }\n :host .canvases > div {\n position: relative;\n }\n :host canvas {\n display: block;\n position: absolute;\n top: 0;\n image-rendering: pixelated;\n }\n :host .progress {\n pointer-events: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n overflow: hidden;\n }\n :host .progress > div {\n position: relative;\n }\n :host .cursor {\n pointer-events: none;\n position: absolute;\n z-index: 5;\n top: 0;\n left: 0;\n height: 100%;\n border-radius: 2px;\n }\n </style>\n\n <div class="scroll" part="scroll">\n <div class="wrapper" part="wrapper">\n <div class="canvases" part="canvases"></div>\n <div class="progress" part="progress"></div>\n <div class="cursor" part="cursor"></div>\n </div>\n </div>\n `;return[t,i]}setOptions(t){var i;if(this.options.container!==t.container){const i=this.parentFromOptionsContainer(t.container);i.appendChild(this.container);this.parent=i}if(t.dragToSeek===true||typeof this.options.dragToSeek==="object"){this.initDrag()}else{(i=this.dragStream)===null||i===void 0?void 0:i.cleanup();this.dragStream=null}this.options=t;this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth-this.containerInlinePadding}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:i}=this.scrollContainer;const s=i*t;this.setScroll(s)}destroy(){var t;this.wrapper.removeEventListener("click",this.onClickWrapper);this.wrapper.removeEventListener("dblclick",this.onDblClickWrapper);this.timeouts.forEach((t=>t()));this.timeouts=[];this.subscriptions.forEach((t=>t()));this.container.remove();if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null}(t=this.unsubscribeOnScroll)===null||t===void 0?void 0:t.forEach((t=>t()));this.unsubscribeOnScroll=[];if(this.dragStream){this.dragStream.cleanup();this.dragStream=null}if(this.scrollStream){this.scrollStream.cleanup();this.scrollStream=null}}createDelay(t=10){let i;let s;const e=()=>{if(i){clearTimeout(i);i=undefined}if(s){s();s=undefined}};this.timeouts.push(e);return()=>new Promise(((n,r)=>{e();s=r;i=setTimeout((()=>{i=undefined;s=undefined;n()}),t)}))}getHeight(t,i){var s;const e=((s=this.audioData)===null||s===void 0?void 0:s.numberOfChannels)||1;return B({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:e,defaultHeight:E})}convertColorValues(t,i){return V(t,this.getPixelRatio(),i===null||i===void 0?void 0:i.canvas.height)}getPixelRatio(){return N(window.devicePixelRatio)}renderBarWaveform(t,i,s,e){const{width:n,height:r}=s.canvas;const{halfHeight:o,barWidth:h,barRadius:a,barIndexScale:l,barSpacing:c,barMinHeight:d}=L({width:n,height:r,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()});const u=F({channelData:t,barIndexScale:l,barSpacing:c,barWidth:h,halfHeight:o,vScale:e,canvasHeight:r,barAlign:i.barAlign,barMinHeight:d});s.beginPath();for(const t of u){if(a&&"roundRect"in s){s.roundRect(t.x,t.y,t.width,t.height,a)}else{s.rect(t.x,t.y,t.width,t.height)}}s.fill();s.closePath()}renderLineWaveform(t,i,s,e){const{width:n,height:r}=s.canvas;const o=Q({channelData:t,width:n,height:r,vScale:e});s.beginPath();for(const t of o){if(!t.length)continue;s.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++){const e=t[i];s.lineTo(e.x,e.y)}}s.fill();s.closePath()}renderWaveform(t,i,s){s.fillStyle=this.convertColorValues(i.waveColor,s);if(i.renderFunction){i.renderFunction(t,s);return}const e=J({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});if(U(i)){this.renderBarWaveform(t,i,s,e);return}this.renderLineWaveform(t,i,s,e)}renderSingleCanvas(t,i,s,e,n,r,o){const h=this.getPixelRatio();const a=document.createElement("canvas");a.width=Math.round(s*h);a.height=Math.round(e*h);a.style.width=`${s}px`;a.style.height=`${e}px`;a.style.left=`${Math.round(n)}px`;r.appendChild(a);const l=a.getContext("2d");if(i.renderFunction){l.fillStyle=this.convertColorValues(i.waveColor,l);i.renderFunction(t,l)}else{this.renderWaveform(t,i,l)}if(a.width>0&&a.height>0){const t=a.cloneNode();const s=t.getContext("2d");s.drawImage(a,0,0);s.globalCompositeOperation="source-in";s.fillStyle=this.convertColorValues(i.progressColor,s);s.fillRect(0,0,a.width,a.height);o.appendChild(t)}}renderMultiCanvas(t,i,s,e,n,r){const o=this.getPixelRatio();const{clientWidth:h}=this.scrollContainer;const a=s/o;const l=q({clientWidth:h,totalWidth:a,options:i});let c={};if(l===0)return;const d=s=>{if(s<0||s>=f)return;if(c[s])return;c[s]=true;const o=s*l;let h=Math.min(a-o,l);h=G(h,i);if(h<=0)return;const d=K({channelData:t,offset:o,clampedWidth:h,totalWidth:a});this.renderSingleCanvas(d,i,h,e,o,n,r)};const u=()=>{if(Y(Object.keys(c).length)){n.innerHTML="";r.innerHTML="";c={}}};const f=Math.ceil(a/l);if(!this.isScrollable){for(let t=0;t<f;t++){d(t)}return}const p=Z({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:a,numCanvases:f});p.forEach((t=>d(t)));if(f>1){const t=this.on("scroll",(()=>{const{scrollLeft:t}=this.scrollContainer;u();Z({scrollLeft:t,totalWidth:a,numCanvases:f}).forEach((t=>d(t)))}));this.unsubscribeOnScroll.push(t)}}renderChannel(t,i,s,e){var{overlay:n}=i,r=ht(i,["overlay"]);const o=document.createElement("div");const h=this.getHeight(r.height,r.splitChannels);o.style.height=`${h}px`;if(n&&e>0){o.style.marginTop=`-${h}px`}this.canvasWrapper.style.minHeight=`${h}px`;this.canvasWrapper.appendChild(o);const a=o.cloneNode();this.progressWrapper.appendChild(a);this.renderMultiCanvas(t,r,s,h,o,a)}render(t){return ot(this,void 0,void 0,(function*(){var i;this.timeouts.forEach((t=>t()));this.timeouts=[];this.unsubscribeOnScroll.forEach((t=>t()));this.unsubscribeOnScroll=[];this.canvasWrapper.innerHTML="";this.progressWrapper.innerHTML="";if(this.options.width!=null){this.scrollContainer.style.width=typeof this.options.width==="number"?`${this.options.width}px`:this.options.width}const s=this.getPixelRatio();const e=this.scrollContainer.clientWidth-this.containerInlinePadding;const{scrollWidth:n,isScrollable:r,useParentWidth:o,width:h}=X({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:e,fillParent:this.options.fillParent,pixelRatio:s});this.isScrollable=r;this.wrapper.style.width=o?"100%":`${n}px`;this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden";this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar);this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`;this.cursor.style.width=`${this.options.cursorWidth}px`;this.audioData=t;this.emit("render");if(this.options.splitChannels){for(let s=0;s<t.numberOfChannels;s++){const e=Object.assign(Object.assign({},this.options),(i=this.options.splitChannels)===null||i===void 0?void 0:i[s]);this.renderChannel([t.getChannelData(s)],e,h,s)}}else{const i=[t.getChannelData(0)];if(t.numberOfChannels>1)i.push(t.getChannelData(1));this.renderChannel(i,this.options,h,0)}Promise.resolve().then((()=>this.emit("rendered")))}))}reRender(){this.unsubscribeOnScroll.forEach((t=>t()));this.unsubscribeOnScroll=[];if(!this.audioData)return;const{scrollWidth:t}=this.scrollContainer;const{right:i}=this.progressWrapper.getBoundingClientRect();this.render(this.audioData);if(!this.isScrollable&&this.scrollContainer.scrollLeft){this.scrollContainer.scrollLeft=0}else if(this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:t}=this.progressWrapper.getBoundingClientRect();const s=tt(t-i);this.scrollContainer.scrollLeft+=s}}zoom(t){this.options.minPxPerSec=t;this.reRender()}scrollIntoView(t,i=false){var s;const{scrollLeft:e,scrollWidth:n,clientWidth:r}=this.scrollContainer;const o=t*n;const h=e;const a=e+r;const l=r/2;if(this.isDragging){const t=30;if(o+t>a){this.scrollContainer.scrollLeft+=t}else if(o-t<h){this.scrollContainer.scrollLeft-=t}}else{if(o<h||o>a){this.scrollContainer.scrollLeft=o-(this.options.autoCenter?l:0)}const t=o-e-l;if(i&&this.options.autoCenter&&t>0){const i=(s=this.audioData)===null||s===void 0?void 0:s.duration;if(i===undefined||i<=0){this.scrollContainer.scrollLeft+=t;return}const e=n/i;if(e<=ct){this.scrollContainer.scrollLeft+=Math.min(t,lt)}else{this.scrollContainer.scrollLeft+=t}}}}renderProgress(t,i){if(isNaN(t))return;const s=t*100;this.canvasWrapper.style.clipPath=`polygon(${s}% 0%, 100% 0%, 100% 100%, ${s}% 100%)`;this.progressWrapper.style.width=`${s}%`;this.cursor.style.left=`${s}%`;this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"";if(this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0){this.scrollIntoView(t,i)}}exportImage(t,i,s){return ot(this,void 0,void 0,(function*(){const e=this.canvasWrapper.querySelectorAll("canvas");if(!e.length){throw new Error("No waveform data")}if(s==="dataURL"){const s=Array.from(e).map((s=>s.toDataURL(t,i)));return Promise.resolve(s)}return Promise.all(Array.from(e).map((s=>new Promise(((e,n)=>{s.toBlob((t=>{if(t){e(t)}else{n(new Error("Could not export image"))}}),t,i)})))))}))}}class ut extends f{constructor(){super(...arguments);this.animationFrameId=null;this.isRunning=false}start(){if(this.isRunning)return;this.isRunning=true;const t=()=>{if(!this.isRunning)return;this.emit("tick");this.animationFrameId=requestAnimationFrame(t)};t()}stop(){this.isRunning=false;if(this.animationFrameId!==null){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}}destroy(){this.stop();this.unAll()}}var ft=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};function pt(){const t=globalThis.navigator;if(!(t===null||t===void 0?void 0:t.audioSession))return;try{t.audioSession.type="playback"}catch(t){console.warn("Setting navigator.audioSession.type failed:",t)}}class vt extends f{constructor(t){super();this.bufferNode=null;this.playStartTime=0;this.playbackPosition=0;this._muted=false;this._playbackRate=1;this._duration=undefined;this.buffer=null;this.currentSrc="";this.paused=true;this.crossOrigin=null;this.seeking=false;this.autoplay=false;this.addEventListener=this.on;this.removeEventListener=this.un;this._destroyed=false;pt();this.audioContext=t||new AudioContext;this.gainNode=this.audioContext.createGain();this.gainNode.connect(this.audioContext.destination)}load(){return ft(this,void 0,void 0,(function*(){return}))}remove(){this.destroy()}destroy(){if(this._destroyed)return;this._destroyed=true;this.currentSrc="";if(this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}this.bufferNode.disconnect();this.bufferNode=null}this.gainNode.disconnect();if(typeof this.audioContext.close==="function"){Promise.resolve(this.audioContext.close.call(this.audioContext)).catch((()=>undefined))}this.buffer=null;this.unAll()}get src(){return this.currentSrc}set src(t){this.currentSrc=t;this._duration=undefined;if(!t){this.buffer=null;this.emit("emptied");return}fetch(t).then((i=>{if(i.status>=400){throw new Error(`Failed to fetch ${t}: ${i.status} (${i.statusText})`)}return i.arrayBuffer()})).then((i=>{if(this.currentSrc!==t)return null;return this.audioContext.decodeAudioData(i)})).then((i=>{if(this.currentSrc!==t)return;this.buffer=i;this.emit("loadedmetadata");this.emit("canplay");if(this.autoplay)this.play()})).catch((t=>{console.error("WebAudioPlayer load error:",t)}))}_play(){if(!this.paused)return;this.paused=false;if(this.bufferNode){this.bufferNode.onended=null;this.bufferNode.disconnect()}this.bufferNode=this.audioContext.createBufferSource();if(this.buffer){this.bufferNode.buffer=this.buffer}this.bufferNode.playbackRate.value=this._playbackRate;this.bufferNode.connect(this.gainNode);let t=this.playbackPosition;if(t>=this.duration||t<0){t=0;this.playbackPosition=0}this.bufferNode.start(this.audioContext.currentTime,t);this.playStartTime=this.audioContext.currentTime;this.bufferNode.onended=()=>{if(!this.paused&&this.duration-this.currentTime<.01){this.pause();this.emit("ended")}}}_pause(){this.paused=true;if(this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}}this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return ft(this,void 0,void 0,(function*(){if(!this.paused)return;this._play();this.emit("play")}))}pause(){if(this.paused)return;this._pause();this.emit("pause")}stopAt(t){const i=(t-this.currentTime)/this._playbackRate;const s=this.bufferNode;s===null||s===void 0?void 0:s.stop(this.audioContext.currentTime+i);s===null||s===void 0?void 0:s.addEventListener("ended",(()=>{if(s===this.bufferNode){this.bufferNode=null;this.pause();this.playbackPosition=Math.min(t,this.duration);this.emit("timeupdate")}}),{once:true})}setSinkId(t){return ft(this,void 0,void 0,(function*(){const i=this.audioContext;return i.setSinkId(t)}))}get playbackRate(){return this._playbackRate}set playbackRate(t){const i=!this.paused;if(i)this._pause();this._playbackRate=t;if(i)this._play();if(this.bufferNode){this.bufferNode.playbackRate.value=t}}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){const i=!this.paused;if(i)this._pause();this.playbackPosition=t;if(i)this._play();this.emit("seeking");this.emit("timeupdate")}get duration(){var t,i;return(t=this._duration)!==null&&t!==void 0?t:((i=this.buffer)===null||i===void 0?void 0:i.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t;this.emit("volumechange")}get muted(){return this._muted}set muted(t){if(this._muted===t)return;this._muted=t;if(this._muted){this.gainNode.disconnect()}else{this.gainNode.connect(this.audioContext.destination)}}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const i=this.buffer.numberOfChannels;for(let s=0;s<i;s++){t.push(this.buffer.getChannelData(s))}return t}removeAttribute(t){switch(t){case"src":this.src="";break;case"playbackRate":this.playbackRate=0;break;case"currentTime":this.currentTime=0;break;case"duration":this.duration=0;break;case"volume":this.volume=0;break;case"muted":this.muted=false;break}}}function gt(t){var i,s,e,n,r,o;const h=(i=t===null||t===void 0?void 0:t.currentTime)!==null&&i!==void 0?i:W(0);const a=(s=t===null||t===void 0?void 0:t.duration)!==null&&s!==void 0?s:W(0);const l=(e=t===null||t===void 0?void 0:t.isPlaying)!==null&&e!==void 0?e:W(false);const c=(n=t===null||t===void 0?void 0:t.isSeeking)!==null&&n!==void 0?n:W(false);const d=(r=t===null||t===void 0?void 0:t.volume)!==null&&r!==void 0?r:W(1);const u=(o=t===null||t===void 0?void 0:t.playbackRate)!==null&&o!==void 0?o:W(1);const f=W(null);const p=W(null);const v=W("");const g=W(0);const b=W(0);const m=A((()=>!l.value),[l]);const y=A((()=>f.value!==null),[f]);const x=A((()=>y.value&&a.value>0),[y,a]);const w=A((()=>h.value),[h]);const k=A((()=>a.value>0?h.value/a.value:0),[h,a]);const M={currentTime:h,duration:a,isPlaying:l,isPaused:m,isSeeking:c,volume:d,playbackRate:u,audioBuffer:f,peaks:p,url:v,zoom:g,scrollPosition:b,canPlay:y,isReady:x,progress:w,progressPercent:k};const S={setCurrentTime:t=>{const i=Math.max(0,Math.min(a.value||Infinity,t));h.set(i)},setDuration:t=>{a.set(Math.max(0,t))},setPlaying:t=>{l.set(t)},setSeeking:t=>{c.set(t)},setVolume:t=>{const i=Math.max(0,Math.min(1,t));d.set(i)},setPlaybackRate:t=>{const i=Math.max(.1,Math.min(16,t));u.set(i)},setAudioBuffer:t=>{f.set(t);if(t){a.set(t.duration)}},setPeaks:t=>{p.set(t)},setUrl:t=>{v.set(t)},setZoom:t=>{g.set(Math.max(0,t))},setScrollPosition:t=>{b.set(Math.max(0,t))}};return{state:M,actions:S}}var bt=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(o,h)}a((e=e.apply(t,i||[])).next())}))};const mt={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:true,interact:true,dragToSeek:false,autoScroll:true,autoCenter:true,sampleRate:8e3};class yt extends j{static create(t){return new yt(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new vt:undefined);super({media:i,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate});this.plugins=[];this.decodedData=null;this.stopAtPosition=null;this.subscriptions=[];this.mediaSubscriptions=[];this.abortController=null;this._isDestroyed=false;this._loadVersion=0;this.options=Object.assign({},mt,t);const{state:s,actions:e}=gt({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=s;this.wavesurferActions=e;this.timer=new ut;const n=i?undefined:this.getMediaElement();this.renderer=new dt(this.options,n);this.initPlayerEvents();this.initRendererEvents();this.initTimerEvents();this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then((()=>{this.emit("init");const{peaks:t,duration:i}=this.options;if(r||t&&i){this.load(r,t,i).catch((()=>{}))}}))}updateProgress(t=this.getCurrentTime()){this.renderer.renderProgress(t/this.getDuration(),this.isPlaying());return t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",(()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t);this.emit("audioprocess",t);if(this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition){const t=this.stopAtPosition;this.pause();this.setTime(t)}}})))}initPlayerEvents(){if(this.isPlaying()){this.emit("play");this.timer.start()}this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",(()=>{const t=this.updateProgress();this.emit("timeupdate",t)})),this.onMediaEvent("play",(()=>{this.emit("play");this.timer.start()})),this.onMediaEvent("pause",(()=>{this.emit("pause");this.timer.stop();this.stopAtPosition=null})),this.onMediaEvent("emptied",(()=>{this.timer.stop();this.stopAtPosition=null})),this.onMediaEvent("ended",(()=>{this.emit("timeupdate",this.getDuration());this.emit("finish");this.stopAtPosition=null})),this.onMediaEvent("seeking",(()=>{this.emit("seeking",this.getCurrentTime())})),this.onMediaEvent("error",(()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error"));this.stopAtPosition=null})))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",((t,i)=>{if(this.options.interact){this.seekTo(t);this.emit("interaction",t*this.getDuration());this.emit("click",t,i)}})),this.renderer.on("dblclick",((t,i)=>{this.emit("dblclick",t,i)})),this.renderer.on("scroll",((t,i,s,e)=>{const n=this.getDuration();this.emit("scroll",t*n,i*n,s,e)})),this.renderer.on("render",(()=>{this.emit("redraw")})),this.renderer.on("rendered",(()=>{this.emit("redrawcomplete")})),this.renderer.on("dragstart",(t=>{this.emit("dragstart",t)})),this.renderer.on("dragend",(t=>{this.emit("dragend",t)})),this.renderer.on("resize",(()=>{this.emit("resize")})));{let t;const i=this.renderer.on("drag",(i=>{var s;if(!this.options.interact)return;this.renderer.renderProgress(i);clearTimeout(t);let e=0;const n=this.options.dragToSeek;if(this.isPlaying()){e=0}else if(n===true){e=200}else if(n&&typeof n==="object"){e=(s=n.debounceTime)!==null&&s!==void 0?s:200}t=setTimeout((()=>{this.seekTo(i)}),e);this.emit("interaction",i*this.getDuration());this.emit("drag",i)}));this.subscriptions.push((()=>{clearTimeout(t);i()}))}}initPlugins(){var t;if(!((t=this.options.plugins)===null||t===void 0?void 0:t.length))return;this.options.plugins.forEach((t=>{this.registerPlugin(t)}))}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach((t=>t()));this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t);if(t.duration&&!t.peaks){this.decodedData=y.createBuffer(this.exportPeaks(),t.duration)}if(t.peaks&&t.duration){this.decodedData=y.createBuffer(t.peaks,t.duration)}this.renderer.setOptions(this.options);if(t.audioRate){this.setPlaybackRate(t.audioRate)}if(t.mediaControls!=null){this.getMediaElement().controls=t.mediaControls}}registerPlugin(t){if(this.plugins.includes(t)){return t}t._init(this);this.plugins.push(t);const i=t.once("destroy",(()=>{this.plugins=this.plugins.filter((i=>i!==t));this.subscriptions=this.subscriptions.filter((t=>t!==i))}));this.subscriptions.push(i);return t}unregisterPlugin(t){this.plugins=this.plugins.filter((i=>i!==t));t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const i=t/this.getDuration();this.renderer.setScrollPercentage(i)}getActivePlugins(){return this.plugins}loadAudio(t,i,s,e){return bt(this,void 0,void 0,(function*(){var n;const r=++this._loadVersion;this._isDestroyed=false;this.emit("load",t);if(!this.options.media&&this.isPlaying())this.pause();this.decodedData=null;this.stopAtPosition=null;(n=this.abortController)===null||n===void 0?void 0:n.abort();this.abortController=null;if(!i&&!s){const s=this.options.fetchParams||{};if(window.AbortController&&!s.signal){this.abortController=new AbortController;s.signal=this.abortController.signal}const e=t=>this.emit("loading",t);i=yield R.fetchBlob(t,e,s);if(this._isDestroyed||r!==this._loadVersion)return;const n=this.options.blobMimeType;if(n){i=new Blob([i],{type:n})}}if(this._isDestroyed||r!==this._loadVersion)return;this.setSrc(t,i);const o=yield new Promise((t=>{const i=e||this.getDuration();if(i){t(i)}else{this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",(()=>t(this.getDuration())),{once:true}))}}));if(this._isDestroyed||r!==this._loadVersion)return;if(!t&&!i){const t=this.getMediaElement();if(t instanceof vt){t.duration=o}}if(s){this.decodedData=y.createBuffer(s,o||0)}else if(i){const t=yield i.arrayBuffer();if(this._isDestroyed||r!==this._loadVersion)return;this.decodedData=yield y.decode(t,this.options.sampleRate)}if(this._isDestroyed||r!==this._loadVersion)return;if(this.decodedData){this.emit("decode",this.getDuration());this.renderer.render(this.decodedData)}this.emit("ready",this.getDuration())}))}load(t,i,s){return bt(this,void 0,void 0,(function*(){try{return yield this.loadAudio(t,undefined,i,s)}catch(t){this.emit("error",t);throw t}}))}loadBlob(t,i,s){return bt(this,void 0,void 0,(function*(){try{return yield this.loadAudio("",t,i,s)}catch(t){this.emit("error",t);throw t}}))}zoom(t){if(!this.decodedData){throw new Error("No audio loaded")}this.renderer.zoom(t);this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:i=8e3,precision:s=1e4}={}){if(!this.decodedData){throw new Error("The audio has not been decoded yet")}const e=Math.min(t,this.decodedData.numberOfChannels);const n=[];for(let t=0;t<e;t++){const e=this.decodedData.getChannelData(t);const r=[];const o=e.length/i;for(let t=0;t<i;t++){const i=e.slice(Math.floor(t*o),Math.ceil((t+1)*o));let n=0;for(let t=0;t<i.length;t++){const s=i[t];if(Math.abs(s)>Math.abs(n))n=s}r.push(Math.round(n*s)/s)}n.push(r)}return n}getDuration(){let t=super.getDuration()||0;if((t===0||t===Infinity)&&this.decodedData){t=this.decodedData.duration}return t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null;super.setTime(t);this.updateProgress(t);this.emit("timeupdate",t)}seekTo(t){const i=this.getDuration()*t;this.setTime(i)}play(t,i){const s=Object.create(null,{play:{get:()=>super.play}});return bt(this,void 0,void 0,(function*(){if(t!=null){this.setTime(t)}const e=yield s.play.call(this);if(i!=null){if(this.media instanceof vt){this.media.stopAt(i)}else{this.stopAtPosition=i}}return e}))}playPause(){return bt(this,void 0,void 0,(function*(){return this.isPlaying()?this.pause():this.play()}))}stop(){this.pause();this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents();super.setMediaElement(t);this.initPlayerEvents()}exportImage(){return bt(this,arguments,void 0,(function*(t="image/png",i=1,s="dataURL"){return this.renderer.exportImage(t,i,s)}))}destroy(){var t;this._isDestroyed=true;this.emit("destroy");(t=this.abortController)===null||t===void 0?void 0:t.abort();this.plugins.forEach((t=>t.destroy()));this.subscriptions.forEach((t=>t()));this.unsubscribePlayerEvents();this.timer.destroy();this.renderer.destroy();super.destroy()}}yt.BasePlugin=p;yt.dom=M;function xt(t,i,s,e){return new(s||(s=Promise))((function(n,r){function o(t){try{a(e.next(t))}catch(t){r(t)}}function h(t){try{a(e.throw(t))}catch(t){r(t)}}function a(t){var i;t.done?n(t.value):(i=t.value,i instanceof s?i:new s((function(t){t(i)}))).then(o,h)}a((e=e.apply(t,i||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class wt{constructor(){this.listeners={}}on(t,i,s){if(this.listeners[t]||(this.listeners[t]=new Set),null==s?void 0:s.once){const s=(...e)=>{this.un(t,s),i(...e)};return this.listeners[t].add(s),()=>this.un(t,s)}return this.listeners[t].add(i),()=>this.un(t,i)}un(t,i){var s;null===(s=this.listeners[t])||void 0===s||s.delete(i)}once(t,i){return this.on(t,i,{once:!0})}unAll(){this.listeners={}}emit(t,...i){this.listeners[t]&&this.listeners[t].forEach((t=>t(...i)))}}class kt extends wt{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((t=>t())),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}class Mt extends wt{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop(),this.unAll()}}const St=100,Ct=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class Pt extends kt{constructor(t){var i,s,e,n,r,o;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:null!==(i=t.audioBitsPerSecond)&&void 0!==i?i:128e3,scrollingWaveform:null!==(s=t.scrollingWaveform)&&void 0!==s&&s,scrollingWaveformWindow:null!==(e=t.scrollingWaveformWindow)&&void 0!==e?e:5,continuousWaveform:null!==(n=t.continuousWaveform)&&void 0!==n&&n,renderRecordedAudio:null===(r=t.renderRecordedAudio)||void 0===r||r,mediaRecorderTimeslice:null!==(o=t.mediaRecorderTimeslice)&&void 0!==o?o:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.micStream=null,this.recordedBlobUrl=null,this.timer=new Mt,this.subscriptions.push(this.timer.on("tick",(()=>{const t=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+t,this.emit("record-progress",this.duration)})))}static create(t){return new Pt(t||{})}renderMicStream(t){var i;const s=new AudioContext,e=s.createMediaStreamSource(t),n=s.createAnalyser();e.connect(n),(this.options.continuousWaveform||this.options.scrollingWaveform)&&(n.fftSize=32);const r=n.frequencyBinCount,o=new Float32Array(r);let h=0;this.wavesurfer&&(null!==(i=this.originalOptions)&&void 0!==i||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0,this.wavesurfer.options.normalize=!0,this.wavesurfer.options.maxPeak=1));const a=setInterval((()=>{var t,i,s,e;if(!this.isWaveformPaused){if(n.getFloatTimeDomainData(o),this.options.scrollingWaveform){const t=Math.floor((this.options.scrollingWaveformWindow||0)*St);let i=0;for(let t=0;t<r;t++){const s=Math.abs(o[t]);s>i&&(i=s)}this.dataWindow||(this.dataWindow=new Float32Array(t));const s=new Float32Array(t);if(this.dataWindow&&this.dataWindow.length>0){const i=t-1,e=this.dataWindow.slice(-i);s.set(e,0)}s[t-1]=i,this.dataWindow=s}else if(this.options.continuousWaveform){if(!this.dataWindow){const s=this.options.continuousWaveformDuration?Math.round(this.options.continuousWaveformDuration*St):(null!==(i=null===(t=this.wavesurfer)||void 0===t?void 0:t.getWidth())&&void 0!==i?i:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(s)}let s=0;for(let t=0;t<r;t++){const i=Math.abs(o[t]);i>s&&(s=i)}if(h+1>this.dataWindow.length){const t=new Float32Array(2*this.dataWindow.length);t.set(this.dataWindow,0),this.dataWindow=t}this.dataWindow[h]=s,h++}else this.dataWindow=o;if(this.wavesurfer){const t=(null!==(e=null===(s=this.dataWindow)||void 0===s?void 0:s.length)&&void 0!==e?e:0)/St;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:t).then((()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))})).catch((t=>{console.error("Error rendering real-time recording data:",t)}))}}}),10);return{onDestroy:()=>{clearInterval(a),null==e||e.disconnect(),null==s||s.close()},onEnd:()=>{this.isWaveformPaused=!0,this.stopMic()}}}startMic(t){return xt(this,void 0,void 0,(function*(){let i;this.micStream&&this.stopMic();try{i=yield navigator.mediaDevices.getUserMedia({audio:null==t||t})}catch(i){throw new Error("Error accessing the microphone: "+i.message)}const s=this.renderMicStream(i);return this.micStream=s,this.unsubscribeDestroy=this.once("destroy",s.onDestroy),this.unsubscribeRecordEnd=this.once("record-end",s.onEnd),this.stream=i,i}))}stopMic(){var t,i,s;null===(t=this.micStream)||void 0===t||t.onDestroy(),null===(i=this.unsubscribeDestroy)||void 0===i||i.call(this),null===(s=this.unsubscribeRecordEnd)||void 0===s||s.call(this),this.micStream=null,this.unsubscribeDestroy=void 0,this.unsubscribeRecordEnd=void 0,this.stream&&(this.stream.getTracks().forEach((t=>t.stop())),this.stream=null,this.mediaRecorder=null)}startRecording(t){return xt(this,void 0,void 0,(function*(){const i=this.stream||(yield this.startMic(t));this.dataWindow=null;const s=this.mediaRecorder||new MediaRecorder(i,{mimeType:this.options.mimeType||Ct.find((t=>MediaRecorder.isTypeSupported(t))),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=s,this.stopRecording();const e=[];s.ondataavailable=t=>{t.data.size>0&&e.push(t.data),this.emit("record-data-available",t.data)};const n=t=>{var i;const n=new Blob(e,{type:s.mimeType});this.emit(t,n),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),this.recordedBlobUrl&&URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=URL.createObjectURL(n),null===(i=this.wavesurfer)||void 0===i||i.load(this.recordedBlobUrl))};s.onpause=()=>n("record-pause"),s.onstop=()=>n("record-end"),s.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")}))}getDuration(){return this.duration}isRecording(){var t;return"recording"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isPaused(){var t;return"paused"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isActive(){var t;return"inactive"!==(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}stopRecording(){var t;this.isActive()&&(null===(t=this.mediaRecorder)||void 0===t||t.stop(),this.timer.stop())}pauseRecording(){var t,i;this.isRecording()&&(this.isWaveformPaused=!0,null===(t=this.mediaRecorder)||void 0===t||t.requestData(),null===(i=this.mediaRecorder)||void 0===i||i.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,null===(t=this.mediaRecorder)||void 0===t||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return xt(this,void 0,void 0,(function*(){return navigator.mediaDevices.enumerateDevices().then((t=>t.filter((t=>"audioinput"===t.kind))))}))}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic(),this.recordedBlobUrl&&(URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=null)}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}const Rt=40;const Wt=class{constructor(s){t(this,s);this.recordingProgress=i(this,"recordingProgress",7);this.recordingError=i(this,"recordingError",7);this.wavesurfer=null;this.recordPlugin=null;this.waveformContainer=null;this.loadAbortController=null;this.currentLoadingUrl=null;this.initializationInterval=null;this.pauseAudioHandler=()=>{if(!this.wavesurfer)return;this.isPlaying=false;this.wavesurfer.pause();this.audioDuration=n(Math.round(this.wavesurfer.getDuration()))};this.playAudioHandler=()=>{if(!this.wavesurfer){const t=this.initWaveSurfer();if(t){this.wavesurfer.once("ready",(()=>{this.isPlaying=true;this.wavesurfer.play()}))}return}this.isPlaying=true;this.wavesurfer.play()};this.audioUrl=undefined;this.audioWaveColor="#C5C5C5";this.audioProgressColor="#4A76FD";this.textColor="#4A76FD";this.isSelf=false;this.borderRadius="";this.bgColor="";this.time="";this.isRead=false;this.isDelivered=false;this.showFooter=false;this.messageId="";this.timeColor="";this.reactions={};this.messageType=undefined;this.liveRecord=false;this.isPlaying=false;this.audioDuration="0:00";this.currentAudioId=null;this.waveformContainerReady=false;this.initializationAttempts=0}componentWillLoad(){if(typeof yt!=="function"){console.error("WaveSurfer is not available as a function. Import may be failing.")}}componentDidLoad(){if(this.liveRecord){void this.startLiveRecording();return}if(this.initializationInterval){clearInterval(this.initializationInterval)}this.initializationInterval=setInterval((()=>{this.initializationAttempts++;if(this.waveformContainer&&this.audioUrl){this.initWaveSurfer();if(this.wavesurfer){clearInterval(this.initializationInterval)}}if(this.initializationAttempts>=10){clearInterval(this.initializationInterval)}}),500)}resolveWaveColor(){const t=(this.audioProgressColor||this.audioWaveColor||"").trim();if(t&&!t.startsWith("var("))return t;const i=getComputedStyle(this.el).getPropertyValue("--brand").trim();return i||"#2563eb"}ensureRecordWaveSurfer(){var t;if(!((t=this.waveformContainer)===null||t===void 0?void 0:t.isConnected))return false;if(this.wavesurfer&&this.recordPlugin)return true;if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null;this.recordPlugin=null}const i=Math.max(this.waveformContainer.clientWidth||0,this.el.clientWidth||0,160);const s=Math.max(this.waveformContainer.clientHeight||0,Rt);const e=this.resolveWaveColor();this.wavesurfer=yt.create({container:this.waveformContainer,waveColor:e,progressColor:e,height:s,width:i,barWidth:4,barGap:2,barRadius:3,barHeight:2.5,barMinHeight:3,normalize:true,interact:false,cursorWidth:0});this.recordPlugin=this.wavesurfer.registerPlugin(Pt.create({scrollingWaveform:true,renderRecordedAudio:false}));this.recordPlugin.on("record-progress",(t=>{this.recordingProgress.emit(t);this.audioDuration=n(Math.round(t/1e3))}));return true}async startLiveRecording(){var t;try{for(let i=0;i<20;i++){if(((t=this.waveformContainer)===null||t===void 0?void 0:t.isConnected)&&(this.waveformContainer.clientWidth>0||this.el.clientWidth>0)){break}await new Promise((t=>requestAnimationFrame((()=>t(null)))))}if(!this.ensureRecordWaveSurfer()){this.recordingError.emit("Waveform not ready");return false}await this.recordPlugin.startRecording();requestAnimationFrame((()=>{var t,i;const s=((t=this.waveformContainer)===null||t===void 0?void 0:t.clientWidth)||this.el.clientWidth;const e=Math.max(((i=this.waveformContainer)===null||i===void 0?void 0:i.clientHeight)||0,Rt);if(s&&this.wavesurfer){try{this.wavesurfer.setOptions({width:s,height:e})}catch(t){}}}));return true}catch(t){console.error(t);this.recordingError.emit((t===null||t===void 0?void 0:t.message)||"Microphone access denied");return false}}async pauseLiveRecording(){var t;(t=this.recordPlugin)===null||t===void 0?void 0:t.pauseRecording()}async resumeLiveRecording(){var t;(t=this.recordPlugin)===null||t===void 0?void 0:t.resumeRecording()}async stopLiveRecording(){if(!this.recordPlugin)return null;if(!this.recordPlugin.isRecording()&&!this.recordPlugin.isPaused()){this.cleanupRecord();return null}return new Promise((t=>{const i=i=>{this.cleanupRecord();t(i)};this.recordPlugin.once("record-end",(t=>i(t||null)));try{this.recordPlugin.stopRecording()}catch(t){i(null)}}))}async cancelLiveRecording(){var t,i,s,e;try{if(((i=(t=this.recordPlugin)===null||t===void 0?void 0:t.isRecording)===null||i===void 0?void 0:i.call(t))||((e=(s=this.recordPlugin)===null||s===void 0?void 0:s.isPaused)===null||e===void 0?void 0:e.call(s))){this.recordPlugin.stopRecording()}}catch(t){}this.cleanupRecord()}cleanupRecord(){var t,i;try{(i=(t=this.recordPlugin)===null||t===void 0?void 0:t.stopMic)===null||i===void 0?void 0:i.call(t)}catch(t){}if(this.wavesurfer){try{this.wavesurfer.destroy()}catch(t){}}this.wavesurfer=null;this.recordPlugin=null}initWaveSurfer(){if(!this.waveformContainer){console.error("Waveform container reference is missing");return false}if(!this.waveformContainer.isConnected){console.error("Waveform container is not connected to DOM");return false}if(!this.audioUrl){console.error("Audio URL is missing");return false}try{this.abortCurrentLoad();if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null}this.loadAbortController=new AbortController;this.currentLoadingUrl=this.audioUrl;this.wavesurfer=yt.create({container:this.waveformContainer,waveColor:this.isSelf?"#000000":this.audioWaveColor,progressColor:this.audioProgressColor,height:40,barHeight:1,barWidth:4,barRadius:3,barGap:4,normalize:true,sampleRate:6e4,fetchParams:{signal:this.loadAbortController.signal}});if(!this.wavesurfer){console.error("Failed to create WaveSurfer instance");return false}this.wavesurfer.load(this.audioUrl);this.wavesurfer.on("ready",(()=>{if(this.currentLoadingUrl===this.audioUrl){const t=this.wavesurfer.getDuration();const i=n(Math.round(t));this.audioDuration=i}}));this.wavesurfer.on("audioprocess",(()=>{const t=Math.max(0,this.wavesurfer.getDuration()-this.wavesurfer.getCurrentTime());this.audioDuration=n(Math.round(t))}));this.wavesurfer.on("finish",(()=>{this.isPlaying=false;this.wavesurfer.seekTo(0);this.audioDuration=n(Math.round(this.wavesurfer.getDuration()))}));this.wavesurfer.on("error",(t=>{if(t.name!=="AbortError"){console.error("WaveSurfer error:",t)}}));return true}catch(t){console.error("Error initializing WaveSurfer:",t);return false}}abortCurrentLoad(){if(this.loadAbortController){this.loadAbortController.abort();this.loadAbortController=null}this.currentLoadingUrl=null}disconnectedCallback(){this.abortCurrentLoad();this.cleanupRecord();if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null}this.isPlaying=false;if(this.initializationInterval){clearInterval(this.initializationInterval)}}chatChanged(t,i){if(t!==i){if(this.wavesurfer&&this.isPlaying){this.wavesurfer.pause();this.isPlaying=false}this.audioDuration="0:00";setTimeout((()=>{if(this.waveformContainer&&t){this.initWaveSurfer()}}),100)}}render(){const t=this.liveRecord;return s("div",{key:"9e4dfb7827f9ee6f3c34218128201ee2ce3b9910",style:{background:t?"transparent":this.bgColor||(this.isSelf?"var(--bg-outgoing-message)":"var(--bg-incoming-message)"),borderRadius:t?"0":this.borderRadius||"7.5px",color:this.textColor||"inherit",padding:t?"0":"10px",width:t?"100%":"336px",maxWidth:"100%",boxSizing:"border-box"}},s("div",{key:"a10a192919ca0ee6c4d7b5dfff2571600067fa24",style:{display:"flex",alignItems:"center",gap:t?"0":"10px",width:"100%"}},t?null:s("button",{type:"button","aria-label":this.isPlaying?"Pause":"Play",style:{border:"none",background:"transparent",cursor:"pointer",fontSize:"18px",color:"inherit"},onClick:()=>this.isPlaying?this.pauseAudioHandler():this.playAudioHandler()},this.isPlaying?"❚❚":"▶"),s("div",{key:"6e5505cd0ff554633ea9471ef9c51044d70e6173",class:"wave-host",ref:t=>{this.waveformContainer=t},style:{flex:"1",height:t?`${Rt}px`:"40px",minHeight:t?`${Rt}px`:"40px",minWidth:"0"}})),t?null:s("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"10px",marginTop:"4px"}},s("span",null,this.audioDuration),this.showFooter?s("span",{style:{color:this.timeColor}},this.time?(()=>{try{const t=new Date(Number(this.time));if(Number.isNaN(t.getTime()))return this.time;return new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit",hour12:true}).format(t)}catch(t){return this.time}})():"",this.isSelf?this.isRead?" ✓✓":this.isDelivered?" ✓✓":" ✓":""):null))}get el(){return e(this)}static get watchers(){return{audioUrl:["chatChanged"]}}};Wt.style=":host {\n display: block;\n width: 100%;\n height: 100%;\n min-width: 0;\n box-sizing: border-box;\n }\n .wave-host {\n width: 100%;\n height: 100%;\n min-width: 0;\n /* Stencil styles: literal 40px — keep in sync with LIVE_RECORD_WAVE_HEIGHT_PX */\n min-height: 40px;\n }";const At=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.openPreview=t=>{var i,s;(i=t===null||t===void 0?void 0:t.preventDefault)===null||i===void 0?void 0:i.call(t);(s=t===null||t===void 0?void 0:t.stopPropagation)===null||s===void 0?void 0:s.call(t);if(!this.href)return;if(this.isPdf()){this.showPdfPreview=true;return}window.open(this.href,"_blank","noopener,noreferrer")};this.closePreview=()=>{this.showPdfPreview=false};this.bgColor=undefined;this.borderRadius="6px";this.padding="10px";this.docName=undefined;this.width=undefined;this.height=undefined;this.documentNameBg=undefined;this.documentNamePadding=undefined;this.time=undefined;this.href=undefined;this.fileName=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.deliveryStatus=undefined;this.docType="";this.textColor=undefined;this.message=undefined;this.mentionedUsers=[];this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.showPdfPreview=false}truncateDocName(t){const i=t.lastIndexOf(".");const s=i!==-1?t.slice(0,i):t;const e=i!==-1?t.slice(i):"";const n=40-e.length;if(s.length<=n){return{firstLine:s.slice(0,Math.min(20,s.length)),secondLine:`${s.slice(20)}${e}`}}const r=s.slice(0,n-3)+"...";return{firstLine:r.slice(0,20),secondLine:`${r.slice(20)}${e}`}}isPdf(){const t=(this.docType||"").toLowerCase();const i=(this.docName||this.fileName||"").toLowerCase();return t.includes("pdf")||i.endsWith(".pdf")}iconSrc(){const t=(this.docType||"").toLowerCase();const i=(this.docName||this.fileName||"").toLowerCase();if(t.includes("pdf")||i.endsWith(".pdf"))return h;if(t.includes("spreadsheet")||t.includes("excel")||/\.xlsx?$/.test(i)||i.endsWith(".csv"))return a;if(t.includes("rtf")||i.endsWith(".rtf"))return l;if(t.includes("text/plain")||i.endsWith(".txt"))return c;return h}render(){const t=this.truncateDocName(this.docName||"Document");const i=(this.docName||this.fileName||"").trim();const e=String(this.message||"").trim();const n=(()=>{if(!e||!i)return false;if(e.localeCompare(i,undefined,{sensitivity:"accent"})===0)return true;const t=t=>(t.split(/[/\\]/).pop()||t).trim();return t(e).localeCompare(t(i),undefined,{sensitivity:"accent"})===0})();const h=e&&!e.includes("AttachmentMessage:")&&!n;const a=this.isPdf();return s("message-bubble",{isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,deliveryStatus:this.deliveryStatus,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor||"var(--bg-secondary)",borderRadius:this.borderRadius||"6px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{class:"doc-container",style:{backgroundColor:this.documentNameBg||"var(--bg-tertiary)",width:this.width||"auto"}},s("div",{class:"document-name",style:{padding:this.documentNamePadding||"5px 10px 5px 0"},onClick:this.openPreview,role:"button",tabIndex:0,onKeyDown:t=>{if(t.key==="Enter"||t.key===" ")this.openPreview(t)}},s("span",{class:"attachment-icon"},s("img",{src:this.iconSrc(),alt:""})),s("span",null,t.firstLine,s("br",null),t.secondLine)),s("div",{class:"doc-actions"},a&&this.href?s("button",{class:"preview-btn",type:"button",onClick:this.openPreview,"aria-label":"Preview PDF"},"View"):null,s("a",{class:"download-btn",href:this.href,download:this.fileName,target:"_blank",rel:"noopener noreferrer","aria-label":"Download"},s("img",{src:d,alt:""})))),h?s("div",{style:{fontSize:"8px",color:this.textColor,marginTop:"4px"}},r(this.message,this.mentionedUsers,(t=>o(this.tagUserClick,t)),!!this.isSelf)):null,this.showPdfPreview&&this.href?s("div",{class:"pdf-lightbox",onClick:this.closePreview},s("div",{class:"pdf-lightbox-bar",onClick:t=>t.stopPropagation()},s("span",{class:"pdf-lightbox-title"},this.docName||this.fileName||"PDF"),s("div",{style:{display:"flex",gap:"8px"}},s("a",{href:this.href,download:this.fileName||this.docName,target:"_blank",rel:"noopener noreferrer",style:{color:"#fff",fontSize:"12px",fontWeight:"600",textDecoration:"none",padding:"6px 12px",background:"rgba(255,255,255,0.15)",borderRadius:"8px"}},"Download"),s("button",{type:"button",onClick:this.closePreview},"Close"))),s("iframe",{src:`${this.href}#toolbar=1`,title:this.docName||"PDF preview",onClick:t=>t.stopPropagation()})):null)}};At.style=":host { display: block; }\n .doc-container {\n display: flex; align-items: center; justify-content: space-between; gap: 8px;\n border-radius: 8px; padding: 4px 8px;\n }\n .document-name {\n display: flex; align-items: center; gap: 8px; word-break: break-word;\n font-size: 12px; line-height: 1.35; min-width: 0; cursor: pointer;\n }\n .attachment-icon { display: flex; flex-shrink: 0; width: 24px; height: 30px; align-items: center; justify-content: center; }\n .attachment-icon img { width: 24px; height: 24px; object-fit: contain; display: block; }\n .doc-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }\n .download-btn, .preview-btn {\n display: flex; align-items: center; justify-content: center;\n flex-shrink: 0; line-height: 0; border: none; background: transparent; cursor: pointer; padding: 0;\n text-decoration: none; color: inherit; font: inherit;\n }\n .download-btn img, .preview-btn img {\n width: 28px; height: 28px; display: block;\n filter: var(--svg-icon-filter);\n }\n .preview-btn {\n font-size: 10px; font-weight: 700; letter-spacing: 0.04em;\n color: var(--brand, #2563eb); padding: 4px 6px; border-radius: 6px;\n background: color-mix(in srgb, var(--brand, #2563eb) 12%, transparent);\n }\n .pdf-lightbox {\n position: fixed; inset: 0; z-index: 9999;\n background: rgba(15, 23, 42, 0.72);\n display: flex; flex-direction: column;\n padding: 12px; box-sizing: border-box;\n }\n .pdf-lightbox-bar {\n display: flex; align-items: center; justify-content: space-between;\n gap: 12px; padding: 8px 4px 12px; color: #fff; flex-shrink: 0;\n }\n .pdf-lightbox-title {\n font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;\n }\n .pdf-lightbox-bar button {\n border: none; background: rgba(255,255,255,0.15); color: #fff;\n border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 12px; font-weight: 600;\n }\n .pdf-lightbox iframe {\n flex: 1; width: 100%; min-height: 0; border: 0; border-radius: 10px; background: #525659;\n }";const Dt=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.openGallery=t=>{var i;(i=this.onImageClick)===null||i===void 0?void 0:i.call(this,t);this.galleryOpen=true};this.downloadPreview=t=>{t.stopPropagation();const i=this.downloadUrl||this.imageSrc;if(!i)return;void u(i,this.downloadFileName,this.mimeType)};this.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.imageSrc=undefined;this.downloadUrl=undefined;this.downloadFileName=undefined;this.mimeType=undefined;this.message=undefined;this.height="220px";this.width="250px";this.time=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.deliveryStatus=undefined;this.textColor=undefined;this.allAttachments=undefined;this.isMediaGalleryOpen=undefined;this.onImageClick=undefined;this.mentionedUsers=[];this.totalMedia=0;this.mediaType=undefined;this.loadingMediaGallery=undefined;this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.galleryOpen=false}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("div",{key:"a5f207c46152f6985e004c890ae359fb806289d2"},s("message-bubble",{key:"7ac2761da95a06ef5081dcad7dbd665bdcbe911f",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,deliveryStatus:this.deliveryStatus,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor,borderRadius:this.borderRadius||"10px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"df99c21dcb4672c6ef9b8e0288d22e761dde6143",class:"image-container",style:{width:this.width||"250px",height:this.height||"220px",borderRadius:this.borderRadius},onClick:this.openGallery},s("img",{key:"bd79e700108db22923c5084c5c78ff60cfbac858",src:this.imageSrc,alt:"image"}),this.totalMedia>0?s("span",{class:"mediaCount"}," + ",this.totalMedia):null),t?s("div",{style:{fontSize:"14px",color:this.textColor,marginTop:"4px"}},r(this.message,this.mentionedUsers,(t=>o(this.tagUserClick,t)),!!this.isSelf)):null),this.galleryOpen?s("div",{class:"gallery-overlay",onClick:()=>this.galleryOpen=false},s("div",{class:"gallery-bar",onClick:t=>t.stopPropagation()},s("button",{type:"button",class:"gallery-action","aria-label":"Download",style:{["--download-icon"]:`url("${d}")`},onClick:t=>this.downloadPreview(t)},s("span",{class:"gallery-download-mask","aria-hidden":"true"})),s("button",{type:"button",class:"gallery-action","aria-label":"Close",onClick:()=>this.galleryOpen=false},s("span",{class:"gallery-close-icon"},"×"))),s("div",{class:"gallery-stage"},s("img",{src:this.imageSrc,alt:"full",onClick:t=>t.stopPropagation()}))):null)}};Dt.style=":host { display: block; font-family: var(--font-primary); }\n .image-container { cursor: pointer; overflow: hidden; position: relative; }\n .image-container img { width: var(--w-full); height: var(--h-full); object-fit: cover; display: block; }\n .mediaCount {\n position: absolute; right: var(--space-8); bottom: var(--space-8);\n background: var(--overlay); color: var(--text-on-brand);\n padding: var(--gap-2) var(--gap-6); border-radius: var(--rounded-8); font-size: var(--text-12);\n }\n .gallery-overlay {\n position: fixed; inset: 0; background: var(--overlay); z-index: 9999;\n display: flex; flex-direction: column;\n }\n .gallery-bar {\n display: flex; justify-content: flex-end; align-items: center; gap: var(--space-8);\n padding: var(--space-8) var(--space-12); flex-shrink: 0;\n }\n .gallery-bar .gallery-action {\n display: flex; align-items: center; justify-content: center;\n border: none; background: transparent; cursor: pointer; padding: 4px;\n color: var(--text-on-brand); line-height: 0;\n width: 28px; height: 28px;\n }\n .gallery-bar .gallery-download-mask {\n width: 20px; height: 20px; display: block;\n background-color: currentColor;\n -webkit-mask: var(--download-icon) center / contain no-repeat;\n mask: var(--download-icon) center / contain no-repeat;\n }\n .gallery-bar .gallery-close-icon {\n font-size: 20px; line-height: 1;\n }\n .gallery-stage {\n flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0;\n padding: 0 var(--space-16) var(--space-16);\n }\n .gallery-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }";const Ht=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.playVideo=()=>{const t=this.videoEl();if(!t)return;t.play();this.isPlaying=true};this.pauseVideo=()=>{const t=this.videoEl();if(!t)return;t.pause();this.isPlaying=false};this.toggle=()=>this.isPlaying?this.pauseVideo():this.playVideo();this.fullscreen=()=>{var t;const i=this.videoEl();(t=i===null||i===void 0?void 0:i.requestFullscreen)===null||t===void 0?void 0:t.call(i)};this.downloadVideo=t=>{t.preventDefault();t.stopPropagation();const i=this.resolveVideoUrl();if(!i)return;void u(i,this.downloadFileName,this.videoType||this.type)};this.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.videoSrc=undefined;this.downloadFileName=undefined;this.poster="";this.videoType="video/mp4";this.time=undefined;this.height="150px";this.width="150px";this.playing=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.deliveryStatus=undefined;this.textColor=undefined;this.message=undefined;this.mentionedUsers=[];this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.type=undefined;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.isPlaying=false}videoEl(){var t;return((t=this.el.shadowRoot)===null||t===void 0?void 0:t.querySelector("video"))||null}resolveVideoUrl(){var t;return this.videoSrc||((t=this.videoEl())===null||t===void 0?void 0:t.currentSrc)||""}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("message-bubble",{key:"4b672ea1d53be97115d7859b8cb61a2f31d17d6c",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,deliveryStatus:this.deliveryStatus,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor,borderRadius:this.borderRadius||"10px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"b615a7f4f55010ac4e1fee0c5a439f11bbf57d3b",class:"video-wrap"},s("video",{key:"ac3ac6918f714849828590b96fd36f70bfd0882c",style:{height:this.height||"150px",width:this.width||"150px",objectFit:"cover",borderRadius:this.borderRadius||"8px"},src:this.videoSrc||undefined,poster:this.poster||undefined,preload:this.poster?"none":"metadata",onClick:this.toggle},s("source",{key:"f43f9c615d1f1f3c4e4e8f941efb02a1fc7eb305",src:this.videoSrc,type:this.videoType||"video/mp4"})),s("div",{key:"db2ee6e3b7fea19634d07a15e0516d69488a1983",class:"controls"},!this.isPlaying?s("button",{type:"button",onClick:this.playVideo,"aria-label":"Play"},"▶"):s("button",{type:"button",onClick:this.pauseVideo,"aria-label":"Pause"},"❚❚")),s("button",{key:"e282ae6caf07832e49e6791d33ee950b7bd1ed91",type:"button",class:"video_corner video_download",onClick:t=>this.downloadVideo(t),"aria-label":"Download"},s("img",{key:"d0ed1fb8ce8b5d5b9c246c9a99e3a04e907ebbaf",src:d,alt:""})),s("button",{key:"4d777aaf7650d5bcdd9f51da470bc43837f19092",type:"button",class:"video_corner video_fullscreen",onClick:this.fullscreen,"aria-label":"Fullscreen"},"⛶")),t?s("div",{style:{fontSize:"14px",color:this.textColor,marginTop:"4px"}},r(this.message,this.mentionedUsers,(t=>o(this.tagUserClick,t)),!!this.isSelf)):null)}get el(){return e(this)}};Ht.style=":host { display: block; position: relative; }\n .video-wrap { position: relative; width: fit-content; }\n .controls {\n position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center;\n pointer-events: none;\n }\n .controls button {\n pointer-events: auto; border: none; background: var(--overlay); color: var(--text-on-brand);\n cursor: pointer; padding: 8px 10px; border-radius: 8px; margin: 0 4px;\n }\n .video_corner {\n position: absolute; bottom: 8px; z-index: 2; pointer-events: auto;\n border: none; background: var(--overlay); color: var(--text-on-brand);\n cursor: pointer; padding: 6px; border-radius: 8px; line-height: 0;\n width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;\n }\n .video_corner img {\n width: 16px; height: 16px; display: block; object-fit: contain;\n filter: brightness(0) invert(1);\n }\n .video_download { left: 8px; }\n .video_fullscreen { right: 8px; font-size: 14px; line-height: 1; }";export{Wt as audio_bubble,At as document_message,Dt as image_message,Ht as video_message};
2
+ //# sourceMappingURL=p-94f0c983.entry.js.map
@@ -0,0 +1,2 @@
1
+ import{M as e}from"./p-8f17345f.js";import{i as t,C as r}from"./p-7fd2c1ad.js";import{j as o}from"./p-40217f22.js";const n=["--font-primary","--text-2","--text-4","--text-6","--text-8","--text-10","--text-12","--text-14","--text-16","--text-18","--text-20","--text-22","--text-24","--fw-400","--fw-500","--fw-600","--fw-700","--bg-primary","--bg-secondary","--bg-tertiary","--bg-input","--bg-row-hover","--text-primary","--text-secondary","--text-tertiary","--text-on-brand","--brand","--brand-soft","--brand-muted","--border","--border-subtle","--success","--danger","--hover-overlay","--overlay","--focus-ring","--icon","--svg-icon-filter","--rail-width","--control","--avatar","--rounded-8","--rounded-12","--rounded-full","--bg-primary-color","--bg-secondary-color","--bg-primary-light","--text-primary-color","--text-secondary-color","--text-tertiary-color","--text-success-color","--text-danger-color","--text-warning-color","--text-info-color","--text-last-seen"];function i(e){if(!e)return{};const t={};for(const[r,o]of Object.entries(e)){if(o==null||o==="")continue;const e=r.startsWith("--")?r:`--${r}`;t[e]=o}return t}function d(e,t){if(!e||!t)return;const r=i(t);for(const[t,o]of Object.entries(r)){e.style.setProperty(t,o)}}function s(e){if(e.show===false)return"hidden";if(e.hasCustomSlot)return"custom";return"default"}function a(e){return s({show:e.showProfileRail,hasCustomSlot:e.hasCustomSlot})}function l(e){if(e.showProfileSidebar!==undefined&&e.showProfileRail!==undefined){if(e.showProfileSidebar!==e.showProfileRail){console.warn("[isometrik-webchat] showProfileSidebar and showProfileRail disagree; using showProfileSidebar")}return e.showProfileSidebar}if(e.showProfileSidebar!==undefined)return e.showProfileSidebar;if(e.showProfileRail!==undefined)return e.showProfileRail;return undefined}function u(n){const i=n.baseUrl||r.baseUrl;const d=n.licenseKey||t.licenseKey;const s=n.appSecret||t.appSecret;e.initializeInstance({baseUrl:i,licenseKey:d,appSecret:s,userSecret:n.userSecret||t.userSecret,userToken:n.userToken});o({baseUrl:i,licenseKey:d,appSecret:s,userToken:n.userToken||""})}async function c(){var t,r,o;const n=await e.getInstance().user.getUserDetails();return{userId:(n===null||n===void 0?void 0:n.userId)||"",userIdentifier:(n===null||n===void 0?void 0:n.userIdentifier)||"",firstName:((t=n===null||n===void 0?void 0:n.metaData)===null||t===void 0?void 0:t.firstName)||"",lastName:((r=n===null||n===void 0?void 0:n.metaData)===null||r===void 0?void 0:r.lastName)||"",updatedAt:(n===null||n===void 0?void 0:n.updatedAt)||"",userName:(n===null||n===void 0?void 0:n.userName)||"",online:(n===null||n===void 0?void 0:n.online)||"",userProfileImageUrl:(n===null||n===void 0?void 0:n.userProfileImageUrl)||"",profilePic:((o=n===null||n===void 0?void 0:n.metaData)===null||o===void 0?void 0:o.profilePic)||""}}export{n as T,d as a,s as b,a as c,c as f,u as i,i as n,l as r};
2
+ //# sourceMappingURL=p-ac671eb5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["THEME_TOKEN_NAMES","normalizeThemeObject","input","out","rawKey","value","Object","entries","key","startsWith","applyThemeObjectToElement","el","theme","normalized","style","setProperty","resolveRegionMode","opts","show","hasCustomSlot","resolveProfileRailMode","showProfileRail","resolveShowProfileRailProp","showProfileSidebar","undefined","console","warn","initializeChatSdk","config","baseUrl","CHAT_CREDS","licenseKey","isometrikFlutterAppSecrets","appSecret","ChatSDK","initializeInstance","userSecret","userToken","setStorageQuotaConfig","async","fetchUserDetails","res","getInstance","user","getUserDetails","userId","userIdentifier","firstName","_a","metaData","lastName","_b","updatedAt","userName","online","userProfileImageUrl","profilePic","_c"],"sources":["src/sdk/theme-tokens.ts","src/sdk/composition.ts","src/lib/chat/session.ts"],"sourcesContent":["/**\n * Public theme token catalog for host apps.\n * Pass values via initializeIsometrikWebchat({ theme: { ... } }) or a CSS file (themeUrl).\n *\n * Apply order: package defaults → themeUrl stylesheet → theme object (wins).\n *\n * Legacy aliases (*-color) still appear in older UI; set both when overriding colors\n * if you need full coverage until those call sites are normalized.\n */\n\nexport const THEME_TOKEN_NAMES = [\n // Typography\n '--font-primary',\n '--text-2',\n '--text-4',\n '--text-6',\n '--text-8',\n '--text-10',\n '--text-12',\n '--text-14',\n '--text-16',\n '--text-18',\n '--text-20',\n '--text-22',\n '--text-24',\n '--fw-400',\n '--fw-500',\n '--fw-600',\n '--fw-700',\n\n // Surfaces\n '--bg-primary',\n '--bg-secondary',\n '--bg-tertiary',\n '--bg-input',\n '--bg-row-hover',\n\n // Text\n '--text-primary',\n '--text-secondary',\n '--text-tertiary',\n '--text-on-brand',\n\n // Brand\n '--brand',\n '--brand-soft',\n '--brand-muted',\n\n // Borders / status / chrome\n '--border',\n '--border-subtle',\n '--success',\n '--danger',\n '--hover-overlay',\n '--overlay',\n '--focus-ring',\n '--icon',\n '--svg-icon-filter',\n\n // Layout helpers hosts sometimes tweak\n '--rail-width',\n '--control',\n '--avatar',\n '--rounded-8',\n '--rounded-12',\n '--rounded-full',\n\n // Legacy aliases still referenced by some components\n '--bg-primary-color',\n '--bg-secondary-color',\n '--bg-primary-light',\n '--text-primary-color',\n '--text-secondary-color',\n '--text-tertiary-color',\n '--text-success-color',\n '--text-danger-color',\n '--text-warning-color',\n '--text-info-color',\n '--text-last-seen',\n] as const;\n\nexport type ThemeTokenName = (typeof THEME_TOKEN_NAMES)[number];\n\n/** Host-provided overrides. Keys should be CSS custom property names (with leading --). */\nexport type ThemeTokenMap = Partial<Record<ThemeTokenName, string>> & {\n [cssVar: `--${string}`]: string | undefined;\n};\n\n/** Map short keys → canonical CSS vars (hosts may omit the leading --). */\nexport function normalizeThemeObject(input?: Record<string, string> | null): Record<string, string> {\n if (!input) return {};\n const out: Record<string, string> = {};\n for (const [rawKey, value] of Object.entries(input)) {\n if (value == null || value === '') continue;\n const key = rawKey.startsWith('--') ? rawKey : `--${rawKey}`;\n out[key] = value;\n }\n return out;\n}\n\n/**\n * Apply theme object as inline CSS variables on a host element.\n * Scoped to the chat root so multiple embeds don't fight over <html>.\n */\nexport function applyThemeObjectToElement(\n el: HTMLElement | null | undefined,\n theme?: Record<string, string> | null,\n): void {\n if (!el || !theme) return;\n const normalized = normalizeThemeObject(theme);\n for (const [key, value] of Object.entries(normalized)) {\n el.style.setProperty(key, value);\n }\n}\n","/**\n * UI composition helpers for the shell.\n * Pure functions — easy to unit test, no Stencil.\n *\n * Matrix for every region:\n * show === false → hidden (wins over custom slot)\n * custom slot → custom\n * else → SDK default\n */\n\nexport type RegionMode = 'hidden' | 'custom' | 'default';\n\n/** @deprecated Use RegionMode */\nexport type ProfileRailMode = RegionMode;\n\nexport function resolveRegionMode(opts: {\n /** When false, region is not rendered. Undefined / true → visible. */\n show?: boolean;\n hasCustomSlot: boolean;\n}): RegionMode {\n if (opts.show === false) return 'hidden';\n if (opts.hasCustomSlot) return 'custom';\n return 'default';\n}\n\n/**\n * Profile icon rail resolution (same matrix as resolveRegionMode).\n */\nexport function resolveProfileRailMode(opts: {\n showProfileRail?: boolean;\n hasCustomSlot: boolean;\n}): RegionMode {\n return resolveRegionMode({\n show: opts.showProfileRail,\n hasCustomSlot: opts.hasCustomSlot,\n });\n}\n\n/**\n * Init prop alias: showProfileSidebar wins over showProfileRail when both set.\n * Returns undefined when neither is passed (component default applies).\n */\nexport function resolveShowProfileRailProp(opts: {\n showProfileSidebar?: boolean;\n showProfileRail?: boolean;\n}): boolean | undefined {\n if (opts.showProfileSidebar !== undefined && opts.showProfileRail !== undefined) {\n if (opts.showProfileSidebar !== opts.showProfileRail) {\n console.warn(\n '[isometrik-webchat] showProfileSidebar and showProfileRail disagree; using showProfileSidebar',\n );\n }\n return opts.showProfileSidebar;\n }\n if (opts.showProfileSidebar !== undefined) return opts.showProfileSidebar;\n if (opts.showProfileRail !== undefined) return opts.showProfileRail;\n return undefined;\n}\n","import ChatSDK from 'test-iso-chat-sdk';\nimport { CHAT_CREDS, isometrikFlutterAppSecrets } from '../../constants/chat-creds';\nimport { setStorageQuotaConfig } from './storage-quota';\n\nexport type ChatSdkInitConfig = {\n baseUrl?: string;\n licenseKey?: string;\n appSecret?: string;\n userSecret?: string;\n userToken?: string;\n};\n\n/** Init ChatSDK singleton. Props win; chat-creds used as local-demo fallback. */\nexport function initializeChatSdk(config: ChatSdkInitConfig) {\n const baseUrl = config.baseUrl || CHAT_CREDS.baseUrl;\n const licenseKey = config.licenseKey || isometrikFlutterAppSecrets.licenseKey;\n const appSecret = config.appSecret || isometrikFlutterAppSecrets.appSecret;\n ChatSDK.initializeInstance({\n baseUrl,\n licenseKey,\n appSecret,\n userSecret: config.userSecret || isometrikFlutterAppSecrets.userSecret,\n userToken: config.userToken,\n });\n // Media storage quota uses the same creds for its raw /chat/quota/* calls.\n setStorageQuotaConfig({ baseUrl, licenseKey, appSecret, userToken: config.userToken || '' });\n}\n\n/** Normalize getUserDetails API response into the shape WebChat stores. */\nexport async function fetchUserDetails() {\n const res: any = await ChatSDK.getInstance().user.getUserDetails();\n return {\n userId: res?.userId || '',\n userIdentifier: res?.userIdentifier || '',\n firstName: res?.metaData?.firstName || '',\n lastName: res?.metaData?.lastName || '',\n updatedAt: res?.updatedAt || '',\n userName: res?.userName || '',\n online: res?.online || '',\n userProfileImageUrl: res?.userProfileImageUrl || '',\n profilePic: res?.metaData?.profilePic || '',\n };\n}\n"],"mappings":"yHAUaA,EAAoB,CAE/B,iBACA,WACA,WACA,WACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,WACA,WACA,WAGA,eACA,iBACA,gBACA,aACA,iBAGA,iBACA,mBACA,kBACA,kBAGA,UACA,eACA,gBAGA,WACA,kBACA,YACA,WACA,kBACA,YACA,eACA,SACA,oBAGA,eACA,YACA,WACA,cACA,eACA,iBAGA,qBACA,uBACA,qBACA,uBACA,yBACA,wBACA,uBACA,sBACA,uBACA,oBACA,oB,SAWcC,EAAqBC,GACnC,IAAKA,EAAO,MAAO,GACnB,MAAMC,EAA8B,GACpC,IAAK,MAAOC,EAAQC,KAAUC,OAAOC,QAAQL,GAAQ,CACnD,GAAIG,GAAS,MAAQA,IAAU,GAAI,SACnC,MAAMG,EAAMJ,EAAOK,WAAW,MAAQL,EAAS,KAAKA,IACpDD,EAAIK,GAAOH,C,CAEb,OAAOF,CACT,C,SAMgBO,EACdC,EACAC,GAEA,IAAKD,IAAOC,EAAO,OACnB,MAAMC,EAAaZ,EAAqBW,GACxC,IAAK,MAAOJ,EAAKH,KAAUC,OAAOC,QAAQM,GAAa,CACrDF,EAAGG,MAAMC,YAAYP,EAAKH,E,CAE9B,C,SClGgBW,EAAkBC,GAKhC,GAAIA,EAAKC,OAAS,MAAO,MAAO,SAChC,GAAID,EAAKE,cAAe,MAAO,SAC/B,MAAO,SACT,C,SAKgBC,EAAuBH,GAIrC,OAAOD,EAAkB,CACvBE,KAAMD,EAAKI,gBACXF,cAAeF,EAAKE,eAExB,C,SAMgBG,EAA2BL,GAIzC,GAAIA,EAAKM,qBAAuBC,WAAaP,EAAKI,kBAAoBG,UAAW,CAC/E,GAAIP,EAAKM,qBAAuBN,EAAKI,gBAAiB,CACpDI,QAAQC,KACN,gG,CAGJ,OAAOT,EAAKM,kB,CAEd,GAAIN,EAAKM,qBAAuBC,UAAW,OAAOP,EAAKM,mBACvD,GAAIN,EAAKI,kBAAoBG,UAAW,OAAOP,EAAKI,gBACpD,OAAOG,SACT,C,SC5CgBG,EAAkBC,GAChC,MAAMC,EAAUD,EAAOC,SAAWC,EAAWD,QAC7C,MAAME,EAAaH,EAAOG,YAAcC,EAA2BD,WACnE,MAAME,EAAYL,EAAOK,WAAaD,EAA2BC,UACjEC,EAAQC,mBAAmB,CACzBN,UACAE,aACAE,YACAG,WAAYR,EAAOQ,YAAcJ,EAA2BI,WAC5DC,UAAWT,EAAOS,YAGpBC,EAAsB,CAAET,UAASE,aAAYE,YAAWI,UAAWT,EAAOS,WAAa,IACzF,CAGOE,eAAeC,I,UACpB,MAAMC,QAAiBP,EAAQQ,cAAcC,KAAKC,iBAClD,MAAO,CACLC,QAAQJ,IAAG,MAAHA,SAAG,SAAHA,EAAKI,SAAU,GACvBC,gBAAgBL,IAAG,MAAHA,SAAG,SAAHA,EAAKK,iBAAkB,GACvCC,YAAWC,EAAAP,IAAG,MAAHA,SAAG,SAAHA,EAAKQ,YAAQ,MAAAD,SAAA,SAAAA,EAAED,YAAa,GACvCG,WAAUC,EAAAV,IAAG,MAAHA,SAAG,SAAHA,EAAKQ,YAAQ,MAAAE,SAAA,SAAAA,EAAED,WAAY,GACrCE,WAAWX,IAAG,MAAHA,SAAG,SAAHA,EAAKW,YAAa,GAC7BC,UAAUZ,IAAG,MAAHA,SAAG,SAAHA,EAAKY,WAAY,GAC3BC,QAAQb,IAAG,MAAHA,SAAG,SAAHA,EAAKa,SAAU,GACvBC,qBAAqBd,IAAG,MAAHA,SAAG,SAAHA,EAAKc,sBAAuB,GACjDC,aAAYC,EAAAhB,IAAG,MAAHA,SAAG,SAAHA,EAAKQ,YAAQ,MAAAQ,SAAA,SAAAA,EAAED,aAAc,GAE7C,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{r as n,h as e,g as t}from"./p-17a96a2a.js";import{g as i,a as r}from"./p-04fdbd0a.js";import{g as o,c as a,m as s,u as d}from"./p-7d01ccbb.js";import{s as l}from"./p-0161f40b.js";import{drawerDialogService as c}from"./p-19d37e1f.js";import{u as h,a as v}from"./p-f97e3f6d.js";import{C as m,a as p}from"./p-c06ad586.js";import"./p-8f17345f.js";import"./p-54267fe0.js";import"./p-5162774c.js";const b=class{constructor(e){n(this,e);this.removeChip=n=>{this.selectedMembers=this.selectedMembers.filter((e=>this.idOf(e)!==n))};this.close=()=>{if(typeof this.onClose==="function")this.onClose();else c.closeDialog("member-add")};this.onSearch=n=>{this.searchText=n.target.value;clearTimeout(this.debounceTimer);this.debounceTimer=setTimeout((()=>this.handleGetEligibleMembers(this.searchText,0)),400)};this.onScroll=n=>{const e=n.target;if(e.scrollHeight-e.scrollTop<=e.clientHeight+10&&this.hasMore&&!this.paginationLoading){this.handleGetEligibleMembers(this.searchText||null,this.membersListSkip+20)}};this.dialogData={};this.onClose=undefined;this.eligibleMembers=[];this.membersListSkip=0;this.hasMore=false;this.isLoading=false;this.paginationLoading=false;this.searchText="";this.selectedMembers=[]}async componentDidLoad(){await this.handleGetEligibleMembers(null,0)}async handleGetEligibleMembers(n="",e=0){var t,r;if(e===0){this.isLoading=true;this.eligibleMembers=[]}if(e>=20)this.paginationLoading=true;this.hasMore=true;try{this.membersListSkip=e;const a={conversationId:this.dialogData.selectedConversationId||this.dialogData.conversationId,limit:20,skip:e};const s={groupcastId:this.dialogData.selectedConversationId||this.dialogData.conversationId,limit:20,skip:e};if(n)a.searchTag=n;let d;if(this.dialogData.isGroupcast){d=await o(Object.assign({},s))}else{d=await i(Object.assign({},a))}if(d){const n=((t=this.dialogData)===null||t===void 0?void 0:t.isGroupcast)?d===null||d===void 0?void 0:d.groupcastEligibleMembers:d===null||d===void 0?void 0:d.conversationEligibleMembers;const e=n||[];const i=n=>this.idOf(n);this.eligibleMembers=this.membersListSkip===0?h(e,i):v(this.eligibleMembers,e,i);const o=((r=this.dialogData)===null||r===void 0?void 0:r.isGroupcast)?s.limit:a.limit;if(e.length<o)this.hasMore=false}}catch(e){if((e===null||e===void 0?void 0:e.status)===404||(e===null||e===void 0?void 0:e.statusCode)===404)this.hasMore=false;if(((e===null||e===void 0?void 0:e.status)===404||(e===null||e===void 0?void 0:e.statusCode)===404)&&n!=null)this.eligibleMembers=[]}finally{this.isLoading=false;this.paginationLoading=false}}async handleAddMember(n){var e,t,i,o,h,v;const m=((e=this.dialogData)===null||e===void 0?void 0:e.selectedConversationId)||((t=this.dialogData)===null||t===void 0?void 0:t.conversationId);if(!m){l({message:"Missing conversation id",type:"error",duration:3e3,position:"bottom-left"});return}if(!(n===null||n===void 0?void 0:n.length)){l({message:"Select at least one member",type:"error",duration:3e3,position:"bottom-left"});return}try{if((i=this.dialogData)===null||i===void 0?void 0:i.isGroupcast){await a(m,n);const e=n.map((n=>{var e;const t=(this.eligibleMembers||[]).find((e=>{var t;return(e===null||e===void 0?void 0:e.userId)===n||((t=e===null||e===void 0?void 0:e.opponentDetails)===null||t===void 0?void 0:t.userId)===n}));const i=(t===null||t===void 0?void 0:t.userName)||((e=t===null||t===void 0?void 0:t.opponentDetails)===null||e===void 0?void 0:e.userName)||n;return{userId:n,userName:i}}));const t=(h=(o=this.dialogData)===null||o===void 0?void 0:o.metaData)===null||h===void 0?void 0:h.membersDetail;const i=s(t,e);await d({groupcastId:m,metaData:Object.assign(Object.assign({},((v=this.dialogData)===null||v===void 0?void 0:v.metaData)||{}),{membersDetail:i})});this.el.dispatchEvent(new CustomEvent("groupcast-members-changed",{detail:{groupcastId:m,membersDetail:i},bubbles:true,composed:true}))}else{await r(m,n)}l({message:"Members added successfully",type:"success",duration:3e3,position:"bottom-left"});c.closeDialog("member-add")}catch(n){console.error("Error adding members to conversation:",n);const e=(n===null||n===void 0?void 0:n.errorMsg)||(n===null||n===void 0?void 0:n.message)||"";const t=typeof e==="string"&&/not allowed to add members/i.test(e)?"Only group admins can add members":typeof e==="string"&&e?e:"Failed to add members";l({message:t,type:"error",duration:4e3,position:"bottom-left"})}}nameOf(n){var e;return((e=n===null||n===void 0?void 0:n.opponentDetails)===null||e===void 0?void 0:e.userName)||(n===null||n===void 0?void 0:n.userName)||"Unknown"}idOf(n){var e;return((e=n===null||n===void 0?void 0:n.opponentDetails)===null||e===void 0?void 0:e.userId)||(n===null||n===void 0?void 0:n.userId)}imageOf(n){var e;return((e=n===null||n===void 0?void 0:n.opponentDetails)===null||e===void 0?void 0:e.userProfileImageUrl)||(n===null||n===void 0?void 0:n.userProfileImageUrl)}selectedIds(){return this.selectedMembers.map((n=>this.idOf(n))).filter(Boolean)}isSelected(n){const e=this.idOf(n);return!!e&&this.selectedIds().includes(e)}toggle(n){const e=this.idOf(n);if(!e)return;this.selectedMembers=this.isSelected(n)?this.selectedMembers.filter((n=>this.idOf(n)!==e)):[...this.selectedMembers,n]}render(){const n=this.eligibleMembers||[];const t=this.selectedIds();return e("div",{key:"e3c4a6015e9a1c4f0e5384418a19f29889e89ae4",class:"card"},e("div",{key:"c1d30d9fb600811e4064bb81a0b9be9aa35ffcb0",class:"head"},e("div",{key:"4c9a8bdc9e97359a577c14742ced97caeb0a6efd",class:"title-row"},e("button",{key:"b3e32f7bb53b36cbcf3f95b0843361471531f438",type:"button",class:"icon-btn","aria-label":"Close",onClick:this.close},e("img",{key:"38b2cd8c1fe29e091de394831ecbad3e3a0a9b49",class:"theme-icon",src:m,alt:""})),e("h3",{key:"05f2f4fc763464d2ec5cb009e86b235ba1163aac"},"Add member")),e("div",{key:"cdab5dc5c19aa27f1ee41236a758d80a7bb71195",class:"search"},e("img",{key:"856e55adca3243f00f48b53630d90c2e8ed913a5",class:"theme-icon",src:p,alt:""}),e("input",{key:"0f00680ddee2f60a23a7c4d35342b60313949db2",type:"text",placeholder:"Search name, number or @username",value:this.searchText,onInput:this.onSearch})),this.selectedMembers.length?e("div",{class:"chips"},this.selectedMembers.map((n=>{const t=this.idOf(n);return e("div",{class:"chip",key:t},e("profile-avatar",{src:this.imageOf(n)||"",name:this.nameOf(n),size:"1.75rem"}),e("span",null,this.nameOf(n)),e("button",{type:"button",class:"chip-x","aria-label":"Remove",onClick:()=>this.removeChip(t)},e("img",{class:"theme-icon",src:m,alt:""})))}))):null),e("div",{key:"d9cc1f7212856eb6e9bc000e447de395fd297ce0",class:"section"},"Contacts"),this.isLoading?e("div",{class:"empty"},e("spinner-loader",{height:"24px",width:"24px"})):n.length===0?e("div",{class:"empty"},"No members found"):e("div",{class:"list",onScroll:this.onScroll},n.map(((n,t)=>{const i=this.isSelected(n);const r=this.idOf(n);return e("div",{class:`row ${i?"selected":""}`,key:r||`row-${t}`,onClick:()=>this.toggle(n)},e("profile-avatar",{src:this.imageOf(n)||"",name:this.nameOf(n),size:"var(--control)"}),e("div",{class:"name"},this.nameOf(n)),e("input",{class:"row-check",type:"checkbox",checked:i,readOnly:true}))})),this.paginationLoading?e("div",{class:"empty"},e("spinner-loader",{height:"20px",width:"20px"})):null),e("div",{key:"525669763490d9e3e3f57cdfbcbc4fa71d72193d",class:"foot"},e("button",{key:"1cbae9fdbb345a5ba910e5e661a99a5859063e67",type:"button",class:"add-btn",disabled:!t.length,onClick:()=>this.handleAddMember(t)},"Add member")))}get el(){return t(this)}};b.style=":host {\n display: block;\n width: 100%;\n max-width: 440px;\n }\n .card {\n display: flex;\n flex-direction: column;\n max-height: 88vh;\n overflow: hidden;\n background: var(--bg-primary);\n color: var(--text-primary);\n border-radius: var(--rounded-12);\n border: 1px solid var(--border-subtle);\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);\n }\n .head {\n padding: 1.25rem 1.25rem 0.5rem;\n }\n .title-row {\n display: flex;\n align-items: center;\n gap: var(--gap-12);\n margin-bottom: 1rem;\n }\n .icon-btn {\n width: 2rem;\n height: 2rem;\n border: none;\n background: transparent;\n border-radius: var(--rounded-full);\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n color: var(--text-primary);\n padding: 0;\n }\n .icon-btn:hover { background: var(--hover-overlay); }\n .icon-btn img {\n width: var(--icon-md);\n height: var(--icon-md);\n display: block;\n }\n .theme-icon { filter: var(--svg-icon-filter); }\n h3 {\n margin: 0;\n font-size: var(--text-16);\n font-weight: var(--fw-600);\n color: var(--text-primary);\n }\n .search {\n position: relative;\n display: flex;\n align-items: center;\n }\n .search img {\n position: absolute;\n left: 0.875rem;\n width: var(--icon-md);\n height: var(--icon-md);\n pointer-events: none;\n opacity: 0.55;\n }\n .search input {\n width: 100%;\n box-sizing: border-box;\n padding: 0.5rem 1rem 0.5rem 2.5rem;\n border-radius: var(--rounded-full);\n border: 1px solid var(--brand);\n font-size: var(--text-14);\n color: var(--text-primary);\n background: var(--bg-primary);\n outline: none;\n font-family: inherit;\n }\n .search input::placeholder { color: var(--text-tertiary); }\n .search input:focus {\n box-shadow: 0 0 0 2px var(--brand-soft);\n }\n .chips {\n display: flex;\n flex-wrap: wrap;\n gap: var(--gap-8);\n margin-top: 1rem;\n padding: 0 0.25rem;\n }\n .chip {\n display: inline-flex;\n align-items: center;\n gap: var(--gap-8);\n padding: 0.25rem 0.5rem 0.25rem 0;\n }\n .chip span {\n font-size: var(--text-14);\n color: var(--text-primary);\n }\n .chip-x {\n border: none;\n background: transparent;\n cursor: pointer;\n padding: 0;\n display: flex;\n color: var(--text-secondary);\n }\n .chip-x:hover { color: var(--text-primary); }\n .chip-x img {\n width: 1rem;\n height: 1rem;\n display: block;\n }\n .section {\n padding: 0.5rem 1.25rem 0.25rem;\n font-size: var(--text-12);\n color: var(--text-secondary);\n font-weight: var(--fw-500);\n text-align: left;\n }\n .list {\n flex: 1;\n overflow-y: auto;\n padding: 0.25rem 0 0.5rem;\n min-height: 12rem;\n max-height: 50vh;\n }\n .row {\n display: flex;\n align-items: center;\n gap: var(--gap-12);\n padding: var(--space-12) var(--space-16);\n cursor: pointer;\n text-align: left;\n border-bottom: 1px solid var(--border-subtle);\n }\n .row.selected { background: var(--brand-muted); }\n .row:hover { background: var(--bg-row-hover); }\n .row-check {\n width: 1.25rem;\n height: 1.25rem;\n flex-shrink: 0;\n margin: 0;\n accent-color: var(--brand);\n cursor: pointer;\n }\n .name {\n flex: 1;\n min-width: 0;\n font-size: var(--text-14);\n font-weight: var(--fw-500);\n color: var(--text-primary);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .empty {\n padding: 1.5rem;\n text-align: center;\n color: var(--text-secondary);\n }\n .foot {\n padding: 0.75rem 1.25rem 1.25rem;\n background: var(--bg-primary);\n }\n .add-btn {\n width: 100%;\n border: none;\n border-radius: var(--rounded-full);\n padding: 0.625rem 1rem;\n font-size: var(--text-14);\n font-weight: var(--fw-600);\n font-family: inherit;\n cursor: pointer;\n background: var(--brand);\n color: var(--text-on-brand);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);\n }\n .add-btn:hover { filter: brightness(1.05); }\n .add-btn:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n filter: none;\n }";export{b as member_add};
2
+ //# sourceMappingURL=p-b884d9ee.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MemberAdd","this","removeChip","id","selectedMembers","filter","m","idOf","close","onClose","drawerDialogService","closeDialog","onSearch","e","searchText","target","value","clearTimeout","debounceTimer","setTimeout","handleGetEligibleMembers","onScroll","el","scrollHeight","scrollTop","clientHeight","hasMore","paginationLoading","membersListSkip","componentDidLoad","searchTag","skip","isLoading","eligibleMembers","payload","conversationId","dialogData","selectedConversationId","limit","groupcastPayload","groupcastId","isGroupcast","getGroupcastEligibleMembers","Object","assign","getConversationEligibleMembers","members","_a","groupcastEligibleMembers","conversationEligibleMembers","page","getId","uniqueById","appendUniqueById","_b","length","error","status","statusCode","handleAddMember","selectedUserIds","showToast","message","type","duration","position","_c","addGroupcastMember","added","map","fromList","find","userId","opponentDetails","userName","existingDetail","_e","_d","metaData","membersDetail","mergeMembersDetail","updateGroupCast","_f","dispatchEvent","CustomEvent","detail","bubbles","composed","addConversationMember","console","raw","errorMsg","msg","test","nameOf","imageOf","userProfileImageUrl","selectedIds","Boolean","isSelected","includes","toggle","x","render","ids","h","key","class","onClick","src","Cancel","alt","Search","placeholder","onInput","name","size","height","width","index","selected","rowId","checked","readOnly","disabled"],"sources":["src/components/ChatUIComponent/AddMember.tsx"],"sourcesContent":["import { Component, h, State, Prop, Element } from '@stencil/core';\nimport { getConversationEligibleMembers, addConversationMember } from '../../api/group-members.js';\nimport { getGroupcastEligibleMembers, addGroupcastMember, updateGroupCast } from '../../api/groupcast.js';\nimport { mergeMembersDetail } from '../../lib/chat';\nimport { showToast } from '../../lib/toast';\nimport { drawerDialogService } from '../../lib/drawer';\nimport { appendUniqueById, uniqueById } from '../../lib/helpers.js';\nimport { Cancel, Search } from '../../constants/chat-assets';\nimport './shared/spinner-loader/spinner-loader';\nimport './shared/profile-avatar/profile-avatar';\n\n@Component({\n tag: 'member-add',\n shadow: true,\n styles: `\n :host {\n display: block;\n width: 100%;\n max-width: 440px;\n }\n .card {\n display: flex;\n flex-direction: column;\n max-height: 88vh;\n overflow: hidden;\n background: var(--bg-primary);\n color: var(--text-primary);\n border-radius: var(--rounded-12);\n border: 1px solid var(--border-subtle);\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);\n }\n .head {\n padding: 1.25rem 1.25rem 0.5rem;\n }\n .title-row {\n display: flex;\n align-items: center;\n gap: var(--gap-12);\n margin-bottom: 1rem;\n }\n .icon-btn {\n width: 2rem;\n height: 2rem;\n border: none;\n background: transparent;\n border-radius: var(--rounded-full);\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n color: var(--text-primary);\n padding: 0;\n }\n .icon-btn:hover { background: var(--hover-overlay); }\n .icon-btn img {\n width: var(--icon-md);\n height: var(--icon-md);\n display: block;\n }\n .theme-icon { filter: var(--svg-icon-filter); }\n h3 {\n margin: 0;\n font-size: var(--text-16);\n font-weight: var(--fw-600);\n color: var(--text-primary);\n }\n .search {\n position: relative;\n display: flex;\n align-items: center;\n }\n .search img {\n position: absolute;\n left: 0.875rem;\n width: var(--icon-md);\n height: var(--icon-md);\n pointer-events: none;\n opacity: 0.55;\n }\n .search input {\n width: 100%;\n box-sizing: border-box;\n padding: 0.5rem 1rem 0.5rem 2.5rem;\n border-radius: var(--rounded-full);\n border: 1px solid var(--brand);\n font-size: var(--text-14);\n color: var(--text-primary);\n background: var(--bg-primary);\n outline: none;\n font-family: inherit;\n }\n .search input::placeholder { color: var(--text-tertiary); }\n .search input:focus {\n box-shadow: 0 0 0 2px var(--brand-soft);\n }\n .chips {\n display: flex;\n flex-wrap: wrap;\n gap: var(--gap-8);\n margin-top: 1rem;\n padding: 0 0.25rem;\n }\n .chip {\n display: inline-flex;\n align-items: center;\n gap: var(--gap-8);\n padding: 0.25rem 0.5rem 0.25rem 0;\n }\n .chip span {\n font-size: var(--text-14);\n color: var(--text-primary);\n }\n .chip-x {\n border: none;\n background: transparent;\n cursor: pointer;\n padding: 0;\n display: flex;\n color: var(--text-secondary);\n }\n .chip-x:hover { color: var(--text-primary); }\n .chip-x img {\n width: 1rem;\n height: 1rem;\n display: block;\n }\n .section {\n padding: 0.5rem 1.25rem 0.25rem;\n font-size: var(--text-12);\n color: var(--text-secondary);\n font-weight: var(--fw-500);\n text-align: left;\n }\n .list {\n flex: 1;\n overflow-y: auto;\n padding: 0.25rem 0 0.5rem;\n min-height: 12rem;\n max-height: 50vh;\n }\n .row {\n display: flex;\n align-items: center;\n gap: var(--gap-12);\n padding: var(--space-12) var(--space-16);\n cursor: pointer;\n text-align: left;\n border-bottom: 1px solid var(--border-subtle);\n }\n .row.selected { background: var(--brand-muted); }\n .row:hover { background: var(--bg-row-hover); }\n .row-check {\n width: 1.25rem;\n height: 1.25rem;\n flex-shrink: 0;\n margin: 0;\n accent-color: var(--brand);\n cursor: pointer;\n }\n .name {\n flex: 1;\n min-width: 0;\n font-size: var(--text-14);\n font-weight: var(--fw-500);\n color: var(--text-primary);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .empty {\n padding: 1.5rem;\n text-align: center;\n color: var(--text-secondary);\n }\n .foot {\n padding: 0.75rem 1.25rem 1.25rem;\n background: var(--bg-primary);\n }\n .add-btn {\n width: 100%;\n border: none;\n border-radius: var(--rounded-full);\n padding: 0.625rem 1rem;\n font-size: var(--text-14);\n font-weight: var(--fw-600);\n font-family: inherit;\n cursor: pointer;\n background: var(--brand);\n color: var(--text-on-brand);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);\n }\n .add-btn:hover { filter: brightness(1.05); }\n .add-btn:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n filter: none;\n }\n `,\n})\nexport class MemberAdd {\n @Element() el: HTMLElement;\n @Prop() dialogData: any = {};\n @Prop() onClose: () => void;\n @State() eligibleMembers: any = [];\n @State() membersListSkip: any = 0;\n @State() hasMore: any = false;\n @State() isLoading: boolean = false;\n @State() paginationLoading: boolean = false;\n @State() searchText: string = '';\n @State() selectedMembers: any[] = [];\n private debounceTimer: any;\n\n async componentDidLoad() {\n await this.handleGetEligibleMembers(null, 0);\n }\n\n async handleGetEligibleMembers(searchTag = '', skip = 0) {\n if (skip === 0) {\n this.isLoading = true;\n this.eligibleMembers = [];\n }\n if (skip >= 20) this.paginationLoading = true;\n this.hasMore = true;\n try {\n this.membersListSkip = skip;\n const payload: any = {\n conversationId: this.dialogData.selectedConversationId || this.dialogData.conversationId,\n limit: 20,\n skip,\n };\n const groupcastPayload: any = {\n groupcastId: this.dialogData.selectedConversationId || this.dialogData.conversationId,\n limit: 20,\n skip,\n };\n if (searchTag) payload.searchTag = searchTag;\n let eligibleMembers;\n if (this.dialogData.isGroupcast) {\n eligibleMembers = await getGroupcastEligibleMembers({ ...groupcastPayload });\n } else {\n eligibleMembers = await getConversationEligibleMembers({ ...payload });\n }\n if (eligibleMembers) {\n const members = this.dialogData?.isGroupcast\n ? eligibleMembers?.groupcastEligibleMembers\n : eligibleMembers?.conversationEligibleMembers;\n const page = members || [];\n const getId = (m: any) => this.idOf(m);\n this.eligibleMembers =\n this.membersListSkip === 0\n ? uniqueById(page, getId)\n : appendUniqueById(this.eligibleMembers, page, getId);\n const limit = this.dialogData?.isGroupcast ? groupcastPayload.limit : payload.limit;\n if (page.length < limit) this.hasMore = false;\n }\n } catch (error) {\n if (error?.status === 404 || error?.statusCode === 404) this.hasMore = false;\n if ((error?.status === 404 || error?.statusCode === 404) && searchTag != null) this.eligibleMembers = [];\n } finally {\n this.isLoading = false;\n this.paginationLoading = false;\n }\n }\n\n async handleAddMember(selectedUserIds: any) {\n const conversationId = this.dialogData?.selectedConversationId || this.dialogData?.conversationId;\n if (!conversationId) {\n showToast({ message: 'Missing conversation id', type: 'error', duration: 3000, position: 'bottom-left' });\n return;\n }\n if (!selectedUserIds?.length) {\n showToast({ message: 'Select at least one member', type: 'error', duration: 3000, position: 'bottom-left' });\n return;\n }\n try {\n if (this.dialogData?.isGroupcast) {\n await addGroupcastMember(conversationId, selectedUserIds);\n const added = selectedUserIds.map((id: string) => {\n const fromList = (this.eligibleMembers || []).find(\n (m: any) => m?.userId === id || m?.opponentDetails?.userId === id,\n );\n const userName =\n fromList?.userName || fromList?.opponentDetails?.userName || id;\n return { userId: id, userName };\n });\n const existingDetail = this.dialogData?.metaData?.membersDetail;\n const membersDetail = mergeMembersDetail(existingDetail, added);\n await updateGroupCast({\n groupcastId: conversationId,\n metaData: {\n ...(this.dialogData?.metaData || {}),\n membersDetail,\n },\n });\n this.el.dispatchEvent(\n new CustomEvent('groupcast-members-changed', {\n detail: { groupcastId: conversationId, membersDetail },\n bubbles: true,\n composed: true,\n }),\n );\n } else {\n await addConversationMember(conversationId, selectedUserIds);\n }\n showToast({\n message: 'Members added successfully',\n type: 'success',\n duration: 3000,\n position: 'bottom-left',\n });\n drawerDialogService.closeDialog('member-add');\n } catch (error: any) {\n console.error('Error adding members to conversation:', error);\n const raw = error?.errorMsg || error?.message || '';\n const msg =\n typeof raw === 'string' && /not allowed to add members/i.test(raw)\n ? 'Only group admins can add members'\n : typeof raw === 'string' && raw\n ? raw\n : 'Failed to add members';\n showToast({\n message: msg,\n type: 'error',\n duration: 4000,\n position: 'bottom-left',\n });\n }\n }\n\n private nameOf(m: any) {\n return m?.opponentDetails?.userName || m?.userName || 'Unknown';\n }\n\n private idOf(m: any) {\n return m?.opponentDetails?.userId || m?.userId;\n }\n\n private imageOf(m: any) {\n return m?.opponentDetails?.userProfileImageUrl || m?.userProfileImageUrl;\n }\n\n private selectedIds() {\n return this.selectedMembers.map(m => this.idOf(m)).filter(Boolean);\n }\n\n private isSelected(m: any) {\n const id = this.idOf(m);\n return !!id && this.selectedIds().includes(id);\n }\n\n private toggle(m: any) {\n const id = this.idOf(m);\n if (!id) return;\n this.selectedMembers = this.isSelected(m)\n ? this.selectedMembers.filter(x => this.idOf(x) !== id)\n : [...this.selectedMembers, m];\n }\n\n private removeChip = (id: string) => {\n this.selectedMembers = this.selectedMembers.filter(m => this.idOf(m) !== id);\n };\n\n private close = () => {\n if (typeof this.onClose === 'function') this.onClose();\n else drawerDialogService.closeDialog('member-add');\n };\n\n private onSearch = (e: Event) => {\n this.searchText = (e.target as HTMLInputElement).value;\n clearTimeout(this.debounceTimer);\n this.debounceTimer = setTimeout(() => this.handleGetEligibleMembers(this.searchText, 0), 400);\n };\n\n private onScroll = (e: Event) => {\n const el = e.target as HTMLElement;\n if (el.scrollHeight - el.scrollTop <= el.clientHeight + 10 && this.hasMore && !this.paginationLoading) {\n this.handleGetEligibleMembers(this.searchText || null, this.membersListSkip + 20);\n }\n };\n\n render() {\n const members = this.eligibleMembers || [];\n const ids = this.selectedIds();\n return (\n <div class=\"card\">\n <div class=\"head\">\n <div class=\"title-row\">\n <button type=\"button\" class=\"icon-btn\" aria-label=\"Close\" onClick={this.close}>\n <img class=\"theme-icon\" src={Cancel} alt=\"\" />\n </button>\n <h3>Add member</h3>\n </div>\n <div class=\"search\">\n <img class=\"theme-icon\" src={Search} alt=\"\" />\n <input\n type=\"text\"\n placeholder=\"Search name, number or @username\"\n value={this.searchText}\n onInput={this.onSearch}\n />\n </div>\n {this.selectedMembers.length ? (\n <div class=\"chips\">\n {this.selectedMembers.map(m => {\n const id = this.idOf(m);\n return (\n <div class=\"chip\" key={id}>\n <profile-avatar src={this.imageOf(m) || ''} name={this.nameOf(m)} size=\"1.75rem\" />\n <span>{this.nameOf(m)}</span>\n <button type=\"button\" class=\"chip-x\" aria-label=\"Remove\" onClick={() => this.removeChip(id)}>\n <img class=\"theme-icon\" src={Cancel} alt=\"\" />\n </button>\n </div>\n );\n })}\n </div>\n ) : null}\n </div>\n\n <div class=\"section\">Contacts</div>\n\n {this.isLoading ? (\n <div class=\"empty\">\n <spinner-loader height=\"24px\" width=\"24px\" />\n </div>\n ) : members.length === 0 ? (\n <div class=\"empty\">No members found</div>\n ) : (\n <div class=\"list\" onScroll={this.onScroll}>\n {members.map((m, index) => {\n const selected = this.isSelected(m);\n const rowId = this.idOf(m);\n return (\n <div\n class={`row ${selected ? 'selected' : ''}`}\n key={rowId || `row-${index}`}\n onClick={() => this.toggle(m)}\n >\n <profile-avatar src={this.imageOf(m) || ''} name={this.nameOf(m)} size=\"var(--control)\" />\n <div class=\"name\">{this.nameOf(m)}</div>\n <input class=\"row-check\" type=\"checkbox\" checked={selected} readOnly />\n </div>\n );\n })}\n {this.paginationLoading ? (\n <div class=\"empty\">\n <spinner-loader height=\"20px\" width=\"20px\" />\n </div>\n ) : null}\n </div>\n )}\n\n <div class=\"foot\">\n <button\n type=\"button\"\n class=\"add-btn\"\n disabled={!ids.length}\n onClick={() => this.handleAddMember(ids)}\n >\n Add member\n </button>\n </div>\n </div>\n );\n }\n}\n"],"mappings":"oZAuMaA,EAAS,M,yBA+JZC,KAAAC,WAAcC,IACpBF,KAAKG,gBAAkBH,KAAKG,gBAAgBC,QAAOC,GAAKL,KAAKM,KAAKD,KAAOH,GAAG,EAGtEF,KAAAO,MAAQ,KACd,UAAWP,KAAKQ,UAAY,WAAYR,KAAKQ,eACxCC,EAAoBC,YAAY,aAAa,EAG5CV,KAAAW,SAAYC,IAClBZ,KAAKa,WAAcD,EAAEE,OAA4BC,MACjDC,aAAahB,KAAKiB,eAClBjB,KAAKiB,cAAgBC,YAAW,IAAMlB,KAAKmB,yBAAyBnB,KAAKa,WAAY,IAAI,IAAI,EAGvFb,KAAAoB,SAAYR,IAClB,MAAMS,EAAKT,EAAEE,OACb,GAAIO,EAAGC,aAAeD,EAAGE,WAAaF,EAAGG,aAAe,IAAMxB,KAAKyB,UAAYzB,KAAK0B,kBAAmB,CACrG1B,KAAKmB,yBAAyBnB,KAAKa,YAAc,KAAMb,KAAK2B,gBAAkB,G,mBA/KxD,G,4CAEM,G,qBACA,E,aACR,M,eACM,M,uBACQ,M,gBACR,G,qBACI,E,CAGlC,sBAAMC,SACE5B,KAAKmB,yBAAyB,KAAM,E,CAG5C,8BAAMA,CAAyBU,EAAY,GAAIC,EAAO,G,QACpD,GAAIA,IAAS,EAAG,CACd9B,KAAK+B,UAAY,KACjB/B,KAAKgC,gBAAkB,E,CAEzB,GAAIF,GAAQ,GAAI9B,KAAK0B,kBAAoB,KACzC1B,KAAKyB,QAAU,KACf,IACEzB,KAAK2B,gBAAkBG,EACvB,MAAMG,EAAe,CACnBC,eAAgBlC,KAAKmC,WAAWC,wBAA0BpC,KAAKmC,WAAWD,eAC1EG,MAAO,GACPP,QAEF,MAAMQ,EAAwB,CAC5BC,YAAavC,KAAKmC,WAAWC,wBAA0BpC,KAAKmC,WAAWD,eACvEG,MAAO,GACPP,QAEF,GAAID,EAAWI,EAAQJ,UAAYA,EACnC,IAAIG,EACJ,GAAIhC,KAAKmC,WAAWK,YAAa,CAC/BR,QAAwBS,EAA2BC,OAAAC,OAAA,GAAML,G,KACpD,CACLN,QAAwBY,EAA8BF,OAAAC,OAAA,GAAMV,G,CAE9D,GAAID,EAAiB,CACnB,MAAMa,IAAUC,EAAA9C,KAAKmC,cAAU,MAAAW,SAAA,SAAAA,EAAEN,aAC7BR,IAAe,MAAfA,SAAe,SAAfA,EAAiBe,yBACjBf,IAAe,MAAfA,SAAe,SAAfA,EAAiBgB,4BACrB,MAAMC,EAAOJ,GAAW,GACxB,MAAMK,EAAS7C,GAAWL,KAAKM,KAAKD,GACpCL,KAAKgC,gBACHhC,KAAK2B,kBAAoB,EACrBwB,EAAWF,EAAMC,GACjBE,EAAiBpD,KAAKgC,gBAAiBiB,EAAMC,GACnD,MAAMb,IAAQgB,EAAArD,KAAKmC,cAAU,MAAAkB,SAAA,SAAAA,EAAEb,aAAcF,EAAiBD,MAAQJ,EAAQI,MAC9E,GAAIY,EAAKK,OAASjB,EAAOrC,KAAKyB,QAAU,K,EAE1C,MAAO8B,GACP,IAAIA,IAAK,MAALA,SAAK,SAALA,EAAOC,UAAW,MAAOD,IAAK,MAALA,SAAK,SAALA,EAAOE,cAAe,IAAKzD,KAAKyB,QAAU,MACvE,KAAK8B,IAAK,MAALA,SAAK,SAALA,EAAOC,UAAW,MAAOD,IAAK,MAALA,SAAK,SAALA,EAAOE,cAAe,MAAQ5B,GAAa,KAAM7B,KAAKgC,gBAAkB,E,SAEtGhC,KAAK+B,UAAY,MACjB/B,KAAK0B,kBAAoB,K,EAI7B,qBAAMgC,CAAgBC,G,gBACpB,MAAMzB,IAAiBY,EAAA9C,KAAKmC,cAAU,MAAAW,SAAA,SAAAA,EAAEV,2BAA0BiB,EAAArD,KAAKmC,cAAU,MAAAkB,SAAA,SAAAA,EAAEnB,gBACnF,IAAKA,EAAgB,CACnB0B,EAAU,CAAEC,QAAS,0BAA2BC,KAAM,QAASC,SAAU,IAAMC,SAAU,gBACzF,M,CAEF,KAAKL,IAAe,MAAfA,SAAe,SAAfA,EAAiBL,QAAQ,CAC5BM,EAAU,CAAEC,QAAS,6BAA8BC,KAAM,QAASC,SAAU,IAAMC,SAAU,gBAC5F,M,CAEF,IACE,IAAIC,EAAAjE,KAAKmC,cAAU,MAAA8B,SAAA,SAAAA,EAAEzB,YAAa,OAC1B0B,EAAmBhC,EAAgByB,GACzC,MAAMQ,EAAQR,EAAgBS,KAAKlE,I,MACjC,MAAMmE,GAAYrE,KAAKgC,iBAAmB,IAAIsC,MAC3CjE,IAAM,IAAAyC,EAAK,OAAAzC,IAAC,MAADA,SAAC,SAADA,EAAGkE,UAAWrE,KAAM4C,EAAAzC,IAAC,MAADA,SAAC,SAADA,EAAGmE,mBAAe,MAAA1B,SAAA,SAAAA,EAAEyB,UAAWrE,CAAE,IAEnE,MAAMuE,GACJJ,IAAQ,MAARA,SAAQ,SAARA,EAAUI,aAAY3B,EAAAuB,IAAQ,MAARA,SAAQ,SAARA,EAAUG,mBAAe,MAAA1B,SAAA,SAAAA,EAAE2B,WAAYvE,EAC/D,MAAO,CAAEqE,OAAQrE,EAAIuE,WAAU,IAEjC,MAAMC,GAAiBC,GAAAC,EAAA5E,KAAKmC,cAAU,MAAAyC,SAAA,SAAAA,EAAEC,YAAQ,MAAAF,SAAA,SAAAA,EAAEG,cAClD,MAAMA,EAAgBC,EAAmBL,EAAgBP,SACnDa,EAAgB,CACpBzC,YAAaL,EACb2C,SAAQnC,OAAAC,OAAAD,OAAAC,OAAA,KACFsC,EAAAjF,KAAKmC,cAAU,MAAA8C,SAAA,SAAAA,EAAEJ,WAAY,IAAE,CACnCC,oBAGJ9E,KAAKqB,GAAG6D,cACN,IAAIC,YAAY,4BAA6B,CAC3CC,OAAQ,CAAE7C,YAAaL,EAAgB4C,iBACvCO,QAAS,KACTC,SAAU,O,KAGT,OACCC,EAAsBrD,EAAgByB,E,CAE9CC,EAAU,CACRC,QAAS,6BACTC,KAAM,UACNC,SAAU,IACVC,SAAU,gBAEZvD,EAAoBC,YAAY,a,CAChC,MAAO6C,GACPiC,QAAQjC,MAAM,wCAAyCA,GACvD,MAAMkC,GAAMlC,IAAK,MAALA,SAAK,SAALA,EAAOmC,YAAYnC,IAAK,MAALA,SAAK,SAALA,EAAOM,UAAW,GACjD,MAAM8B,SACGF,IAAQ,UAAY,8BAA8BG,KAAKH,GAC1D,2CACOA,IAAQ,UAAYA,EACzBA,EACA,wBACR7B,EAAU,CACRC,QAAS8B,EACT7B,KAAM,QACNC,SAAU,IACVC,SAAU,e,EAKR,MAAA6B,CAAOxF,G,MACb,QAAOyC,EAAAzC,IAAC,MAADA,SAAC,SAADA,EAAGmE,mBAAe,MAAA1B,SAAA,SAAAA,EAAE2B,YAAYpE,IAAC,MAADA,SAAC,SAADA,EAAGoE,WAAY,S,CAGhD,IAAAnE,CAAKD,G,MACX,QAAOyC,EAAAzC,IAAC,MAADA,SAAC,SAADA,EAAGmE,mBAAe,MAAA1B,SAAA,SAAAA,EAAEyB,UAAUlE,IAAC,MAADA,SAAC,SAADA,EAAGkE,O,CAGlC,OAAAuB,CAAQzF,G,MACd,QAAOyC,EAAAzC,IAAC,MAADA,SAAC,SAADA,EAAGmE,mBAAe,MAAA1B,SAAA,SAAAA,EAAEiD,uBAAuB1F,IAAC,MAADA,SAAC,SAADA,EAAG0F,oB,CAG/C,WAAAC,GACN,OAAOhG,KAAKG,gBAAgBiE,KAAI/D,GAAKL,KAAKM,KAAKD,KAAID,OAAO6F,Q,CAGpD,UAAAC,CAAW7F,GACjB,MAAMH,EAAKF,KAAKM,KAAKD,GACrB,QAASH,GAAMF,KAAKgG,cAAcG,SAASjG,E,CAGrC,MAAAkG,CAAO/F,GACb,MAAMH,EAAKF,KAAKM,KAAKD,GACrB,IAAKH,EAAI,OACTF,KAAKG,gBAAkBH,KAAKkG,WAAW7F,GACnCL,KAAKG,gBAAgBC,QAAOiG,GAAKrG,KAAKM,KAAK+F,KAAOnG,IAClD,IAAIF,KAAKG,gBAAiBE,E,CAyBhC,MAAAiG,GACE,MAAMzD,EAAU7C,KAAKgC,iBAAmB,GACxC,MAAMuE,EAAMvG,KAAKgG,cACjB,OACEQ,EAAA,OAAAC,IAAA,2CAAKC,MAAM,QACTF,EAAA,OAAAC,IAAA,2CAAKC,MAAM,QACTF,EAAA,OAAAC,IAAA,2CAAKC,MAAM,aACTF,EAAA,UAAAC,IAAA,2CAAQ3C,KAAK,SAAS4C,MAAM,WAAU,aAAY,QAAQC,QAAS3G,KAAKO,OACtEiG,EAAA,OAAAC,IAAA,2CAAKC,MAAM,aAAaE,IAAKC,EAAQC,IAAI,MAE3CN,EAAA,MAAAC,IAAA,2DAEFD,EAAA,OAAAC,IAAA,2CAAKC,MAAM,UACTF,EAAA,OAAAC,IAAA,2CAAKC,MAAM,aAAaE,IAAKG,EAAQD,IAAI,KACzCN,EAAA,SAAAC,IAAA,2CACE3C,KAAK,OACLkD,YAAY,mCACZjG,MAAOf,KAAKa,WACZoG,QAASjH,KAAKW,YAGjBX,KAAKG,gBAAgBmD,OACpBkD,EAAA,OAAKE,MAAM,SACR1G,KAAKG,gBAAgBiE,KAAI/D,IACxB,MAAMH,EAAKF,KAAKM,KAAKD,GACrB,OACEmG,EAAA,OAAKE,MAAM,OAAOD,IAAKvG,GACrBsG,EAAA,kBAAgBI,IAAK5G,KAAK8F,QAAQzF,IAAM,GAAI6G,KAAMlH,KAAK6F,OAAOxF,GAAI8G,KAAK,YACvEX,EAAA,YAAOxG,KAAK6F,OAAOxF,IACnBmG,EAAA,UAAQ1C,KAAK,SAAS4C,MAAM,SAAQ,aAAY,SAASC,QAAS,IAAM3G,KAAKC,WAAWC,IACtFsG,EAAA,OAAKE,MAAM,aAAaE,IAAKC,EAAQC,IAAI,MAEvC,KAIV,MAGNN,EAAA,OAAAC,IAAA,2CAAKC,MAAM,WAAS,YAEnB1G,KAAK+B,UACJyE,EAAA,OAAKE,MAAM,SACTF,EAAA,kBAAgBY,OAAO,OAAOC,MAAM,UAEpCxE,EAAQS,SAAW,EACrBkD,EAAA,OAAKE,MAAM,SAAO,oBAElBF,EAAA,OAAKE,MAAM,OAAOtF,SAAUpB,KAAKoB,UAC9ByB,EAAQuB,KAAI,CAAC/D,EAAGiH,KACf,MAAMC,EAAWvH,KAAKkG,WAAW7F,GACjC,MAAMmH,EAAQxH,KAAKM,KAAKD,GACxB,OACEmG,EAAA,OACEE,MAAO,OAAOa,EAAW,WAAa,KACtCd,IAAKe,GAAS,OAAOF,IACrBX,QAAS,IAAM3G,KAAKoG,OAAO/F,IAE3BmG,EAAA,kBAAgBI,IAAK5G,KAAK8F,QAAQzF,IAAM,GAAI6G,KAAMlH,KAAK6F,OAAOxF,GAAI8G,KAAK,mBACvEX,EAAA,OAAKE,MAAM,QAAQ1G,KAAK6F,OAAOxF,IAC/BmG,EAAA,SAAOE,MAAM,YAAY5C,KAAK,WAAW2D,QAASF,EAAUG,SAAQ,OAChE,IAGT1H,KAAK0B,kBACJ8E,EAAA,OAAKE,MAAM,SACTF,EAAA,kBAAgBY,OAAO,OAAOC,MAAM,UAEpC,MAIRb,EAAA,OAAAC,IAAA,2CAAKC,MAAM,QACTF,EAAA,UAAAC,IAAA,2CACE3C,KAAK,SACL4C,MAAM,UACNiB,UAAWpB,EAAIjD,OACfqD,QAAS,IAAM3G,KAAK0D,gBAAgB6C,IAAI,e","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{r as n,a as e,h as i,g as t}from"./p-17a96a2a.js";import{j as r,k as a,l as s,i as o,r as d,M as l,s as h,t as c,B as f,h as u,f as p,D as v,S as b}from"./p-c06ad586.js";import{C as g}from"./p-8fea0c86.js";const m=class{constructor(i){n(this,i);this.tileMenu=e(this,"chat-tile-menu",7);this.toggleMenu=n=>{n.stopPropagation();if(this.menuOpen){this.menuOpen=false;this.menuPos=null;return}const e=n.currentTarget;const i=e.getBoundingClientRect();this.menuPos={top:i.bottom+2,left:i.right-8};this.menuOpen=true};this.emitAction=(n,e)=>{n.stopPropagation();this.menuOpen=false;this.menuPos=null;this.tileMenu.emit({action:e,conversationId:this.conversationId})};this.emitBlockToggle=n=>{this.emitAction(n,this.isBlockedByMe?"unblock":"block")};this.imageSrc=undefined;this.imageAlt=undefined;this.imageHeight=undefined;this.imageWidth=undefined;this.imageRadius=undefined;this.imageFillColor=undefined;this.imageTextColor=undefined;this.username="";this.userNameColor=undefined;this.userNameFontFamily=undefined;this.userNameFontWeight=undefined;this.usernameFontSize=undefined;this.usernameFontStyle=undefined;this.chatPreview="";this.chatPreviewColor=undefined;this.chatPreviewFontFamily=undefined;this.chatPreviewFontWeight=undefined;this.chatPreviewFontSize=undefined;this.chatPreviewFontStyle=undefined;this.unreadCount=0;this.unreadCountColor=undefined;this.unreadCountFontSize=undefined;this.unreadCountBgColor=undefined;this.unreadCountBorderRadius=undefined;this.unreadCountWidth=undefined;this.unreadCountHeight=undefined;this.messageDate="";this.messageDateColor=undefined;this.messageDateFontFamily=undefined;this.messageDateFontWeight=undefined;this.messageDateFontSize=undefined;this.messageDateFontStyle=undefined;this.padding=undefined;this.usernamePadding=undefined;this.chatPreviewPadding=undefined;this.messageDatePadding=undefined;this.bgColor=undefined;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.height=undefined;this.width=undefined;this.isSelected=undefined;this.sidebarSelectedColor=undefined;this.suffix=undefined;this.suffixColor=undefined;this.suffixBgColor=undefined;this.gap=undefined;this.isTyping=undefined;this.typingUserName=undefined;this.isRead=undefined;this.isPending=undefined;this.isDelivered=undefined;this.isSelfMessage=undefined;this.mediaType=undefined;this.mediaLabel=undefined;this.isGroup=false;this.isBlockedByMe=false;this.conversationId=undefined;this.onClick=undefined;this.onContextmenu=undefined;this.title=undefined;this.subtitle=undefined;this.time=undefined;this.menuOpen=false;this.menuPos=null}onDocClick(n){if(!this.menuOpen)return;if(!n.composedPath().includes(this.el)){this.menuOpen=false;this.menuPos=null}}docIcon(n){const e=(n||"").toLowerCase();if(/\.xlsx?$/.test(e)||e.endsWith(".csv"))return r;if(e.endsWith(".rtf"))return a;if(e.endsWith(".txt"))return s;return o}previewMeta(){if(this.isTyping)return{label:`${this.typingUserName||"Someone"} typing…`};if(this.mediaType===1)return{icon:d,label:"Image"};if(this.mediaType===2)return{label:"Video"};if(this.mediaType===3)return{icon:this.docIcon(this.mediaLabel),label:this.mediaLabel||"Document"};if(this.mediaType===4)return{icon:l,label:"Audio"};if(this.mediaType===5)return{icon:h,label:"Link"};return null}previewText(){const n=this.previewMeta();if(n)return n.label;return this.chatPreview||this.subtitle||""}render(){const n=this.imageWidth||this.imageHeight||undefined;return i("div",{key:"50ac0e7ea61c1d570bae6ddf316cb99a86943dd8",class:`chat-tile-container${this.isSelected?" selected":""}${this.menuOpen?" menu-open":""}`,style:{background:this.bgColor||undefined,padding:this.padding,gap:this.gap,height:this.height,width:this.width||undefined,borderWidth:this.borderWidth,borderColor:this.borderColor,borderStyle:this.borderStyle},onClick:n=>{var e;return(e=this.onClick)===null||e===void 0?void 0:e.call(this,n)},onContextMenu:n=>{var e;return(e=this.onContextmenu)===null||e===void 0?void 0:e.call(this,n)}},i("div",{key:"0e73b0b8868b0ac58d1eb70260719e38aa0d870c",class:"avatar-slot"},i("profile-avatar",{key:"f5b5d1c0ed04a4d97cbc42c4297fe7161659dc2b",src:this.imageSrc||"",name:this.username||this.title||"",size:n,radius:this.imageRadius,isGroup:this.isGroup})),i("div",{key:"bf6fd1fe59f9543dd0c09f353b7acf83e810cb92",class:"meta"},i("span",{key:"f2dec4b78b9669e1e50615710bf1bfd0760fd24d",class:"username",style:{color:this.userNameColor,fontFamily:this.userNameFontFamily,fontWeight:this.userNameFontWeight,fontSize:this.usernameFontSize,fontStyle:this.usernameFontStyle,padding:this.usernamePadding}},this.username||this.title,this.suffix?i("span",{class:"suffix",style:{color:this.suffixColor,background:this.suffixBgColor}},this.suffix):null),i("span",{key:"2b9d4a920d1124c8930f433d69a76594f2421c47",class:"date",style:{color:this.messageDateColor,fontFamily:this.messageDateFontFamily,fontWeight:this.messageDateFontWeight,fontSize:this.messageDateFontSize,fontStyle:this.messageDateFontStyle,padding:this.messageDatePadding}},this.messageDate||this.time),i("span",{key:"15cb594cdb7e11285640a40250462e69ae596dfc",class:"preview",style:{color:this.chatPreviewColor,fontFamily:this.chatPreviewFontFamily,fontWeight:this.chatPreviewFontWeight,fontSize:this.chatPreviewFontSize,fontStyle:this.chatPreviewFontStyle,padding:this.chatPreviewPadding}},(()=>{const n=this.previewMeta();if(n===null||n===void 0?void 0:n.icon){return[i("img",{class:"preview-icon",src:n.icon,alt:""}),i("span",{class:"preview-label"},n.label)]}return i("span",{class:"preview-label"},this.previewText())})()),i("div",{key:"0532a117aec4ecf1abf256aa0db4626f8a90e03b",class:"trailing"},i("button",{key:"50788bea9bdabf364376a18d0e7d94860c08fa29",type:"button",class:"menu-btn",title:"Chat options","aria-label":"Chat options",onClick:this.toggleMenu},i("img",{key:"c89e9bfcd7066906ac9be7698c8b061a342690d8",class:"theme-icon",src:c,alt:""})),this.unreadCount>0?i("span",{class:"unread",style:{color:this.unreadCountColor,background:this.unreadCountBgColor,fontSize:this.unreadCountFontSize,borderRadius:this.unreadCountBorderRadius,width:this.unreadCountWidth,height:this.unreadCountHeight}},this.unreadCount):null,this.menuOpen&&this.menuPos?i("div",{class:"tile-menu",role:"menu",style:{top:`${this.menuPos.top}px`,left:`${this.menuPos.left}px`},onClick:n=>n.stopPropagation()},!this.isGroup?i("button",{type:"button",class:"tile-menu-item",role:"menuitem",onClick:this.emitBlockToggle},i("img",{class:"theme-icon",src:f,alt:""}),i("span",null,this.isBlockedByMe?"Unblock":"Block")):null,i("button",{type:"button",class:"tile-menu-item",role:"menuitem",onClick:n=>this.emitAction(n,"clear")},i("img",{class:"theme-icon",src:u,alt:""}),i("span",null,"Clear chat")),this.isGroup?i("button",{type:"button",class:"tile-menu-item danger",role:"menuitem",onClick:n=>this.emitAction(n,"exit")},i("img",{class:"theme-icon",src:p,alt:""}),i("span",null,"Exit group")):i("button",{type:"button",class:"tile-menu-item danger",role:"menuitem",onClick:n=>this.emitAction(n,"delete")},i("img",{class:"theme-icon",src:v,alt:""}),i("span",null,"Delete chat"))):null)))}get el(){return t(this)}};m.style=":host {\n display: block;\n cursor: pointer;\n font-family: var(--font-primary);\n min-width: 0;\n max-width: var(--w-full);\n overflow: hidden;\n }\n .chat-tile-container {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: var(--gap-12);\n padding: var(--space-12) var(--space-16);\n width: var(--w-full);\n max-width: var(--w-full);\n min-width: 0;\n overflow: hidden;\n border-left: var(--strip) solid transparent;\n background: transparent;\n transition: background-color 0.15s;\n position: relative;\n }\n .chat-tile-container:hover {\n background-color: var(--bg-row-hover);\n }\n .chat-tile-container.selected {\n background-color: var(--bg-row-hover);\n border-left-color: var(--brand);\n }\n .chat-tile-container.selected:hover {\n background-color: var(--bg-row-hover);\n }\n .avatar-slot { flex-shrink: 0; }\n .meta {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n display: grid;\n grid-template-columns: minmax(0, 1fr) auto;\n grid-template-rows: auto auto;\n column-gap: var(--gap-8);\n row-gap: var(--gap-2);\n align-items: center;\n }\n .username {\n grid-column: 1;\n grid-row: 1;\n font-weight: 600;\n font-size: var(--text-14);\n color: var(--text-primary);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n min-width: 0;\n }\n .date {\n grid-column: 2;\n grid-row: 1;\n font-size: var(--text-10);\n color: var(--text-tertiary);\n white-space: nowrap;\n line-height: 1.2;\n }\n .chat-tile-container.selected .date {\n color: var(--brand);\n font-weight: 500;\n }\n .preview {\n grid-column: 1;\n grid-row: 2;\n font-size: var(--text-12);\n color: var(--text-secondary);\n white-space: nowrap;\n overflow: hidden;\n display: flex;\n align-items: center;\n gap: var(--gap-4);\n min-width: 0;\n }\n .preview-label {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n flex: 1;\n }\n .preview-icon {\n width: 1em;\n height: 1em;\n flex-shrink: 0;\n object-fit: contain;\n }\n .trailing {\n grid-column: 2;\n grid-row: 2;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n min-width: var(--icon-md);\n min-height: var(--icon-md);\n position: relative;\n }\n .menu-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n border: none;\n background: transparent;\n border-radius: var(--rounded-full);\n cursor: pointer;\n color: var(--text-tertiary);\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s, background-color 0.15s, color 0.15s;\n }\n .chat-tile-container:hover .menu-btn,\n .chat-tile-container.menu-open .menu-btn {\n opacity: 1;\n pointer-events: auto;\n }\n .chat-tile-container:hover .unread,\n .chat-tile-container.menu-open .unread {\n display: none;\n }\n .menu-btn:hover {\n color: var(--text-primary);\n background: var(--hover-overlay);\n }\n .menu-btn img {\n width: 1rem;\n height: 1rem;\n display: block;\n }\n .tile-menu {\n position: fixed;\n width: 10rem;\n background: var(--bg-primary);\n border-radius: var(--rounded-8);\n box-shadow: 0 2px 16px var(--overlay);\n border: 1px solid var(--border-subtle);\n padding: var(--gap-6) 0;\n z-index: 1000;\n }\n .tile-menu-item {\n width: calc(100% - 12px);\n margin: 0 6px;\n display: flex;\n align-items: center;\n gap: var(--gap-12);\n padding: var(--gap-6) var(--space-12);\n border: none;\n background: transparent;\n border-radius: var(--rounded-8);\n cursor: pointer;\n text-align: left;\n font-size: var(--text-12);\n font-weight: 200;\n color: var(--text-primary);\n font-family: var(--font-primary);\n }\n .tile-menu-item:hover {\n background: var(--brand-soft);\n color: var(--brand);\n }\n .tile-menu-item.danger {\n color: var(--danger);\n }\n .tile-menu-item.danger:hover {\n background: var(--hover-overlay);\n color: var(--danger);\n }\n .tile-menu-item img {\n width: var(--icon-sm);\n height: var(--icon-sm);\n display: block;\n flex-shrink: 0;\n object-fit: contain;\n }\n .unread {\n min-width: var(--badge);\n height: var(--badge);\n border-radius: var(--rounded-full);\n padding: 0 var(--gap-6);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: var(--text-10);\n color: var(--text-on-brand);\n background: var(--brand);\n }\n .suffix {\n font-size: var(--text-10);\n padding: var(--gap-2) var(--gap-6);\n border-radius: var(--rounded-4);\n margin-left: var(--gap-4);\n }\n .theme-icon { filter: var(--svg-icon-filter); }";const y=class{constructor(e){n(this,e);this.onSearch=n=>{const e=n.target.value;this.searchText=e;clearTimeout(this.debounceTimer);this.debounceTimer=setTimeout((()=>{if(typeof this.getForwardMessageMemberList==="function"){this.getForwardMessageMemberList(e||null,0)}}),400)};this.clearSelected=n=>{n.stopPropagation();this.selectedIds=[];this.selectedContacts=[]};this.onScroll=n=>{const e=n.target;if(e.scrollHeight-e.scrollTop<=e.clientHeight+10&&this.hasMore&&!this.paginationLoading){if(typeof this.getForwardMessageMemberList==="function"){this.getForwardMessageMemberList(this.searchText||null,(this.skip||0)+20)}}};this.bgColor=undefined;this.padding=undefined;this.height=undefined;this.width=undefined;this.label=undefined;this.hideTopbar=false;this.fontFamily=undefined;this.textColor=undefined;this.fontSize=undefined;this.selectedContacts=[];this.contactList=[];this.conversationList=[];this.isSearching=false;this.getForwardMessageMemberList=undefined;this.onSend=undefined;this.isLoading=false;this.paginationLoading=false;this.hasMore=false;this.skip=0;this.searchText="";this.selectedIds=[]}items(){return this.isSearching?this.contactList||[]:this.conversationList||this.contactList||[]}nameOf(n){var e;return((e=n===null||n===void 0?void 0:n.opponentDetails)===null||e===void 0?void 0:e.userName)||(n===null||n===void 0?void 0:n.userName)||(n===null||n===void 0?void 0:n.conversationTitle)||"Unknown"}idOf(n){var e;return((e=n===null||n===void 0?void 0:n.opponentDetails)===null||e===void 0?void 0:e.userId)||(n===null||n===void 0?void 0:n.userId)||(n===null||n===void 0?void 0:n.conversationId)||this.nameOf(n)}imageOf(n){var e;return((e=n===null||n===void 0?void 0:n.opponentDetails)===null||e===void 0?void 0:e.userProfileImageUrl)||(n===null||n===void 0?void 0:n.userProfileImageUrl)||(n===null||n===void 0?void 0:n.conversationImageUrl)}toggle(n){const e=this.idOf(n);const i=this.nameOf(n);if(this.selectedIds.includes(e)){this.selectedIds=this.selectedIds.filter((n=>n!==e));this.selectedContacts=(this.selectedContacts||[]).filter((n=>n!==i&&n!==e))}else{this.selectedIds=[...this.selectedIds,e];this.selectedContacts=[...this.selectedContacts||[],i]}}send(){if(typeof this.onSend==="function")this.onSend(this.selectedIds,this.selectedContacts)}render(){var n,e,t,r;const a=this.items();return i("div",{key:"a7ba6ff10408826dafbca24b12f92cc8296aa7ca",class:"searchable-list-container",style:{backgroundColor:this.bgColor,color:this.textColor,fontFamily:this.fontFamily,fontSize:this.fontSize,height:this.height,width:this.width,padding:this.padding}},this.hideTopbar?null:i("div",{class:"searchable-list-topbar"},this.label||"Forward to…"),i("div",{key:"9a672cdbfa86c04da6ccfc59ab652c2054ca9c5c",class:"searchable-list-searchbar"},i("input",{key:"838f01ba05c03e3199dfa7c39e0f0c2af3149cbd",type:"text",placeholder:"Search",value:this.searchText,onInput:this.onSearch})),this.isLoading?i("div",{class:"empty"},i("spinner-loader",{height:"24px",width:"24px"})):a.length===0?i("div",{class:"empty"},"No results"):i("div",{class:"searchable-list-tile",onScroll:this.onScroll},a.map((n=>{const e=this.idOf(n);const t=this.selectedIds.includes(e);return i("div",{class:`row ${t?"selected":""}`,onClick:()=>this.toggle(n)},i("profile-avatar",{src:this.imageOf(n)||"",name:this.nameOf(n),size:"var(--control)"}),i("span",{class:"row-name"},this.nameOf(n)),i("input",{class:"row-check",type:"checkbox",checked:t,readOnly:true}))})),this.paginationLoading?i("div",{class:"empty"},i("spinner-loader",{height:"20px",width:"20px"})):null),i("div",{key:"801ce1592835c6edafe3055aff0dfb136a2d7175",class:`footer ${this.selectedIds.length?"":"hidden"}`},i("div",{key:"0228c8e1b0716d7c5e40867a8ef897a1885e297b",class:"chip"},i("span",{key:"39d00ce7a61fd1359c6991ab8e12731e60edba20",class:"chip-dot"}),i("span",{key:"dca159778fbc7b9883a07d59a588d8f456234e7a"},this.selectedIds.length," selected"),i("button",{key:"59ea8e7573ffe5ed7f754b7b7f4f322ac0740bfa",class:"chip-clear",type:"button","aria-label":"Clear selection",onClick:this.clearSelected},i("img",{key:"08f4aa8a43ec77fb2187055645c0555f2973cfe2",class:"theme-icon",src:g,alt:""}))),i("button",{key:"4141d05130bb09ad140882c9e901b31c437cf122",class:"send-btn",type:"button","aria-label":((r=(e=(n=this.label)===null||n===void 0?void 0:n.toString)===null||e===void 0?void 0:(t=e.call(n)).toLowerCase)===null||r===void 0?void 0:r.call(t).includes("group"))?"Next":"Send",onClick:()=>this.send()},i("img",{key:"81c4277952b15ffc8bc067d0e6867f6bacf94e1e",src:b,alt:""}))))}};y.style=":host { display: block; }\n .searchable-list-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n min-height: 0;\n background: var(--bg-primary);\n color: var(--text-primary);\n font-family: var(--font-primary);\n }\n .searchable-list-topbar {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding: 0 var(--space-16);\n height: 4rem;\n box-sizing: border-box;\n border-bottom: 1px solid var(--border);\n font-size: var(--text-16);\n font-weight: 600;\n font-family: var(--font-primary);\n color: var(--text-primary);\n }\n .searchable-list-topbar:empty { display: none; }\n .searchable-list-searchbar {\n display: flex;\n align-items: center;\n gap: var(--gap-8);\n padding: var(--gap-6) var(--space-12);\n border-radius: var(--rounded-8);\n background-color: var(--bg-input);\n margin: var(--space-8) var(--space-16);\n }\n input {\n border: none;\n outline: none;\n padding: var(--gap-4);\n width: var(--w-full);\n background: transparent;\n color: var(--text-primary);\n font-size: var(--text-14);\n }\n input::placeholder { color: var(--text-tertiary); }\n .searchable-list-tile { width: 100%; flex: 1; min-height: 0; overflow-y: auto; }\n .row {\n display: flex;\n align-items: center;\n gap: var(--gap-12);\n padding: var(--space-12) var(--space-16);\n cursor: pointer;\n border-bottom: 1px solid var(--border-subtle);\n }\n .row.selected { background: var(--brand-muted); }\n .row:hover { background: var(--bg-row-hover); }\n .row-name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--text-14);\n }\n .row-check {\n width: 1.25rem;\n height: 1.25rem;\n flex-shrink: 0;\n margin: 0;\n accent-color: var(--brand);\n cursor: pointer;\n }\n .avatar {\n width: var(--control);\n height: var(--control);\n border-radius: var(--rounded-full);\n object-fit: cover;\n background: var(--brand-soft);\n flex-shrink: 0;\n }\n .footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--gap-12);\n padding: 0.875rem 1.25rem;\n background: var(--bg-input);\n border-top: 1px solid var(--border-subtle);\n flex-shrink: 0;\n }\n .footer.hidden { display: none; }\n .chip {\n display: inline-flex;\n align-items: center;\n gap: var(--gap-6);\n padding: var(--gap-4) 0.625rem;\n border-radius: var(--rounded-full);\n background: var(--bg-primary);\n border: 1px solid var(--border);\n font-size: var(--text-12);\n font-weight: var(--fw-600);\n color: var(--text-primary);\n }\n .chip-dot {\n width: 0.5rem;\n height: 0.5rem;\n border-radius: var(--rounded-full);\n background: var(--brand);\n }\n .chip-clear {\n border: none;\n background: transparent;\n cursor: pointer;\n padding: 0;\n display: flex;\n line-height: 0;\n }\n .chip-clear img { width: 0.875rem; height: 0.875rem; display: block; }\n .send-btn {\n width: 2.75rem;\n height: 2.75rem;\n border: none;\n border-radius: var(--rounded-full);\n background: var(--brand);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n box-shadow: 0 8px 16px rgba(37, 99, 235, 0.28);\n }\n .send-btn:active { transform: scale(0.95); }\n .send-btn img {\n width: var(--icon-sm);\n height: var(--icon-sm);\n display: block;\n filter: brightness(0) invert(1);\n }\n .empty { padding: var(--space-16); text-align: center; color: var(--text-secondary); }\n .theme-icon { filter: var(--svg-icon-filter); }";export{m as chat_tile,y as searchable_list};
2
+ //# sourceMappingURL=p-c4333279.entry.js.map