isometrik-plugin-chat-sdk 2.0.12 → 2.0.13
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.
- package/dist/cjs/{app-globals-c433d8a6.js → app-globals-95486d77.js} +2 -2
- package/dist/cjs/{app-globals-c433d8a6.js.map → app-globals-95486d77.js.map} +1 -1
- package/dist/cjs/attachment-preview_22.cjs.entry.js +65 -57
- package/dist/cjs/attachment-preview_22.cjs.entry.js.map +1 -1
- package/dist/cjs/audio-bubble_4.cjs.entry.js +3 -2
- package/dist/cjs/audio-bubble_4.cjs.entry.js.map +1 -1
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/isometrik-webchat.cjs.js +4 -4
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/cjs/login-page_3.cjs.entry.js +88 -35
- package/dist/cjs/login-page_3.cjs.entry.js.map +1 -1
- package/dist/cjs/{runtime-controls-95f6cb3b.js → runtime-controls-959fe6ed.js} +4 -2
- package/dist/cjs/runtime-controls-959fe6ed.js.map +1 -0
- package/dist/cjs/{send-media-37e09e83.js → send-media-2dadbb03.js} +98 -19
- package/dist/cjs/send-media-2dadbb03.js.map +1 -0
- package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js +53 -12
- package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js +12 -32
- package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/Header/WebChatHeader.js +11 -6
- package/dist/collection/components/ChatUIComponent/Header/WebChatHeader.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js +5 -5
- package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/shared/GroupCast/GroupCast.js +2 -2
- package/dist/collection/components/ChatUIComponent/shared/GroupCast/GroupCast.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/shared/video-message/video-message.js +21 -2
- package/dist/collection/components/ChatUIComponent/shared/video-message/video-message.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/WebChat.js +19 -0
- package/dist/collection/components/my-component/web-chat/WebChat.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/data-fetch.js +13 -3
- package/dist/collection/components/my-component/web-chat/data-fetch.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/shell-render.js +1 -1
- package/dist/collection/components/my-component/web-chat/shell-render.js.map +1 -1
- package/dist/collection/lib/chat/index.js +1 -1
- package/dist/collection/lib/chat/index.js.map +1 -1
- package/dist/collection/lib/chat/send-media.js +96 -18
- package/dist/collection/lib/chat/send-media.js.map +1 -1
- package/dist/collection/lib/mqtt/dispatch.js +56 -31
- package/dist/collection/lib/mqtt/dispatch.js.map +1 -1
- package/dist/collection/lib/mqtt/index.js +1 -1
- package/dist/collection/lib/mqtt/index.js.map +1 -1
- package/dist/collection/lib/mqtt/types.js +17 -0
- package/dist/collection/lib/mqtt/types.js.map +1 -1
- package/dist/collection/sdk/init.js +2 -0
- package/dist/collection/sdk/init.js.map +1 -1
- package/dist/components/ChatFooter.js +12 -32
- package/dist/components/ChatFooter.js.map +1 -1
- package/dist/components/ChatSidebar.js +36 -12
- package/dist/components/ChatSidebar.js.map +1 -1
- package/dist/components/GroupCast2.js +2 -2
- package/dist/components/GroupCast2.js.map +1 -1
- package/dist/components/WebChat.js +88 -34
- package/dist/components/WebChat.js.map +1 -1
- package/dist/components/WebChatBody.js +6 -6
- package/dist/components/WebChatBody.js.map +1 -1
- package/dist/components/WebChatHeader.js +11 -6
- package/dist/components/WebChatHeader.js.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/send-media.js +97 -19
- package/dist/components/send-media.js.map +1 -1
- package/dist/components/video-message2.js +4 -2
- package/dist/components/video-message2.js.map +1 -1
- package/dist/esm/{app-globals-dfce8a5b.js → app-globals-879c137f.js} +2 -2
- package/dist/esm/{app-globals-dfce8a5b.js.map → app-globals-879c137f.js.map} +1 -1
- package/dist/esm/attachment-preview_22.entry.js +65 -57
- package/dist/esm/attachment-preview_22.entry.js.map +1 -1
- package/dist/esm/audio-bubble_4.entry.js +3 -2
- package/dist/esm/audio-bubble_4.entry.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/isometrik-webchat.js +4 -4
- package/dist/esm/loader.js +4 -4
- package/dist/esm/login-page_3.entry.js +88 -35
- package/dist/esm/login-page_3.entry.js.map +1 -1
- package/dist/esm/{runtime-controls-ec6d5c75.js → runtime-controls-6b7c852a.js} +4 -2
- package/dist/esm/runtime-controls-6b7c852a.js.map +1 -0
- package/dist/esm/{send-media-a946c6dd.js → send-media-ac360d8e.js} +98 -20
- package/dist/esm/send-media-ac360d8e.js.map +1 -0
- package/dist/isometrik-webchat/index.esm.js +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.esm.js.map +1 -1
- package/dist/isometrik-webchat/{p-46dcd38f.js → p-217b9dc2.js} +2 -2
- package/dist/isometrik-webchat/p-217b9dc2.js.map +1 -0
- package/dist/isometrik-webchat/p-2c87c3fd.entry.js +2 -0
- package/dist/isometrik-webchat/p-2c87c3fd.entry.js.map +1 -0
- package/dist/isometrik-webchat/p-30855ba7.js +2 -0
- package/dist/isometrik-webchat/p-30855ba7.js.map +1 -0
- package/dist/isometrik-webchat/{p-cc5b86e6.entry.js → p-3120b9d3.entry.js} +2 -2
- package/dist/isometrik-webchat/p-3120b9d3.entry.js.map +1 -0
- package/dist/isometrik-webchat/{p-63ff4eea.entry.js.map → p-5672fae7.entry.js} +2 -1
- package/dist/isometrik-webchat/p-5672fae7.entry.js.map +1 -0
- package/dist/isometrik-webchat/p-79d1a171.js +2 -0
- package/dist/types/components/ChatUIComponent/ChatSidebar/ChatSidebar.d.ts +2 -0
- package/dist/types/components/ChatUIComponent/shared/video-message/video-message.d.ts +2 -0
- package/dist/types/components/my-component/web-chat/WebChat.d.ts +322 -0
- package/dist/types/components/my-component/web-chat/data-fetch.d.ts +14 -0
- package/dist/types/components.d.ts +24 -0
- package/dist/types/lib/chat/index.d.ts +1 -1
- package/dist/types/lib/chat/send-media.d.ts +21 -0
- package/dist/types/lib/mqtt/index.d.ts +1 -1
- package/dist/types/lib/mqtt/types.d.ts +11 -0
- package/dist/types/sdk/init.d.ts +7 -0
- package/package.json +1 -1
- package/dist/cjs/runtime-controls-95f6cb3b.js.map +0 -1
- package/dist/cjs/send-media-37e09e83.js.map +0 -1
- package/dist/components/urls.js +0 -5
- package/dist/components/urls.js.map +0 -1
- package/dist/esm/runtime-controls-ec6d5c75.js.map +0 -1
- package/dist/esm/send-media-a946c6dd.js.map +0 -1
- package/dist/isometrik-webchat/p-2d69086d.entry.js +0 -2
- package/dist/isometrik-webchat/p-2d69086d.entry.js.map +0 -1
- package/dist/isometrik-webchat/p-3f355f9e.js +0 -2
- package/dist/isometrik-webchat/p-3f355f9e.js.map +0 -1
- package/dist/isometrik-webchat/p-46dcd38f.js.map +0 -1
- package/dist/isometrik-webchat/p-63ff4eea.entry.js +0 -2
- package/dist/isometrik-webchat/p-86be30fe.js +0 -2
- package/dist/isometrik-webchat/p-cc5b86e6.entry.js.map +0 -1
- /package/dist/isometrik-webchat/{p-86be30fe.js.map → p-79d1a171.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as t}from"./p-5162774c.js";import{r as e,n,i as o,f as s,a as i,b as r,s as a,m as c,c as u,d,e as f}from"./p-1953573d.js";import{f as l,m,a as h,s as p,b as y,c as v,d as w,e as b,g as C,h as g,p as M,i as R}from"./p-217b9dc2.js";import{f as T}from"./p-b1330793.js";const k=["chatReady","conversationsChange","messagesChange","conversationSelect","replyChange","chatError","unreadMessageCountUpdated","conversationNotFound","messageReadStatusUpdated"];const E=["selectConversation","sendText","sendMedia","setReply","clearReply","loadMoreMessages","loadMoreConversations","getChatState","setCustomParts"];function P(t,e,...n){const o=t===null||t===void 0?void 0:t[e];if(typeof o!=="function"){return Promise.reject(new Error(`[isometrik-webchat] method "${e}" is not available`))}return Promise.resolve(o.apply(t,n))}function j(t){if(!t)return null;const e=t;return{selectConversation:t=>P(e,"selectConversation",t),sendText:(t,n)=>P(e,"sendText",t,n),sendMedia:(t,n,o)=>P(e,"sendMedia",t,n,o),setReply:t=>P(e,"setReply",t),clearReply:()=>P(e,"clearReply"),loadMoreMessages:()=>P(e,"loadMoreMessages"),loadMoreConversations:()=>P(e,"loadMoreConversations"),getChatState:()=>P(e,"getChatState"),setCustomParts:t=>P(e,"setCustomParts",t),on(t,n){e.addEventListener(t,n);return()=>e.removeEventListener(t,n)},methods:E,events:k}}function O(t){return!!t&&t.nodeType===1}function x(t){return t.getAttribute("slot")||t.slot||null}function S(t,e,n){if(!t||!n)return null;_(t,e);n.slot=e;n.setAttribute("slot",e);t.appendChild(n);return n}function _(t,e){if(!t)return;Array.from(t.children).forEach((t=>{if(!O(t))return;if(x(t)===e){t.remove()}}))}function D(t,e){const n=document.createElement("div");n.slot=t;n.setAttribute("slot",t);n.setAttribute("data-isometrik-slot",t);if(e)n.className=e;n.style.height="100%";n.style.width="100%";n.style.display="contents";return n}function z(t,e){if(!t||!e)return;Object.entries(e).forEach((([e,n])=>{if(n)S(t,e,n)}))}function H(){if(typeof window==="undefined")return{};window.__isometrikChatComponents=window.__isometrikChatComponents||{};return window.__isometrikChatComponents}function I(t){const e=H();if(t.themeProvider!==undefined)e.themeProvider=t.themeProvider;if(t.chatComponent!==undefined)e.chatComponent=t.chatComponent}function q(){if(typeof window==="undefined")return;window.__isometrikChatComponents={}}function A(t){var e,n;if(t){const o=t;if(o.tagName==="THEME-PROVIDER")return o;const s=(e=o.closest)===null||e===void 0?void 0:e.call(o,"theme-provider");if(s)return s;const i=T(o);if(((n=i===null||i===void 0?void 0:i.parentElement)===null||n===void 0?void 0:n.tagName)==="THEME-PROVIDER"){return i.parentElement}}const o=H().themeProvider;if(o)return o;if(typeof document==="undefined")return null;return document.querySelector("theme-provider")}function B(t){if(t){const e=t;if(e.tagName==="WEB-CHAT")return e;const n=T(e);if(n)return n}const e=H().chatComponent;if(e)return e;if(typeof document==="undefined")return null;return document.querySelector("web-chat")}const K="https://isometrik-website-bucket.s3.ap-south-1.amazonaws.com/styles/chat-combined-theme.css";function U(t){return[t.containerId||"__body__",t.isometrikUserId,t.userToken,t.projectId,t.accountId,t.keysetId].join("|")}function F(){if(typeof window==="undefined"){return{count:0,sessionKey:"",instance:null,pendingDestroy:null}}const t=window;if(!t.__isometrikChatRetain){t.__isometrikChatRetain={count:0,sessionKey:"",instance:null,pendingDestroy:null}}return t.__isometrikChatRetain}function L(t){const e=Object.assign(Object.assign({},t.themeObject||{}),t.theme||{});const o=n(e);return Object.keys(o).length?o:undefined}function W(t,e,n){if(n!==undefined)t[e]=n}function $(t){if(!t)return false;const{themeProvider:e,chatComponent:n}=t;if(!e||!n)return false;const o=H();return o.chatComponent===n&&o.themeProvider===e}function V(){const e=F();if(e.pendingDestroy){clearTimeout(e.pendingDestroy);e.pendingDestroy=null}e.count=0;e.sessionKey="";e.instance=null;t();document.querySelectorAll("theme-provider").forEach((t=>{if(!t.querySelector("web-chat")&&t.childNodes.length===0){t.remove()}}));q()}const N=V;function G(t){if(!t.licenseKey||!t.appSecret||!t.userSecret||!t.userToken||!t.isometrikUserId||!t.projectId||!t.keysetId||!t.accountId){console.error("Missing required props to Initialize chat!");return null}V();const n=U(t);const o=document.createElement("theme-provider");const s=t.themeUrl||K;const i=L(t);if(t.defaultTheme){o.setAttribute("mode",t.defaultTheme)}o.setAttribute("theme-path",s);if(i){o.themeObject=i}const r=document.createElement("web-chat");r.baseUrl=t.baseUrl||"https://apis.isometrik.io";r.hostUrl=t.hostUrl||"wss://connections.isometrik.io:2053/mqtt";r.licenseKey=t.licenseKey;r.appSecret=t.appSecret;r.userSecret=t.userSecret;r.userToken=t.userToken;r.isometrikUserId=t.isometrikUserId;r.projectId=t.projectId;r.keysetId=t.keysetId;r.accountId=t.accountId;r.defaultTheme=t.defaultTheme||"light";r.themeUrl=s;r.style.width="100%";r.style.height="100%";if(t.customParts){r.customParts=t.customParts}W(r,"showProfileRail",e(t));W(r,"showChatWallpaper",t.showChatWallpaper);W(r,"groupcastEnabled",t.groupcastEnabled);W(r,"showHeader",t.showHeader);W(r,"showComposer",t.showComposer);W(r,"showEmptyState",t.showEmptyState);W(r,"showConversationList",t.showConversationList);W(r,"showRightPanel",t.showRightPanel);W(r,"isSidebarHeaderSearch",t.isSidebarHeaderSearch);W(r,"showMqttStatus",t.showMqttStatus);z(r,t.slots);o.appendChild(r);o.style.width="100%";o.style.height="100%";o.style.display="block";const a=t.containerId?document.getElementById(t.containerId):document.body;if(a){a.appendChild(o)}else{console.error("Container with the specified ID not found. Appending to body instead.");document.body.appendChild(o)}I({themeProvider:o,chatComponent:r});const c=j(r);const u={themeProvider:o,chatComponent:r,api:c,sessionKey:n,destroy:V};const d=F();d.instance=u;d.sessionKey=n;d.count=Math.max(d.count,1);return u}function J(t){const e=F();if(e.pendingDestroy){clearTimeout(e.pendingDestroy);e.pendingDestroy=null}const n=U(t);if(e.sessionKey===n&&$(e.instance)){return e.instance}return G(t)}function Q(t){const e=F();if(e.pendingDestroy){clearTimeout(e.pendingDestroy);e.pendingDestroy=null}e.count+=1;return J(t)}function X(t=0){const e=F();e.count=Math.max(0,e.count-1);if(e.count>0)return;if(e.pendingDestroy)clearTimeout(e.pendingDestroy);e.pendingDestroy=setTimeout((()=>{e.pendingDestroy=null;if(e.count>0)return;V()}),t)}const Y=G;const Z={session:{init:t=>o(t),fetchUserDetails:s},conversations:{list:i,details:r,sortByLatest:a,mergeUnique:c},messages:{list:l,markRead:m,mergeById:h,search:p,links:y,mediaCount:v,mediaAttachments:w,filterMedia:b},groupcast:{details:u,members:d,contacts:f},media:{mediaTypeFromMime:C,customTypeFromMime:g,prepareMediaAttachments:M,buildReplyMetaData:R}};const tt="__isometrikReactBridge";function et(t,e,n){t.root.render(e.createElement(t.Component,Object.assign(Object.assign({},t.extraProps||{}),n)))}function nt(t,e,n){if(typeof customElements==="undefined")return t;if(customElements.get(t))return t;const{react:o,createRoot:s,propKeys:i,extraProps:r}=n;class a extends HTMLElement{constructor(){super(...arguments);this._store=null}connectedCallback(){if(!this._store){this._store={root:s(this),Component:e,extraProps:r}}this.render()}disconnectedCallback(){var t;try{(t=this._store)===null||t===void 0?void 0:t.root.unmount()}catch(t){}this._store=null}render(){if(!this._store||!this.isConnected)return;const t={};i.forEach((e=>{t[e]=this[`_${e}`]}));et(this._store,o,t)}}i.forEach((t=>{const e=`_${t}`;Object.defineProperty(a.prototype,t,{get(){return this[e]},set(t){if(this[e]===t)return;this[e]=t;if(this.isConnected)this.render()},configurable:true})}));customElements.define(t,a);return t}function ot(t,e,n){const o=D(t,n.className);o.style.display="block";o.style.height="100%";const s={root:n.createRoot(o),Component:e,extraProps:n.props};o[tt]=s;et(s,n.react,{});o.updateProps=t=>{s.extraProps=Object.assign(Object.assign({},s.extraProps||{}),t);et(s,n.react,{})};o.unmount=()=>{try{s.root.unmount()}catch(t){}delete o[tt]};return o}function st(t){if(!t)return;const e=t;if(typeof e.unmount==="function"){e.unmount();return}const n=t[tt];if(!n)return;try{n.root.unmount()}catch(t){}delete t[tt]}function it(t,e){const n=B(e);if(!n){console.error("Isometrik chat is not initialized");return}if(t.isChatFilter!==undefined){n.isChatFilter=t.isChatFilter}}function rt(t,e){const n=A(e);const o=B(e);if(o){o.defaultTheme=t}if(n){n.setAttribute("mode",t);if(typeof n.setTheme==="function"){n.setTheme(t)}return}console.error("Theme provider is not initialized")}function at(t,e){const o=A(e);if(!o){console.error("Theme provider is not initialized");return}if(t.themePath){o.setAttribute("theme-path",t.themePath)}if(t.themeObject){o.themeObject=n(t.themeObject)}}function ct(t){const e=A(t);if(!e){console.error("Theme provider is not initialized");return}if(typeof e.toggleTheme==="function"){e.toggleTheme()}}export{k as W,X as a,Z as b,j as c,V as d,J as e,nt as f,at as g,A as h,G as i,B as j,it as k,E as l,ot as m,U as n,Y as o,N as p,S as q,Q as r,rt as s,ct as t,st as u,_ as v,D as w,z as x,H as y};
|
|
2
|
+
//# sourceMappingURL=p-30855ba7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WEB_CHAT_PUBLIC_EVENTS","WEB_CHAT_PUBLIC_METHODS","callMethod","el","name","args","fn","Promise","reject","Error","resolve","apply","createWebChatApi","chatComponent","selectConversation","id","sendText","body","conversationId","sendMedia","files","caption","setReply","message","clearReply","loadMoreMessages","loadMoreConversations","getChatState","setCustomParts","parts","on","event","handler","addEventListener","removeEventListener","methods","events","isElement","node","nodeType","slotNameOf","getAttribute","slot","setWebChatSlot","slotName","element","clearWebChatSlot","setAttribute","appendChild","Array","from","children","forEach","remove","createSlotHost","className","document","createElement","style","height","width","display","setWebChatSlots","slots","Object","entries","getChatStore","window","__isometrikChatComponents","setChatStore","partial","store","themeProvider","undefined","clearChatStore","resolveThemeProvider","tagName","closest","_a","call","host","findWebChatHost","_b","parentElement","stored","querySelector","resolveWebChat","DEFAULT_THEME_URL","buildWebchatSessionKey","props","containerId","isometrikUserId","userToken","projectId","accountId","keysetId","join","getRetainState","count","sessionKey","instance","pendingDestroy","w","__isometrikChatRetain","resolveThemeObject","merged","assign","themeObject","theme","normalized","normalizeThemeObject","keys","length","applyOptionalBool","key","value","isLiveInstance","destroyIsometrikWebchat","retain","clearTimeout","destroyChatDom","querySelectorAll","childNodes","destroyChat","initializeIsometrikWebchat","licenseKey","appSecret","userSecret","console","error","themeUrl","defaultTheme","baseUrl","hostUrl","customParts","resolveShowProfileRailProp","showChatWallpaper","groupcastEnabled","showHeader","showComposer","showEmptyState","showConversationList","showRightPanel","isSidebarHeaderSearch","showMqttStatus","container","getElementById","api","destroy","Math","max","ensureIsometrikWebchat","retainIsometrikWebchat","releaseIsometrikWebchat","delayMs","setTimeout","initializeChat","isometrikWebchatApi","session","init","config","initializeChatSdk","fetchUserDetails","conversations","list","fetchConversationsPage","details","fetchConversationDetails","sortByLatest","sortConversationsByLatestMessage","mergeUnique","mergeUniqueConversations","messages","fetchMessagesPage","markRead","markConversationRead","mergeById","mergeMessagesById","search","searchMessages","links","fetchLinkMessages","mediaCount","fetchMediaCount","mediaAttachments","fetchMediaAttachments","filterMedia","filterMediaMessages","groupcast","fetchGroupcastDetails","members","fetchGroupcastMembersPage","contacts","fetchGroupcastContactsPage","media","mediaTypeFromMime","customTypeFromMime","prepareMediaAttachments","buildReplyMetaData","ROOT_KEY","paint","react","propsFromHost","root","render","Component","extraProps","defineReactCustomPart","tag","opts","customElements","get","createRoot","propKeys","ReactPart","HTMLElement","constructor","this","_store","connectedCallback","disconnectedCallback","unmount","isConnected","fromSetters","defineProperty","prototype","set","configurable","define","mountReactInSlot","updateProps","next","unmountReactSlot","anyHost","customChatSidebar","isChatFilter","switchChatTheme","chat","setTheme","applyCustomTheme","customTheme","themePath","toggleTheme"],"sources":["src/lib/custom-ui/public-api.ts","src/sdk/webchat-api.ts","src/sdk/slots.ts","src/sdk/instance.ts","src/sdk/init.ts","src/sdk/headless-api.ts","src/sdk/react-bridge.ts","src/sdk/runtime-controls.ts"],"sourcesContent":["/**\n * Public host-facing events + method contract for <web-chat>.\n * Slots/customParts = UI. These = data + actions (fully functional custom UI).\n */\n\nexport type ChatReadyDetail = {\n userMetaData: any;\n conversations: any[];\n};\n\nexport type ConversationsChangeDetail = {\n conversations: any[];\n};\n\nexport type MessagesChangeDetail = {\n conversationId: string | null;\n messages: any[];\n};\n\nexport type SelectionChangeDetail = {\n conversationId: string | null;\n conversation: any | null;\n};\n\nexport type ReplyChangeDetail = {\n replyMessage: any | null;\n};\n\nexport type ChatErrorDetail = {\n code: string;\n message: string;\n cause?: unknown;\n};\n\nexport const WEB_CHAT_PUBLIC_EVENTS = [\n 'chatReady',\n 'conversationsChange',\n 'messagesChange',\n 'conversationSelect',\n 'replyChange',\n 'chatError',\n 'unreadMessageCountUpdated',\n 'conversationNotFound',\n 'messageReadStatusUpdated',\n] as const;\n\nexport type WebChatPublicEvent = (typeof WEB_CHAT_PUBLIC_EVENTS)[number];\n\n/** Documented public @Method names on <web-chat>. */\nexport const WEB_CHAT_PUBLIC_METHODS = [\n 'selectConversation',\n 'sendText',\n 'sendMedia',\n 'setReply',\n 'clearReply',\n 'loadMoreMessages',\n 'loadMoreConversations',\n 'getChatState',\n 'setCustomParts',\n] as const;\n\nexport type WebChatPublicMethod = (typeof WEB_CHAT_PUBLIC_METHODS)[number];\n","/**\n * Bound actions/events for a live <web-chat> instance.\n * No REST imports — safe for unit tests without ChatSDK.\n */\n\nimport { WEB_CHAT_PUBLIC_EVENTS, WEB_CHAT_PUBLIC_METHODS } from '../lib/custom-ui';\nimport type { WebChatPublicEvent, WebChatPublicMethod } from '../lib/custom-ui';\n\nexport type WebChatApi = {\n selectConversation: (conversationId: string | null) => Promise<void>;\n sendText: (body: string, conversationId?: string) => Promise<unknown>;\n sendMedia: (files: File[] | FileList, conversationId?: string, caption?: string) => Promise<unknown>;\n setReply: (message: any | null) => Promise<void>;\n clearReply: () => Promise<void>;\n loadMoreMessages: () => Promise<void>;\n loadMoreConversations: () => Promise<void>;\n getChatState: () => Promise<Record<string, unknown>>;\n setCustomParts: (parts: Record<string, string>) => Promise<unknown>;\n on: (event: WebChatPublicEvent, handler: (ev: Event) => void) => () => void;\n methods: typeof WEB_CHAT_PUBLIC_METHODS;\n events: typeof WEB_CHAT_PUBLIC_EVENTS;\n};\n\nfunction callMethod(el: any, name: WebChatPublicMethod | 'setCustomParts', ...args: any[]) {\n const fn = el?.[name];\n if (typeof fn !== 'function') {\n return Promise.reject(new Error(`[isometrik-webchat] method \"${name}\" is not available`));\n }\n return Promise.resolve(fn.apply(el, args));\n}\n\n/** Bind public methods/events to a mounted <web-chat> element. */\nexport function createWebChatApi(chatComponent: HTMLElement | null | undefined): WebChatApi | null {\n if (!chatComponent) return null;\n const el = chatComponent as any;\n\n return {\n selectConversation: id => callMethod(el, 'selectConversation', id),\n sendText: (body, conversationId) => callMethod(el, 'sendText', body, conversationId),\n sendMedia: (files, conversationId, caption) => callMethod(el, 'sendMedia', files, conversationId, caption),\n setReply: message => callMethod(el, 'setReply', message),\n clearReply: () => callMethod(el, 'clearReply'),\n loadMoreMessages: () => callMethod(el, 'loadMoreMessages'),\n loadMoreConversations: () => callMethod(el, 'loadMoreConversations'),\n getChatState: () => callMethod(el, 'getChatState'),\n setCustomParts: parts => callMethod(el, 'setCustomParts', parts),\n on(event, handler) {\n el.addEventListener(event, handler);\n return () => el.removeEventListener(event, handler);\n },\n methods: WEB_CHAT_PUBLIC_METHODS,\n events: WEB_CHAT_PUBLIC_EVENTS,\n };\n}\n","/**\n * Framework-agnostic slot helpers.\n * React / Angular / Vue / vanilla all end up calling these with real HTMLElements.\n *\n * Note: avoid `instanceof HTMLElement` — it fails across jsdom realms in Jest.\n */\n\nimport type { WebChatSlotName } from '../lib/custom-ui';\n\nfunction isElement(node: ChildNode | null | undefined): node is HTMLElement {\n return !!node && node.nodeType === 1;\n}\n\nfunction slotNameOf(el: HTMLElement): string | null {\n return el.getAttribute('slot') || el.slot || null;\n}\n\n/** Attach (or replace) a named slot on <web-chat>. */\nexport function setWebChatSlot(\n chatComponent: HTMLElement | null | undefined,\n slotName: WebChatSlotName,\n element: HTMLElement,\n): HTMLElement | null {\n if (!chatComponent || !element) return null;\n clearWebChatSlot(chatComponent, slotName);\n element.slot = slotName;\n element.setAttribute('slot', slotName);\n chatComponent.appendChild(element);\n return element;\n}\n\n/** Remove host content for a named slot. */\nexport function clearWebChatSlot(\n chatComponent: HTMLElement | null | undefined,\n slotName: WebChatSlotName,\n): void {\n if (!chatComponent) return;\n Array.from(chatComponent.children).forEach(node => {\n if (!isElement(node)) return;\n if (slotNameOf(node) === slotName) {\n node.remove();\n }\n });\n}\n\n/** Create a plain wrapper element ready to receive framework content (e.g. React portal target). */\nexport function createSlotHost(slotName: WebChatSlotName, className?: string): HTMLElement {\n const el = document.createElement('div');\n el.slot = slotName;\n el.setAttribute('slot', slotName);\n el.setAttribute('data-isometrik-slot', slotName);\n if (className) el.className = className;\n el.style.height = '100%';\n el.style.width = '100%';\n el.style.display = 'contents';\n return el;\n}\n\n/** Attach many slots at once (same shape as initialize props.slots). */\nexport function setWebChatSlots(\n chatComponent: HTMLElement | null | undefined,\n slots?: Partial<Record<WebChatSlotName, HTMLElement>>,\n): void {\n if (!chatComponent || !slots) return;\n (Object.entries(slots) as [WebChatSlotName, HTMLElement | undefined][]).forEach(([name, el]) => {\n if (el) setWebChatSlot(chatComponent, name, el);\n });\n}\n","/**\n * Last-mounted chat instance registry + resolvers.\n * Prefer explicit elements; fall back to store; querySelector is last resort.\n */\n\nimport { findWebChatHost } from '../lib/custom-ui';\n\nexport type StoredChatComponents = {\n themeProvider?: HTMLElement;\n chatComponent?: HTMLElement;\n};\n\nexport function getChatStore(): StoredChatComponents {\n if (typeof window === 'undefined') return {};\n (window as any).__isometrikChatComponents = (window as any).__isometrikChatComponents || {};\n return (window as any).__isometrikChatComponents;\n}\n\nexport function setChatStore(partial: StoredChatComponents): void {\n const store = getChatStore();\n if (partial.themeProvider !== undefined) store.themeProvider = partial.themeProvider;\n if (partial.chatComponent !== undefined) store.chatComponent = partial.chatComponent;\n}\n\nexport function clearChatStore(): void {\n if (typeof window === 'undefined') return;\n (window as any).__isometrikChatComponents = {};\n}\n\n/** Resolve <theme-provider> from an explicit node, store, or (last) DOM. */\nexport function resolveThemeProvider(from?: Element | null): HTMLElement | null {\n if (from) {\n const el = from as HTMLElement;\n if (el.tagName === 'THEME-PROVIDER') return el;\n const closest = el.closest?.('theme-provider');\n if (closest) return closest as HTMLElement;\n const host = findWebChatHost(el);\n if (host?.parentElement?.tagName === 'THEME-PROVIDER') {\n return host.parentElement;\n }\n }\n const stored = getChatStore().themeProvider;\n if (stored) return stored;\n if (typeof document === 'undefined') return null;\n return document.querySelector('theme-provider');\n}\n\n/** Resolve <web-chat> from an explicit node, store, or (last) DOM. */\nexport function resolveWebChat(from?: Element | null): HTMLElement | null {\n if (from) {\n const el = from as HTMLElement;\n if (el.tagName === 'WEB-CHAT') return el;\n const host = findWebChatHost(el);\n if (host) return host;\n }\n const stored = getChatStore().chatComponent;\n if (stored) return stored;\n if (typeof document === 'undefined') return null;\n return document.querySelector('web-chat');\n}\n","import { destroyChatDom } from '../lib/destroy-chat';\nimport type { WebChatSlotName, WebChatCustomParts } from '../lib/custom-ui';\nimport type { ThemeTokenMap } from './theme-tokens';\nimport { normalizeThemeObject } from './theme-tokens';\nimport { resolveShowProfileRailProp } from './composition';\nimport { createWebChatApi, type WebChatApi } from './webchat-api';\nimport { setWebChatSlots } from './slots';\nimport { clearChatStore, getChatStore, setChatStore } from './instance';\n\nconst DEFAULT_THEME_URL =\n 'https://isometrik-website-bucket.s3.ap-south-1.amazonaws.com/styles/chat-combined-theme.css';\n\nexport type IsometrikWebchatInitProps = {\n baseUrl?: string;\n hostUrl?: string;\n licenseKey: string;\n appSecret: string;\n userSecret: string;\n userToken: string;\n isometrikUserId: string;\n projectId: string;\n keysetId: string;\n accountId: string;\n defaultTheme?: 'dark' | 'light';\n /** CSS file from CDN or same-origin path. */\n themeUrl?: string;\n /** Inline CSS variable overrides (wins over themeUrl for same keys). */\n theme?: ThemeTokenMap;\n /** @deprecated Use `theme`. Kept for applyCustomTheme / older hosts. */\n themeObject?: Record<string, string>;\n containerId?: string;\n /** Optional custom UI nodes — each gets `slot=\"<name>\"` and is appended to <web-chat>. */\n slots?: Partial<Record<WebChatSlotName, HTMLElement>>;\n /** Custom element tags for list rows / dialogs. */\n customParts?: WebChatCustomParts;\n /** When false, hide the left profile icon rail. Default true. */\n showProfileRail?: boolean;\n /** Alias of showProfileRail for clearer host DX. Default true. */\n showProfileSidebar?: boolean;\n /** When false, no doodle wallpaper behind messages. Default true. */\n showChatWallpaper?: boolean;\n /** When false, hide groupcast entry points. Default true. */\n groupcastEnabled?: boolean;\n /** When false, hide conversation header. Default true. */\n showHeader?: boolean;\n /** When false, hide composer. Default true. */\n showComposer?: boolean;\n /** When false, hide empty state. Default true. */\n showEmptyState?: boolean;\n /** When false, hide conversation list. Default true. */\n showConversationList?: boolean;\n /** When false, never show right info panel. Default true. */\n showRightPanel?: boolean;\n /** When false, hide conversation-list search. Default true. */\n isSidebarHeaderSearch?: boolean;\n /**\n * When false, hide the MQTT green/red status dot in the conversation list header.\n * Default true.\n */\n showMqttStatus?: boolean;\n};\n\n/** @deprecated Use IsometrikWebchatInitProps */\nexport type InitializeChatProps = IsometrikWebchatInitProps;\n\nexport type IsometrikWebchatInstance = {\n themeProvider: HTMLElement;\n chatComponent: HTMLElement;\n /** Bound actions/events for the live instance. */\n api: WebChatApi;\n /** Session key used by ensure/retain. */\n sessionKey: string;\n destroy: () => void;\n};\n\n/** Identity for reuse — same user + project + mount target → skip re-bootstrap. */\nexport function buildWebchatSessionKey(props: IsometrikWebchatInitProps): string {\n return [\n props.containerId || '__body__',\n props.isometrikUserId,\n props.userToken,\n props.projectId,\n props.accountId,\n props.keysetId,\n ].join('|');\n}\n\ntype RetainState = {\n count: number;\n sessionKey: string;\n instance: IsometrikWebchatInstance | null;\n pendingDestroy: ReturnType<typeof setTimeout> | null;\n};\n\nfunction getRetainState(): RetainState {\n if (typeof window === 'undefined') {\n return { count: 0, sessionKey: '', instance: null, pendingDestroy: null };\n }\n const w = window as any;\n if (!w.__isometrikChatRetain) {\n w.__isometrikChatRetain = {\n count: 0,\n sessionKey: '',\n instance: null,\n pendingDestroy: null,\n } as RetainState;\n }\n return w.__isometrikChatRetain;\n}\n\nfunction resolveThemeObject(props: IsometrikWebchatInitProps): Record<string, string> | undefined {\n const merged = { ...(props.themeObject || {}), ...(props.theme || {}) };\n const normalized = normalizeThemeObject(merged as Record<string, string>);\n return Object.keys(normalized).length ? normalized : undefined;\n}\n\nfunction applyOptionalBool(el: any, key: string, value: boolean | undefined) {\n if (value !== undefined) el[key] = value;\n}\n\nfunction isLiveInstance(instance: IsometrikWebchatInstance | null): boolean {\n if (!instance) return false;\n const { themeProvider, chatComponent } = instance;\n if (!themeProvider || !chatComponent) return false;\n // isConnected may be false in some test envs; also accept store match\n const store = getChatStore();\n return store.chatComponent === chatComponent && store.themeProvider === themeProvider;\n}\n\n/** Tear down existing chat instance (MQTT via disconnectedCallback, DOM). */\nexport function destroyIsometrikWebchat(): void {\n const retain = getRetainState();\n if (retain.pendingDestroy) {\n clearTimeout(retain.pendingDestroy);\n retain.pendingDestroy = null;\n }\n retain.count = 0;\n retain.sessionKey = '';\n retain.instance = null;\n\n destroyChatDom();\n document.querySelectorAll('theme-provider').forEach(el => {\n if (!el.querySelector('web-chat') && el.childNodes.length === 0) {\n el.remove();\n }\n });\n clearChatStore();\n}\n\n/** @deprecated Use destroyIsometrikWebchat */\nexport const destroyChat = destroyIsometrikWebchat;\n\n/**\n * Force mount: always tears down previous instance then creates a new one.\n * Prefer `retainIsometrikWebchat` / `ensureIsometrikWebchat` in React/SPA hosts\n * to avoid double bootstrap (Strict Mode / remount).\n */\nexport function initializeIsometrikWebchat(\n props: IsometrikWebchatInitProps,\n): IsometrikWebchatInstance | null {\n if (\n !props.licenseKey ||\n !props.appSecret ||\n !props.userSecret ||\n !props.userToken ||\n !props.isometrikUserId ||\n !props.projectId ||\n !props.keysetId ||\n !props.accountId\n ) {\n console.error('Missing required props to Initialize chat!');\n return null;\n }\n\n destroyIsometrikWebchat();\n\n const sessionKey = buildWebchatSessionKey(props);\n const themeProvider = document.createElement('theme-provider') as any;\n const themeUrl = props.themeUrl || DEFAULT_THEME_URL;\n const themeObject = resolveThemeObject(props);\n\n if (props.defaultTheme) {\n themeProvider.setAttribute('mode', props.defaultTheme);\n }\n themeProvider.setAttribute('theme-path', themeUrl);\n if (themeObject) {\n themeProvider.themeObject = themeObject;\n }\n\n const chatComponent = document.createElement('web-chat') as any;\n\n chatComponent.baseUrl = props.baseUrl || 'https://apis.isometrik.io';\n chatComponent.hostUrl = props.hostUrl || 'wss://connections.isometrik.io:2053/mqtt';\n chatComponent.licenseKey = props.licenseKey;\n chatComponent.appSecret = props.appSecret;\n chatComponent.userSecret = props.userSecret;\n chatComponent.userToken = props.userToken;\n chatComponent.isometrikUserId = props.isometrikUserId;\n chatComponent.projectId = props.projectId;\n chatComponent.keysetId = props.keysetId;\n chatComponent.accountId = props.accountId;\n chatComponent.defaultTheme = props.defaultTheme || 'light';\n chatComponent.themeUrl = themeUrl;\n\n chatComponent.style.width = '100%';\n chatComponent.style.height = '100%';\n\n if (props.customParts) {\n chatComponent.customParts = props.customParts;\n }\n\n applyOptionalBool(chatComponent, 'showProfileRail', resolveShowProfileRailProp(props));\n applyOptionalBool(chatComponent, 'showChatWallpaper', props.showChatWallpaper);\n applyOptionalBool(chatComponent, 'groupcastEnabled', props.groupcastEnabled);\n applyOptionalBool(chatComponent, 'showHeader', props.showHeader);\n applyOptionalBool(chatComponent, 'showComposer', props.showComposer);\n applyOptionalBool(chatComponent, 'showEmptyState', props.showEmptyState);\n applyOptionalBool(chatComponent, 'showConversationList', props.showConversationList);\n applyOptionalBool(chatComponent, 'showRightPanel', props.showRightPanel);\n applyOptionalBool(chatComponent, 'isSidebarHeaderSearch', props.isSidebarHeaderSearch);\n applyOptionalBool(chatComponent, 'showMqttStatus', props.showMqttStatus);\n\n setWebChatSlots(chatComponent, props.slots);\n\n themeProvider.appendChild(chatComponent);\n themeProvider.style.width = '100%';\n themeProvider.style.height = '100%';\n themeProvider.style.display = 'block';\n\n const container = props.containerId ? document.getElementById(props.containerId) : document.body;\n if (container) {\n container.appendChild(themeProvider);\n } else {\n console.error('Container with the specified ID not found. Appending to body instead.');\n document.body.appendChild(themeProvider);\n }\n\n setChatStore({ themeProvider, chatComponent });\n\n const api = createWebChatApi(chatComponent)!;\n const instance: IsometrikWebchatInstance = {\n themeProvider,\n chatComponent,\n api,\n sessionKey,\n destroy: destroyIsometrikWebchat,\n };\n\n const retain = getRetainState();\n retain.instance = instance;\n retain.sessionKey = sessionKey;\n retain.count = Math.max(retain.count, 1);\n\n return instance;\n}\n\n/**\n * Reuse live instance when session key matches (same user/token/container).\n * Otherwise mounts fresh. Does not bump retain count — use `retainIsometrikWebchat` in React.\n */\nexport function ensureIsometrikWebchat(\n props: IsometrikWebchatInitProps,\n): IsometrikWebchatInstance | null {\n const retain = getRetainState();\n if (retain.pendingDestroy) {\n clearTimeout(retain.pendingDestroy);\n retain.pendingDestroy = null;\n }\n\n const key = buildWebchatSessionKey(props);\n if (retain.sessionKey === key && isLiveInstance(retain.instance)) {\n return retain.instance;\n }\n return initializeIsometrikWebchat(props);\n}\n\n/**\n * React / SPA friendly: acquire a chat instance.\n * Pair with `releaseIsometrikWebchat` in effect cleanup.\n * Survives React 18 Strict Mode double-mount without a second bootstrap.\n */\nexport function retainIsometrikWebchat(\n props: IsometrikWebchatInitProps,\n): IsometrikWebchatInstance | null {\n const retain = getRetainState();\n if (retain.pendingDestroy) {\n clearTimeout(retain.pendingDestroy);\n retain.pendingDestroy = null;\n }\n retain.count += 1;\n return ensureIsometrikWebchat(props);\n}\n\n/**\n * Release a retain from `retainIsometrikWebchat`.\n * Destroy is deferred so Strict Mode remount can cancel it.\n * @param delayMs default 0 (macrotask) — enough for React 18 Strict Mode\n */\nexport function releaseIsometrikWebchat(delayMs: number = 0): void {\n const retain = getRetainState();\n retain.count = Math.max(0, retain.count - 1);\n if (retain.count > 0) return;\n\n if (retain.pendingDestroy) clearTimeout(retain.pendingDestroy);\n retain.pendingDestroy = setTimeout(() => {\n retain.pendingDestroy = null;\n if (retain.count > 0) return;\n destroyIsometrikWebchat();\n }, delayMs);\n}\n\n/** @deprecated Use initializeIsometrikWebchat */\nexport const initializeChat = initializeIsometrikWebchat;\n","/**\n * Headless REST helpers — same paths the shell uses.\n * Call session.init before other methods when not mounting <web-chat>.\n */\n\nimport {\n fetchConversationsPage,\n fetchConversationDetails,\n sortConversationsByLatestMessage,\n mergeUniqueConversations,\n fetchMessagesPage,\n markConversationRead,\n mergeMessagesById,\n searchMessages,\n fetchLinkMessages,\n fetchMediaCount,\n fetchMediaAttachments,\n filterMediaMessages,\n initializeChatSdk,\n fetchUserDetails,\n fetchGroupcastDetails,\n fetchGroupcastMembersPage,\n fetchGroupcastContactsPage,\n mediaTypeFromMime,\n customTypeFromMime,\n prepareMediaAttachments,\n buildReplyMetaData,\n type ChatSdkInitConfig,\n} from '../lib/chat';\n\nexport const isometrikWebchatApi = {\n session: {\n init: (config: ChatSdkInitConfig) => initializeChatSdk(config),\n fetchUserDetails,\n },\n conversations: {\n list: fetchConversationsPage,\n details: fetchConversationDetails,\n sortByLatest: sortConversationsByLatestMessage,\n mergeUnique: mergeUniqueConversations,\n },\n messages: {\n list: fetchMessagesPage,\n markRead: markConversationRead,\n mergeById: mergeMessagesById,\n search: searchMessages,\n links: fetchLinkMessages,\n mediaCount: fetchMediaCount,\n mediaAttachments: fetchMediaAttachments,\n filterMedia: filterMediaMessages,\n },\n groupcast: {\n details: fetchGroupcastDetails,\n members: fetchGroupcastMembersPage,\n contacts: fetchGroupcastContactsPage,\n },\n media: {\n mediaTypeFromMime,\n customTypeFromMime,\n prepareMediaAttachments,\n buildReplyMetaData,\n },\n};\n\nexport type IsometrikWebchatApi = typeof isometrikWebchatApi;\n","/**\n * React → WebChat bridge (no React dependency in this package).\n *\n * Hosts pass their own `createElement` + `createRoot` so the core SDK stays\n * framework-agnostic.\n *\n * 1) Panels (slots): mountReactInSlot → HTMLElement for `slots['profile-rail']`\n * 2) Rows/overlays (customParts): defineReactCustomPart → CE tag for customParts\n */\n\nimport type { WebChatSlotName } from '../lib/custom-ui';\nimport { createSlotHost } from './slots';\n\nexport type ReactLike = {\n createElement: (type: any, props: any, ...children: any[]) => any;\n};\n\nexport type ReactRootLike = {\n render: (node: any) => void;\n unmount: () => void;\n};\n\nexport type CreateRootLike = (container: Element) => ReactRootLike;\n\ntype BridgeRootStore = {\n root: ReactRootLike;\n Component: any;\n extraProps?: Record<string, unknown>;\n};\n\nconst ROOT_KEY = '__isometrikReactBridge';\n\nfunction paint(store: BridgeRootStore, react: ReactLike, propsFromHost: Record<string, unknown>) {\n store.root.render(\n react.createElement(store.Component, {\n ...(store.extraProps || {}),\n ...propsFromHost,\n }),\n );\n}\n\n/**\n * Wrap a React component as a custom element for `customParts`.\n * SDK assigns props (conversation, onSelect, …); we re-render React.\n *\n * @example\n * import { createElement } from 'react';\n * import { createRoot } from 'react-dom/client';\n * defineReactCustomPart('app-chat-tile', MyTile, {\n * react: { createElement },\n * createRoot,\n * propKeys: ['conversation', 'isSelected', 'unreadCount', 'previewText', 'onSelect'],\n * });\n * initializeIsometrikWebchat({ customParts: { chatTile: 'app-chat-tile' }, … });\n */\nexport function defineReactCustomPart(\n tag: string,\n Component: any,\n opts: {\n react: ReactLike;\n createRoot: CreateRootLike;\n /** Prop names the SDK writes on the CE (see lib/custom-ui/contracts.ts). */\n propKeys: string[];\n /** Static props merged into every render. */\n extraProps?: Record<string, unknown>;\n },\n): string {\n if (typeof customElements === 'undefined') return tag;\n if (customElements.get(tag)) return tag;\n\n const { react, createRoot, propKeys, extraProps } = opts;\n\n class ReactPart extends HTMLElement {\n private _store: BridgeRootStore | null = null;\n\n connectedCallback() {\n if (!this._store) {\n this._store = { root: createRoot(this), Component, extraProps };\n }\n this.render();\n }\n\n disconnectedCallback() {\n try {\n this._store?.root.unmount();\n } catch {\n /* unmount is best-effort */\n }\n this._store = null;\n }\n\n /** Called by applyCustomPartProps after Object.assign. */\n render() {\n if (!this._store || !this.isConnected) return;\n const fromSetters: Record<string, unknown> = {};\n propKeys.forEach(key => {\n fromSetters[key] = (this as any)[`_${key}`];\n });\n paint(this._store, react, fromSetters);\n }\n }\n\n propKeys.forEach(key => {\n const store = `_${key}`;\n Object.defineProperty(ReactPart.prototype, key, {\n get() {\n return (this as any)[store];\n },\n set(value) {\n if ((this as any)[store] === value) return;\n (this as any)[store] = value;\n if (this.isConnected) (this as HTMLElement & { render: () => void }).render();\n },\n configurable: true,\n });\n });\n\n customElements.define(tag, ReactPart);\n return tag;\n}\n\nexport type ReactSlotHost = HTMLElement & {\n updateProps: (props: Record<string, unknown>) => void;\n unmount: () => void;\n};\n\n/**\n * Mount a React component into a slot host for panel overrides.\n * Pass the returned element in `slots: { 'profile-rail': el }`.\n *\n * @example\n * const rail = mountReactInSlot('profile-rail', MyProfileRail, {\n * react: { createElement },\n * createRoot,\n * props: { userId: '…' },\n * });\n * initializeIsometrikWebchat({ slots: { 'profile-rail': rail }, … });\n * // later: rail.updateProps({ badge: 3 }); rail.unmount();\n */\nexport function mountReactInSlot(\n slotName: WebChatSlotName,\n Component: any,\n opts: {\n react: ReactLike;\n createRoot: CreateRootLike;\n props?: Record<string, unknown>;\n className?: string;\n },\n): ReactSlotHost {\n const host = createSlotHost(slotName, opts.className) as ReactSlotHost;\n // display:contents can break React roots — use block for React mounts.\n host.style.display = 'block';\n host.style.height = '100%';\n\n const store: BridgeRootStore = {\n root: opts.createRoot(host),\n Component,\n extraProps: opts.props,\n };\n (host as any)[ROOT_KEY] = store;\n paint(store, opts.react, {});\n\n host.updateProps = (next: Record<string, unknown>) => {\n store.extraProps = { ...(store.extraProps || {}), ...next };\n paint(store, opts.react, {});\n };\n host.unmount = () => {\n try {\n store.root.unmount();\n } catch {\n /* ignore */\n }\n delete (host as any)[ROOT_KEY];\n };\n return host;\n}\n\nexport function unmountReactSlot(host: HTMLElement | null | undefined): void {\n if (!host) return;\n const anyHost = host as ReactSlotHost;\n if (typeof anyHost.unmount === 'function') {\n anyHost.unmount();\n return;\n }\n const store = (host as any)[ROOT_KEY] as BridgeRootStore | undefined;\n if (!store) return;\n try {\n store.root.unmount();\n } catch {\n /* ignore */\n }\n delete (host as any)[ROOT_KEY];\n}\n","/**\n * Theme / sidebar controls — instance-first (no bare querySelector in happy path).\n */\n\nimport { normalizeThemeObject } from './theme-tokens';\nimport { resolveThemeProvider, resolveWebChat } from './instance';\n\nexport function customChatSidebar(\n props: { isChatFilter?: boolean },\n from?: Element | null,\n): void {\n const chatComponent = resolveWebChat(from) as any;\n if (!chatComponent) {\n console.error('Isometrik chat is not initialized');\n return;\n }\n if (props.isChatFilter !== undefined) {\n chatComponent.isChatFilter = props.isChatFilter;\n }\n}\n\nexport function switchChatTheme(theme: 'dark' | 'light', from?: Element | null): void {\n const themeProvider = resolveThemeProvider(from) as any;\n const chat = resolveWebChat(from) as any;\n\n if (chat) {\n chat.defaultTheme = theme;\n }\n if (themeProvider) {\n themeProvider.setAttribute('mode', theme);\n if (typeof themeProvider.setTheme === 'function') {\n themeProvider.setTheme(theme);\n }\n return;\n }\n console.error('Theme provider is not initialized');\n}\n\nexport function applyCustomTheme(\n customTheme: {\n themePath?: string;\n themeObject?: { [key: string]: string };\n },\n from?: Element | null,\n): void {\n const themeProvider = resolveThemeProvider(from) as any;\n if (!themeProvider) {\n console.error('Theme provider is not initialized');\n return;\n }\n\n if (customTheme.themePath) {\n themeProvider.setAttribute('theme-path', customTheme.themePath);\n }\n\n if (customTheme.themeObject) {\n themeProvider.themeObject = normalizeThemeObject(customTheme.themeObject);\n }\n}\n\nexport function toggleTheme(from?: Element | null): void {\n const themeProvider = resolveThemeProvider(from) as any;\n if (!themeProvider) {\n console.error('Theme provider is not initialized');\n return;\n }\n if (typeof themeProvider.toggleTheme === 'function') {\n themeProvider.toggleTheme();\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,a as i,h as s,g as e}from"./p-17a96a2a.js";import{h as n}from"./p-9982fa21.js";import{r,e as h}from"./p-d28c5548.js";import{i as o,j as a,k as c,l}from"./p-a5707f12.js";import"./p-5162774c.js";class u{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 d extends u{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 f=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};function p(t,i){return f(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 g(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 v(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")}g(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 b={decode:p,createBuffer:v};function m(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(m(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 y(t,i,s){const e=m(t,i||{});s===null||s===void 0?void 0:s.appendChild(e);return e}function x(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:y,isHTMLElement:x,default:y});var w=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};function N(t,i,s){return w(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 h=0;const o=()=>{n.cancel()};if(s){if(s.aborted){n.cancel();return}s.addEventListener("abort",o,{once:true})}try{while(true){const t=yield n.read();if(t.done){break}h+=((e=t.value)===null||e===void 0?void 0:e.length)||0;if(r>0){const t=Math.round(h/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",o)}}}))}function T(t,i,s){return w(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})`)}N(n.clone(),i,(e=s===null||s===void 0?void 0:s.signal)!==null&&e!==void 0?e:undefined);return n.blob()}))}const k={fetchBlob:T};function D(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 j(t,i){const s=D(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 S(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 I=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};class E extends u{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=D(false);this._currentTime=D(0);this._duration=D(0);this._volume=D(this.media.volume);this._muted=D(this.media.muted);this._playbackRate=D(this.media.playbackRate||1);this._seeking=D(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 I(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 C=128;const A=8e3;const L=10;function z(t){if(t<0)return 0;if(t>1)return 1;return t}function P({width:t,height:i,length:s,options:e,pixelRatio:n}){const r=i/2;const h=e.barWidth?e.barWidth*n:1;const o=e.barGap?e.barGap*n:e.barWidth?h/2:0;const a=e.barRadius||0;const c=e.barMinHeight?e.barMinHeight*n:0;const l=h+o||1;const u=s>0?t/l/s:0;return{halfHeight:r,barWidth:h,barGap:o,barRadius:a,barMinHeight:c,barIndexScale:u,barSpacing:l}}function O({maxTop:t,maxBottom:i,halfHeight:s,vScale:e,barMinHeight:n=0,barAlign:r}){let h=Math.round(t*s*e);const o=Math.round(i*s*e);let a=h+o||1;if(a<n){a=n;if(!r){h=a/2}}return{topHeight:h,totalHeight:a}}function R({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 W({channelData:t,barIndexScale:i,barSpacing:s,barWidth:e,halfHeight:n,vScale:r,canvasHeight:h,barAlign:o,barMinHeight:a}){const c=t[0]||[];const l=t[1]||c;const u=c.length;const d=[];let f=0;let p=0;let g=0;for(let t=0;t<=u;t++){const u=Math.round(t*i);if(u>f){const{topHeight:t,totalHeight:i}=O({maxTop:p,maxBottom:g,halfHeight:n,vScale:r,barMinHeight:a,barAlign:o});const c=R({barAlign:o,halfHeight:n,topHeight:t,totalHeight:i,canvasHeight:h});d.push({x:f*s,y:c,width:e,height:i});f=u;p=0;g=0}const v=Math.abs(c[t]||0);const b=Math.abs(l[t]||0);if(v>p)p=v;if(b>g)g=b}return d}function U(t,i,s){const e=i-t.left;const n=s-t.top;const r=e/t.width;const h=n/t.height;return[r,h]}function H({optionsHeight:t,optionsSplitChannels:i,parentHeight:s,numberOfChannels:e,defaultHeight:n=C}){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 V(t){return Math.max(1,t||1)}function Y(t){return Boolean(t.barWidth||t.barGap||t.barAlign)}function F(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 h=n.createLinearGradient(0,0,0,r);const o=1/(t.length-1);t.forEach(((t,i)=>{h.addColorStop(i*o,t)}));return h}function Q({duration:t,minPxPerSec:i=0,parentWidth:s,fillParent:e,pixelRatio:n}){const r=Math.ceil(t*i);const h=r>s;const o=Boolean(e&&!h);const a=(o?s:r)*n;return{scrollWidth:r,isScrollable:h,useParentWidth:o,width:a}}function $(t,i){if(!Y(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 B({clientWidth:t,totalWidth:i,options:s}){const e=Math.min(A,t,i);return $(e,s)}function _({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 Z(t){return t>L}function G({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 X({channelData:t,barHeight:i,normalize:s,maxPeak:e}){var n;const r=i||1;if(!s)return r;const h=t[0];if(!h||h.length===0)return r;let o=e!==null&&e!==void 0?e:0;if(!e){for(let t=0;t<h.length;t++){const i=(n=h[t])!==null&&n!==void 0?n:0;const s=Math.abs(i);if(s>o)o=s}}if(!o)return r;return r/o}function q({channelData:t,width:i,height:s,vScale:e}){const n=s/2;const r=t[0]||[];const h=t[1]||r;const o=[r,h];return o.map(((t,s)=>{const r=t.length;const h=r?i/r:0;const o=n;const a=s===0?-1:1;const c=[{x:0,y:o}];let l=0;let u=0;for(let i=0;i<=r;i++){const s=Math.round(i*h);if(s>l){const t=Math.round(u*n*e)||1;const i=o+t*a;c.push({x:l,y:i});l=s;u=0}const r=Math.abs(t[i]||0);if(r>u)u=r}c.push({x:l,y:o});return c}))}function J(t){const i=t*2;const s=i<0?Math.floor(i):Math.ceil(i);return s/2}function K(t){const i=t._cleanup;if(typeof i==="function"){i()}}function tt(t,i={}){const{threshold:s=3,mouseButton:e=0,touchDelay:n=100}=i;const r=D(null);const h=new Map;const o=matchMedia("(pointer: coarse)").matches;let a=()=>void 0;const c=i=>{if(i.button!==e)return;if(h.has(i.pointerId))return;h.set(i.pointerId,i);if(h.size>1){return}const c=i.pointerId;let l=i.clientX;let u=i.clientY;let d=false;const f=Date.now();const p=t.getBoundingClientRect();const{left:g,top:v}=p;const b=t=>{if(t.pointerId!==c)return;if(t.defaultPrevented||h.size>1){return}if(o&&Date.now()-f<n)return;const i=t.clientX;const e=t.clientY;const a=i-l;const p=e-u;if(d||Math.abs(a)>s||Math.abs(p)>s){t.preventDefault();t.stopPropagation();if(!d){r.set({type:"start",x:l-g,y:u-v});d=true}r.set({type:"move",x:i-g,y:e-v,deltaX:a,deltaY:p});l=i;u=e}};const m=t=>{if(!h.delete(t.pointerId))return;if(t.pointerId===c&&d){const i=t.clientX;const s=t.clientY;r.set({type:"end",x:i-g,y:s-v})}if(h.size===0){a()}};const y=t=>{if(!t.relatedTarget||t.relatedTarget===document.documentElement){m(t)}};const x=t=>{if(d){t.stopPropagation();t.preventDefault()}};const M=t=>{if(t.defaultPrevented||h.size>1){return}if(d){t.preventDefault()}};document.addEventListener("pointermove",b);document.addEventListener("pointerup",m);document.addEventListener("pointerout",y);document.addEventListener("pointercancel",y);document.addEventListener("touchmove",M,{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",M);setTimeout((()=>{document.removeEventListener("click",x,{capture:true})}),10)}};t.addEventListener("pointerdown",c);const l=()=>{a();t.removeEventListener("pointerdown",c);h.clear();K(r)};return{signal:r,cleanup:l}}function it(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 st(t){return{left:t.scrollLeft,right:t.scrollLeft+t.clientWidth}}function et(t){const i=D({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth});const s=j((()=>it(i.value)),[i]);const e=j((()=>st(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);K(i)};return{scrollData:i,percentages:s,bounds:e,cleanup:r}}var nt=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};var rt=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 ht=60;const ot=10;const at=ot*ht;class ct extends u{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]=U(i,t.clientX,t.clientY);this.emit("click",s,e)};this.onDblClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=U(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(x(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=et(this.scrollContainer);const t=S((()=>{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=tt(this.wrapper);const t=S((()=>{const t=this.dragStream.signal.value;if(!t)return;const i=this.wrapper.getBoundingClientRect().width;const s=z(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 H({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:e,defaultHeight:C})}convertColorValues(t,i){return F(t,this.getPixelRatio(),i===null||i===void 0?void 0:i.canvas.height)}getPixelRatio(){return V(window.devicePixelRatio)}renderBarWaveform(t,i,s,e){const{width:n,height:r}=s.canvas;const{halfHeight:h,barWidth:o,barRadius:a,barIndexScale:c,barSpacing:l,barMinHeight:u}=P({width:n,height:r,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()});const d=W({channelData:t,barIndexScale:c,barSpacing:l,barWidth:o,halfHeight:h,vScale:e,canvasHeight:r,barAlign:i.barAlign,barMinHeight:u});s.beginPath();for(const t of d){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 h=q({channelData:t,width:n,height:r,vScale:e});s.beginPath();for(const t of h){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=X({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});if(Y(i)){this.renderBarWaveform(t,i,s,e);return}this.renderLineWaveform(t,i,s,e)}renderSingleCanvas(t,i,s,e,n,r,h){const o=this.getPixelRatio();const a=document.createElement("canvas");a.width=Math.round(s*o);a.height=Math.round(e*o);a.style.width=`${s}px`;a.style.height=`${e}px`;a.style.left=`${Math.round(n)}px`;r.appendChild(a);const c=a.getContext("2d");if(i.renderFunction){c.fillStyle=this.convertColorValues(i.waveColor,c);i.renderFunction(t,c)}else{this.renderWaveform(t,i,c)}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);h.appendChild(t)}}renderMultiCanvas(t,i,s,e,n,r){const h=this.getPixelRatio();const{clientWidth:o}=this.scrollContainer;const a=s/h;const c=B({clientWidth:o,totalWidth:a,options:i});let l={};if(c===0)return;const u=s=>{if(s<0||s>=f)return;if(l[s])return;l[s]=true;const h=s*c;let o=Math.min(a-h,c);o=$(o,i);if(o<=0)return;const u=_({channelData:t,offset:h,clampedWidth:o,totalWidth:a});this.renderSingleCanvas(u,i,o,e,h,n,r)};const d=()=>{if(Z(Object.keys(l).length)){n.innerHTML="";r.innerHTML="";l={}}};const f=Math.ceil(a/c);if(!this.isScrollable){for(let t=0;t<f;t++){u(t)}return}const p=G({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:a,numCanvases:f});p.forEach((t=>u(t)));if(f>1){const t=this.on("scroll",(()=>{const{scrollLeft:t}=this.scrollContainer;d();G({scrollLeft:t,totalWidth:a,numCanvases:f}).forEach((t=>u(t)))}));this.unsubscribeOnScroll.push(t)}}renderChannel(t,i,s,e){var{overlay:n}=i,r=rt(i,["overlay"]);const h=document.createElement("div");const o=this.getHeight(r.height,r.splitChannels);h.style.height=`${o}px`;if(n&&e>0){h.style.marginTop=`-${o}px`}this.canvasWrapper.style.minHeight=`${o}px`;this.canvasWrapper.appendChild(h);const a=h.cloneNode();this.progressWrapper.appendChild(a);this.renderMultiCanvas(t,r,s,o,h,a)}render(t){return nt(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:h,width:o}=Q({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:e,fillParent:this.options.fillParent,pixelRatio:s});this.isScrollable=r;this.wrapper.style.width=h?"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,o,s)}}else{const i=[t.getChannelData(0)];if(t.numberOfChannels>1)i.push(t.getChannelData(1));this.renderChannel(i,this.options,o,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=J(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 h=t*n;const o=e;const a=e+r;const c=r/2;if(this.isDragging){const t=30;if(h+t>a){this.scrollContainer.scrollLeft+=t}else if(h-t<o){this.scrollContainer.scrollLeft-=t}}else{if(h<o||h>a){this.scrollContainer.scrollLeft=h-(this.options.autoCenter?c:0)}const t=h-e-c;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<=at){this.scrollContainer.scrollLeft+=Math.min(t,ot)}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 nt(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 lt extends u{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 ut=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};function dt(){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 ft extends u{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;dt();this.audioContext=t||new AudioContext;this.gainNode=this.audioContext.createGain();this.gainNode.connect(this.audioContext.destination)}load(){return ut(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 ut(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 ut(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 pt(t){var i,s,e,n,r,h;const o=(i=t===null||t===void 0?void 0:t.currentTime)!==null&&i!==void 0?i:D(0);const a=(s=t===null||t===void 0?void 0:t.duration)!==null&&s!==void 0?s:D(0);const c=(e=t===null||t===void 0?void 0:t.isPlaying)!==null&&e!==void 0?e:D(false);const l=(n=t===null||t===void 0?void 0:t.isSeeking)!==null&&n!==void 0?n:D(false);const u=(r=t===null||t===void 0?void 0:t.volume)!==null&&r!==void 0?r:D(1);const d=(h=t===null||t===void 0?void 0:t.playbackRate)!==null&&h!==void 0?h:D(1);const f=D(null);const p=D(null);const g=D("");const v=D(0);const b=D(0);const m=j((()=>!c.value),[c]);const y=j((()=>f.value!==null),[f]);const x=j((()=>y.value&&a.value>0),[y,a]);const M=j((()=>o.value),[o]);const w=j((()=>a.value>0?o.value/a.value:0),[o,a]);const N={currentTime:o,duration:a,isPlaying:c,isPaused:m,isSeeking:l,volume:u,playbackRate:d,audioBuffer:f,peaks:p,url:g,zoom:v,scrollPosition:b,canPlay:y,isReady:x,progress:M,progressPercent:w};const T={setCurrentTime:t=>{const i=Math.max(0,Math.min(a.value||Infinity,t));o.set(i)},setDuration:t=>{a.set(Math.max(0,t))},setPlaying:t=>{c.set(t)},setSeeking:t=>{l.set(t)},setVolume:t=>{const i=Math.max(0,Math.min(1,t));u.set(i)},setPlaybackRate:t=>{const i=Math.max(.1,Math.min(16,t));d.set(i)},setAudioBuffer:t=>{f.set(t);if(t){a.set(t.duration)}},setPeaks:t=>{p.set(t)},setUrl:t=>{g.set(t)},setZoom:t=>{v.set(Math.max(0,t))},setScrollPosition:t=>{b.set(Math.max(0,t))}};return{state:N,actions:T}}var gt=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};const vt={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:true,interact:true,dragToSeek:false,autoScroll:true,autoCenter:true,sampleRate:8e3};class bt extends E{static create(t){return new bt(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new ft: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({},vt,t);const{state:s,actions:e}=pt({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 lt;const n=i?undefined:this.getMediaElement();this.renderer=new ct(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=b.createBuffer(this.exportPeaks(),t.duration)}if(t.peaks&&t.duration){this.decodedData=b.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 gt(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 k.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 h=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 ft){t.duration=h}}if(s){this.decodedData=b.createBuffer(s,h||0)}else if(i){const t=yield i.arrayBuffer();if(this._isDestroyed||r!==this._loadVersion)return;this.decodedData=yield b.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 gt(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 gt(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 h=e.length/i;for(let t=0;t<i;t++){const i=e.slice(Math.floor(t*h),Math.ceil((t+1)*h));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 gt(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 ft){this.media.stopAt(i)}else{this.stopAtPosition=i}}return e}))}playPause(){return gt(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 gt(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()}}bt.BasePlugin=d;bt.dom=M;function mt(t,i,s,e){return new(s||(s=Promise))((function(n,r){function h(t){try{a(e.next(t))}catch(t){r(t)}}function o(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(h,o)}a((e=e.apply(t,i||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class yt{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 xt extends yt{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 yt{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 wt=100,Nt=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class Tt extends xt{constructor(t){var i,s,e,n,r,h;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!==(h=t.mediaRecorderTimeslice)&&void 0!==h?h: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 Tt(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,h=new Float32Array(r);let o=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(h),this.options.scrollingWaveform){const t=Math.floor((this.options.scrollingWaveformWindow||0)*wt);let i=0;for(let t=0;t<r;t++){const s=Math.abs(h[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*wt):(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(h[t]);i>s&&(s=i)}if(o+1>this.dataWindow.length){const t=new Float32Array(2*this.dataWindow.length);t.set(this.dataWindow,0),this.dataWindow=t}this.dataWindow[o]=s,o++}else this.dataWindow=h;if(this.wavesurfer){const t=(null!==(e=null===(s=this.dataWindow)||void 0===s?void 0:s.length)&&void 0!==e?e:0)/wt;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 mt(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 mt(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||Nt.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 mt(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 kt=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 bt!=="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=this.resolveWaveColor();this.wavesurfer=bt.create({container:this.waveformContainer,waveColor:s,progressColor:s,height:28,width:i,barWidth:2,barGap:2,barRadius:2,interact:false,cursorWidth:0});this.recordPlugin=this.wavesurfer.registerPlugin(Tt.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;const i=((t=this.waveformContainer)===null||t===void 0?void 0:t.clientWidth)||this.el.clientWidth;if(i&&this.wavesurfer){try{this.wavesurfer.setOptions({width:i})}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=bt.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:"670b82c67119d4d4c74867a94b4737c16dd8cf57",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:"b797e83c979987e4d1d616cfc1507bb5cf177333",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:"8f0dc7991e61e5f534dff91d6c54e31d6287197b",class:"wave-host",ref:t=>{this.waveformContainer=t},style:{flex:"1",height:t?"28px":"40px",minHeight:t?"28px":"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"]}}};kt.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 min-height: 28px;\n }";const Dt="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNS42MjUgMTVDNS42MjUgMTQuNTg1OCA1LjI4OTIxIDE0LjI1IDQuODc1IDE0LjI1QzQuNDYwNzkgMTQuMjUgNC4xMjUgMTQuNTg1OCA0LjEyNSAxNUg1LjYyNVpNNC44NzUgMTZINC4xMjVINC44NzVaTTE5LjI3NSAxNUMxOS4yNzUgMTQuNTg1OCAxOC45MzkyIDE0LjI1IDE4LjUyNSAxNC4yNUMxOC4xMTA4IDE0LjI1IDE3Ljc3NSAxNC41ODU4IDE3Ljc3NSAxNUgxOS4yNzVaTTExLjEwODYgMTUuNTM4N0MxMC44NTM5IDE1Ljg2NTMgMTAuOTEyMSAxNi4zMzY2IDExLjIzODcgMTYuNTkxNEMxMS41NjUzIDE2Ljg0NjEgMTIuMDM2NiAxNi43ODc5IDEyLjI5MTQgMTYuNDYxM0wxMS4xMDg2IDE1LjUzODdaTTE2LjE5MTQgMTEuNDYxM0MxNi40NDYxIDExLjEzNDcgMTYuMzg3OSAxMC42NjM0IDE2LjA2MTMgMTAuNDA4NkMxNS43MzQ3IDEwLjE1MzkgMTUuMjYzNCAxMC4yMTIxIDE1LjAwODYgMTAuNTM4N0wxNi4xOTE0IDExLjQ2MTNaTTExLjEwODYgMTYuNDYxM0MxMS4zNjM0IDE2Ljc4NzkgMTEuODM0NyAxNi44NDYxIDEyLjE2MTMgMTYuNTkxNEMxMi40ODc5IDE2LjMzNjYgMTIuNTQ2MSAxNS44NjUzIDEyLjI5MTQgMTUuNTM4N0wxMS4xMDg2IDE2LjQ2MTNaTTguMzkxMzggMTAuNTM4N0M4LjEzNjYyIDEwLjIxMjEgNy42NjUzMyAxMC4xNTM5IDcuMzM4NzMgMTAuNDA4NkM3LjAxMjEyIDEwLjY2MzQgNi45NTM4NyAxMS4xMzQ3IDcuMjA4NjIgMTEuNDYxM0w4LjM5MTM4IDEwLjUzODdaTTEwLjk1IDE2QzEwLjk1IDE2LjQxNDIgMTEuMjg1OCAxNi43NSAxMS43IDE2Ljc1QzEyLjExNDIgMTYuNzUgMTIuNDUgMTYuNDE0MiAxMi40NSAxNkgxMC45NVpNMTIuNDUgNUMxMi40NSA0LjU4NTc5IDEyLjExNDIgNC4yNSAxMS43IDQuMjVDMTEuMjg1OCA0LjI1IDEwLjk1IDQuNTg1NzkgMTAuOTUgNUgxMi40NVpNNC4xMjUgMTVWMTZINS42MjVWMTVINC4xMjVaTTQuMTI1IDE2QzQuMTI1IDE4LjA1MzEgNS43NTI1NyAxOS43NSA3LjggMTkuNzVWMTguMjVDNi42MTY1NyAxOC4yNSA1LjYyNSAxNy4yNjA3IDUuNjI1IDE2SDQuMTI1Wk03LjggMTkuNzVIMTUuNlYxOC4yNUg3LjhWMTkuNzVaTTE1LjYgMTkuNzVDMTcuNjQ3NCAxOS43NSAxOS4yNzUgMTguMDUzMSAxOS4yNzUgMTZIMTcuNzc1QzE3Ljc3NSAxNy4yNjA3IDE2Ljc4MzQgMTguMjUgMTUuNiAxOC4yNVYxOS43NVpNMTkuMjc1IDE2VjE1SDE3Ljc3NVYxNkgxOS4yNzVaTTEyLjI5MTQgMTYuNDYxM0wxNi4xOTE0IDExLjQ2MTNMMTUuMDA4NiAxMC41Mzg3TDExLjEwODYgMTUuNTM4N0wxMi4yOTE0IDE2LjQ2MTNaTTEyLjI5MTQgMTUuNTM4N0w4LjM5MTM4IDEwLjUzODdMNy4yMDg2MiAxMS40NjEzTDExLjEwODYgMTYuNDYxM0wxMi4yOTE0IDE1LjUzODdaTTEyLjQ1IDE2VjVIMTAuOTVWMTZIMTIuNDVaIiBmaWxsPSIjMDAwMDAwIi8+Cjwvc3ZnPg==";const jt=Dt;const St=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 o;if(t.includes("spreadsheet")||t.includes("excel")||/\.xlsx?$/.test(i)||i.endsWith(".csv"))return a;if(t.includes("rtf")||i.endsWith(".rtf"))return c;if(t.includes("text/plain")||i.endsWith(".txt"))return l;return o}render(){const t=this.truncateDocName(this.docName||"Document");const i=this.message&&!String(this.message).includes("AttachmentMessage:");const e=this.isPdf();return s("message-bubble",{key:"b6ace1cd0668f471bf64d89d3d7861955411c8ec",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",{key:"96fefa9df08407f2df4be3b72af9dbf5873fe928",class:"doc-container",style:{backgroundColor:this.documentNameBg||"var(--bg-tertiary)",width:this.width||"auto"}},s("div",{key:"e3c866721409745fe12168f5ae0fa53a31527b3b",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",{key:"70247e85e8d862ed0f475650df7d3fd299d58c77",class:"attachment-icon"},s("img",{key:"9d234ea89459c3385086fe17abfcfaa037753c2f",src:this.iconSrc(),alt:""})),s("span",{key:"8c35191f12fbcd1ee972703296059c4ab1b666d9"},t.firstLine,s("br",{key:"4b206833e3181384fbeb683d0459b8a03a285be4"}),t.secondLine)),s("div",{key:"0cb86e8a218cc577287e9be3589a1cd4441a685c",class:"doc-actions"},e&&this.href?s("button",{class:"preview-btn",type:"button",onClick:this.openPreview,"aria-label":"Preview PDF"},"View"):null,s("a",{key:"3351a7680f4f71cd0c05b8b4bb462bfdc4b6b948",class:"download-btn",href:this.href,download:this.fileName,target:"_blank",rel:"noopener noreferrer","aria-label":"Download"},s("img",{key:"30d9286c55c66a6944c46d68fdb9098cb1a31a75",src:jt,alt:""})))),i?s("div",{style:{fontSize:"8px",color:this.textColor,marginTop:"4px"}},r(this.message,this.mentionedUsers,(t=>h(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)}};St.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 It=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.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.imageSrc=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:"b3c7b9f8e05923e0955bff3e8f71740baf5e42b7"},s("message-bubble",{key:"7bca9fc47d0dde8e111bdc445a3fa65a90322def",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:"fb3cf820d1ba04c2e73024700016660ddcffee3a",class:"image-container",style:{width:this.width||"250px",height:this.height||"220px",borderRadius:this.borderRadius},onClick:this.openGallery},s("img",{key:"883f683d9833d06ae7c1c7a375ac3208385cc8c7",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=>h(this.tagUserClick,t)),!!this.isSelf)):null),this.galleryOpen?s("div",{class:"gallery-overlay",onClick:()=>this.galleryOpen=false},s("button",{type:"button",class:"gallery-close","aria-label":"Close"},"×"),s("img",{src:this.imageSrc,alt:"full",onClick:t=>t.stopPropagation()})):null)}};It.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; align-items: center; justify-content: center;\n }\n .gallery-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; }\n .gallery-close {\n position: absolute; top: var(--space-16); right: var(--space-16);\n color: var(--text-on-brand); font-size: var(--text-24);\n background: transparent; border: none; cursor: pointer;\n }";const Et=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.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.videoSrc=undefined;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}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("message-bubble",{key:"7b545b4022480c31b4e71a14d5e1bb61de4bd5c8",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:"8295b66f4967e0ef5f34687cd6b7e524aba43b7f",class:"video-wrap"},s("video",{key:"a768a37cc340fabe46885fd33aaf8012f3d05dd3",style:{height:this.height||"150px",width:this.width||"150px",objectFit:"cover",borderRadius:this.borderRadius||"8px"},onClick:this.toggle},s("source",{key:"8a241e2002f7a857837d5ef83d91393e950fa4bd",src:this.videoSrc,type:this.videoType||"video/mp4"})),s("div",{key:"24fb30b390b6a315a1dbc9a3651cc670d3419cbf",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:"190a151c404aabfebd7157e23bd3691e65ab678b",type:"button",class:"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=>h(this.tagUserClick,t)),!!this.isSelf)):null)}get el(){return e(this)}};Et.style=":host { display: block; position: relative; }\n .video-wrap { position: relative; width: fit-content; }\n .controls {\n position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; 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_fullscreen { position: absolute; right: 8px; bottom: 8px; }";export{kt as audio_bubble,St as document_message,It as image_message,Et as video_message};
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{r as t,a as i,h as s,g as e}from"./p-17a96a2a.js";import{h as n}from"./p-9982fa21.js";import{r,e as h}from"./p-d28c5548.js";import{i as o,j as a,k as c,l}from"./p-a5707f12.js";import"./p-5162774c.js";class u{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 d extends u{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 f=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};function p(t,i){return f(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 g(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 v(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")}g(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 b={decode:p,createBuffer:v};function m(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(m(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 y(t,i,s){const e=m(t,i||{});s===null||s===void 0?void 0:s.appendChild(e);return e}function x(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:y,isHTMLElement:x,default:y});var w=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};function N(t,i,s){return w(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 h=0;const o=()=>{n.cancel()};if(s){if(s.aborted){n.cancel();return}s.addEventListener("abort",o,{once:true})}try{while(true){const t=yield n.read();if(t.done){break}h+=((e=t.value)===null||e===void 0?void 0:e.length)||0;if(r>0){const t=Math.round(h/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",o)}}}))}function T(t,i,s){return w(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})`)}N(n.clone(),i,(e=s===null||s===void 0?void 0:s.signal)!==null&&e!==void 0?e:undefined);return n.blob()}))}const k={fetchBlob:T};function D(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 j(t,i){const s=D(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 S(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 I=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};class E extends u{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=D(false);this._currentTime=D(0);this._duration=D(0);this._volume=D(this.media.volume);this._muted=D(this.media.muted);this._playbackRate=D(this.media.playbackRate||1);this._seeking=D(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 I(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 C=128;const A=8e3;const L=10;function z(t){if(t<0)return 0;if(t>1)return 1;return t}function P({width:t,height:i,length:s,options:e,pixelRatio:n}){const r=i/2;const h=e.barWidth?e.barWidth*n:1;const o=e.barGap?e.barGap*n:e.barWidth?h/2:0;const a=e.barRadius||0;const c=e.barMinHeight?e.barMinHeight*n:0;const l=h+o||1;const u=s>0?t/l/s:0;return{halfHeight:r,barWidth:h,barGap:o,barRadius:a,barMinHeight:c,barIndexScale:u,barSpacing:l}}function O({maxTop:t,maxBottom:i,halfHeight:s,vScale:e,barMinHeight:n=0,barAlign:r}){let h=Math.round(t*s*e);const o=Math.round(i*s*e);let a=h+o||1;if(a<n){a=n;if(!r){h=a/2}}return{topHeight:h,totalHeight:a}}function R({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 W({channelData:t,barIndexScale:i,barSpacing:s,barWidth:e,halfHeight:n,vScale:r,canvasHeight:h,barAlign:o,barMinHeight:a}){const c=t[0]||[];const l=t[1]||c;const u=c.length;const d=[];let f=0;let p=0;let g=0;for(let t=0;t<=u;t++){const u=Math.round(t*i);if(u>f){const{topHeight:t,totalHeight:i}=O({maxTop:p,maxBottom:g,halfHeight:n,vScale:r,barMinHeight:a,barAlign:o});const c=R({barAlign:o,halfHeight:n,topHeight:t,totalHeight:i,canvasHeight:h});d.push({x:f*s,y:c,width:e,height:i});f=u;p=0;g=0}const v=Math.abs(c[t]||0);const b=Math.abs(l[t]||0);if(v>p)p=v;if(b>g)g=b}return d}function U(t,i,s){const e=i-t.left;const n=s-t.top;const r=e/t.width;const h=n/t.height;return[r,h]}function H({optionsHeight:t,optionsSplitChannels:i,parentHeight:s,numberOfChannels:e,defaultHeight:n=C}){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 V(t){return Math.max(1,t||1)}function Y(t){return Boolean(t.barWidth||t.barGap||t.barAlign)}function F(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 h=n.createLinearGradient(0,0,0,r);const o=1/(t.length-1);t.forEach(((t,i)=>{h.addColorStop(i*o,t)}));return h}function Q({duration:t,minPxPerSec:i=0,parentWidth:s,fillParent:e,pixelRatio:n}){const r=Math.ceil(t*i);const h=r>s;const o=Boolean(e&&!h);const a=(o?s:r)*n;return{scrollWidth:r,isScrollable:h,useParentWidth:o,width:a}}function $(t,i){if(!Y(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 B({clientWidth:t,totalWidth:i,options:s}){const e=Math.min(A,t,i);return $(e,s)}function _({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 Z(t){return t>L}function G({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 X({channelData:t,barHeight:i,normalize:s,maxPeak:e}){var n;const r=i||1;if(!s)return r;const h=t[0];if(!h||h.length===0)return r;let o=e!==null&&e!==void 0?e:0;if(!e){for(let t=0;t<h.length;t++){const i=(n=h[t])!==null&&n!==void 0?n:0;const s=Math.abs(i);if(s>o)o=s}}if(!o)return r;return r/o}function q({channelData:t,width:i,height:s,vScale:e}){const n=s/2;const r=t[0]||[];const h=t[1]||r;const o=[r,h];return o.map(((t,s)=>{const r=t.length;const h=r?i/r:0;const o=n;const a=s===0?-1:1;const c=[{x:0,y:o}];let l=0;let u=0;for(let i=0;i<=r;i++){const s=Math.round(i*h);if(s>l){const t=Math.round(u*n*e)||1;const i=o+t*a;c.push({x:l,y:i});l=s;u=0}const r=Math.abs(t[i]||0);if(r>u)u=r}c.push({x:l,y:o});return c}))}function J(t){const i=t*2;const s=i<0?Math.floor(i):Math.ceil(i);return s/2}function K(t){const i=t._cleanup;if(typeof i==="function"){i()}}function tt(t,i={}){const{threshold:s=3,mouseButton:e=0,touchDelay:n=100}=i;const r=D(null);const h=new Map;const o=matchMedia("(pointer: coarse)").matches;let a=()=>void 0;const c=i=>{if(i.button!==e)return;if(h.has(i.pointerId))return;h.set(i.pointerId,i);if(h.size>1){return}const c=i.pointerId;let l=i.clientX;let u=i.clientY;let d=false;const f=Date.now();const p=t.getBoundingClientRect();const{left:g,top:v}=p;const b=t=>{if(t.pointerId!==c)return;if(t.defaultPrevented||h.size>1){return}if(o&&Date.now()-f<n)return;const i=t.clientX;const e=t.clientY;const a=i-l;const p=e-u;if(d||Math.abs(a)>s||Math.abs(p)>s){t.preventDefault();t.stopPropagation();if(!d){r.set({type:"start",x:l-g,y:u-v});d=true}r.set({type:"move",x:i-g,y:e-v,deltaX:a,deltaY:p});l=i;u=e}};const m=t=>{if(!h.delete(t.pointerId))return;if(t.pointerId===c&&d){const i=t.clientX;const s=t.clientY;r.set({type:"end",x:i-g,y:s-v})}if(h.size===0){a()}};const y=t=>{if(!t.relatedTarget||t.relatedTarget===document.documentElement){m(t)}};const x=t=>{if(d){t.stopPropagation();t.preventDefault()}};const M=t=>{if(t.defaultPrevented||h.size>1){return}if(d){t.preventDefault()}};document.addEventListener("pointermove",b);document.addEventListener("pointerup",m);document.addEventListener("pointerout",y);document.addEventListener("pointercancel",y);document.addEventListener("touchmove",M,{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",M);setTimeout((()=>{document.removeEventListener("click",x,{capture:true})}),10)}};t.addEventListener("pointerdown",c);const l=()=>{a();t.removeEventListener("pointerdown",c);h.clear();K(r)};return{signal:r,cleanup:l}}function it(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 st(t){return{left:t.scrollLeft,right:t.scrollLeft+t.clientWidth}}function et(t){const i=D({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth});const s=j((()=>it(i.value)),[i]);const e=j((()=>st(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);K(i)};return{scrollData:i,percentages:s,bounds:e,cleanup:r}}var nt=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};var rt=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 ht=60;const ot=10;const at=ot*ht;class ct extends u{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]=U(i,t.clientX,t.clientY);this.emit("click",s,e)};this.onDblClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=U(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(x(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=et(this.scrollContainer);const t=S((()=>{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=tt(this.wrapper);const t=S((()=>{const t=this.dragStream.signal.value;if(!t)return;const i=this.wrapper.getBoundingClientRect().width;const s=z(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 H({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:e,defaultHeight:C})}convertColorValues(t,i){return F(t,this.getPixelRatio(),i===null||i===void 0?void 0:i.canvas.height)}getPixelRatio(){return V(window.devicePixelRatio)}renderBarWaveform(t,i,s,e){const{width:n,height:r}=s.canvas;const{halfHeight:h,barWidth:o,barRadius:a,barIndexScale:c,barSpacing:l,barMinHeight:u}=P({width:n,height:r,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()});const d=W({channelData:t,barIndexScale:c,barSpacing:l,barWidth:o,halfHeight:h,vScale:e,canvasHeight:r,barAlign:i.barAlign,barMinHeight:u});s.beginPath();for(const t of d){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 h=q({channelData:t,width:n,height:r,vScale:e});s.beginPath();for(const t of h){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=X({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});if(Y(i)){this.renderBarWaveform(t,i,s,e);return}this.renderLineWaveform(t,i,s,e)}renderSingleCanvas(t,i,s,e,n,r,h){const o=this.getPixelRatio();const a=document.createElement("canvas");a.width=Math.round(s*o);a.height=Math.round(e*o);a.style.width=`${s}px`;a.style.height=`${e}px`;a.style.left=`${Math.round(n)}px`;r.appendChild(a);const c=a.getContext("2d");if(i.renderFunction){c.fillStyle=this.convertColorValues(i.waveColor,c);i.renderFunction(t,c)}else{this.renderWaveform(t,i,c)}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);h.appendChild(t)}}renderMultiCanvas(t,i,s,e,n,r){const h=this.getPixelRatio();const{clientWidth:o}=this.scrollContainer;const a=s/h;const c=B({clientWidth:o,totalWidth:a,options:i});let l={};if(c===0)return;const u=s=>{if(s<0||s>=f)return;if(l[s])return;l[s]=true;const h=s*c;let o=Math.min(a-h,c);o=$(o,i);if(o<=0)return;const u=_({channelData:t,offset:h,clampedWidth:o,totalWidth:a});this.renderSingleCanvas(u,i,o,e,h,n,r)};const d=()=>{if(Z(Object.keys(l).length)){n.innerHTML="";r.innerHTML="";l={}}};const f=Math.ceil(a/c);if(!this.isScrollable){for(let t=0;t<f;t++){u(t)}return}const p=G({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:a,numCanvases:f});p.forEach((t=>u(t)));if(f>1){const t=this.on("scroll",(()=>{const{scrollLeft:t}=this.scrollContainer;d();G({scrollLeft:t,totalWidth:a,numCanvases:f}).forEach((t=>u(t)))}));this.unsubscribeOnScroll.push(t)}}renderChannel(t,i,s,e){var{overlay:n}=i,r=rt(i,["overlay"]);const h=document.createElement("div");const o=this.getHeight(r.height,r.splitChannels);h.style.height=`${o}px`;if(n&&e>0){h.style.marginTop=`-${o}px`}this.canvasWrapper.style.minHeight=`${o}px`;this.canvasWrapper.appendChild(h);const a=h.cloneNode();this.progressWrapper.appendChild(a);this.renderMultiCanvas(t,r,s,o,h,a)}render(t){return nt(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:h,width:o}=Q({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:e,fillParent:this.options.fillParent,pixelRatio:s});this.isScrollable=r;this.wrapper.style.width=h?"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,o,s)}}else{const i=[t.getChannelData(0)];if(t.numberOfChannels>1)i.push(t.getChannelData(1));this.renderChannel(i,this.options,o,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=J(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 h=t*n;const o=e;const a=e+r;const c=r/2;if(this.isDragging){const t=30;if(h+t>a){this.scrollContainer.scrollLeft+=t}else if(h-t<o){this.scrollContainer.scrollLeft-=t}}else{if(h<o||h>a){this.scrollContainer.scrollLeft=h-(this.options.autoCenter?c:0)}const t=h-e-c;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<=at){this.scrollContainer.scrollLeft+=Math.min(t,ot)}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 nt(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 lt extends u{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 ut=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};function dt(){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 ft extends u{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;dt();this.audioContext=t||new AudioContext;this.gainNode=this.audioContext.createGain();this.gainNode.connect(this.audioContext.destination)}load(){return ut(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 ut(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 ut(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 pt(t){var i,s,e,n,r,h;const o=(i=t===null||t===void 0?void 0:t.currentTime)!==null&&i!==void 0?i:D(0);const a=(s=t===null||t===void 0?void 0:t.duration)!==null&&s!==void 0?s:D(0);const c=(e=t===null||t===void 0?void 0:t.isPlaying)!==null&&e!==void 0?e:D(false);const l=(n=t===null||t===void 0?void 0:t.isSeeking)!==null&&n!==void 0?n:D(false);const u=(r=t===null||t===void 0?void 0:t.volume)!==null&&r!==void 0?r:D(1);const d=(h=t===null||t===void 0?void 0:t.playbackRate)!==null&&h!==void 0?h:D(1);const f=D(null);const p=D(null);const g=D("");const v=D(0);const b=D(0);const m=j((()=>!c.value),[c]);const y=j((()=>f.value!==null),[f]);const x=j((()=>y.value&&a.value>0),[y,a]);const M=j((()=>o.value),[o]);const w=j((()=>a.value>0?o.value/a.value:0),[o,a]);const N={currentTime:o,duration:a,isPlaying:c,isPaused:m,isSeeking:l,volume:u,playbackRate:d,audioBuffer:f,peaks:p,url:g,zoom:v,scrollPosition:b,canPlay:y,isReady:x,progress:M,progressPercent:w};const T={setCurrentTime:t=>{const i=Math.max(0,Math.min(a.value||Infinity,t));o.set(i)},setDuration:t=>{a.set(Math.max(0,t))},setPlaying:t=>{c.set(t)},setSeeking:t=>{l.set(t)},setVolume:t=>{const i=Math.max(0,Math.min(1,t));u.set(i)},setPlaybackRate:t=>{const i=Math.max(.1,Math.min(16,t));d.set(i)},setAudioBuffer:t=>{f.set(t);if(t){a.set(t.duration)}},setPeaks:t=>{p.set(t)},setUrl:t=>{g.set(t)},setZoom:t=>{v.set(Math.max(0,t))},setScrollPosition:t=>{b.set(Math.max(0,t))}};return{state:N,actions:T}}var gt=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 h(t){try{a(e.next(t))}catch(t){r(t)}}function o(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?s(t.value):n(t.value).then(h,o)}a((e=e.apply(t,i||[])).next())}))};const vt={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:true,interact:true,dragToSeek:false,autoScroll:true,autoCenter:true,sampleRate:8e3};class bt extends E{static create(t){return new bt(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new ft: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({},vt,t);const{state:s,actions:e}=pt({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 lt;const n=i?undefined:this.getMediaElement();this.renderer=new ct(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=b.createBuffer(this.exportPeaks(),t.duration)}if(t.peaks&&t.duration){this.decodedData=b.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 gt(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 k.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 h=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 ft){t.duration=h}}if(s){this.decodedData=b.createBuffer(s,h||0)}else if(i){const t=yield i.arrayBuffer();if(this._isDestroyed||r!==this._loadVersion)return;this.decodedData=yield b.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 gt(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 gt(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 h=e.length/i;for(let t=0;t<i;t++){const i=e.slice(Math.floor(t*h),Math.ceil((t+1)*h));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 gt(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 ft){this.media.stopAt(i)}else{this.stopAtPosition=i}}return e}))}playPause(){return gt(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 gt(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()}}bt.BasePlugin=d;bt.dom=M;function mt(t,i,s,e){return new(s||(s=Promise))((function(n,r){function h(t){try{a(e.next(t))}catch(t){r(t)}}function o(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(h,o)}a((e=e.apply(t,i||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class yt{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 xt extends yt{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 yt{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 wt=100,Nt=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class Tt extends xt{constructor(t){var i,s,e,n,r,h;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!==(h=t.mediaRecorderTimeslice)&&void 0!==h?h: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 Tt(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,h=new Float32Array(r);let o=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(h),this.options.scrollingWaveform){const t=Math.floor((this.options.scrollingWaveformWindow||0)*wt);let i=0;for(let t=0;t<r;t++){const s=Math.abs(h[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*wt):(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(h[t]);i>s&&(s=i)}if(o+1>this.dataWindow.length){const t=new Float32Array(2*this.dataWindow.length);t.set(this.dataWindow,0),this.dataWindow=t}this.dataWindow[o]=s,o++}else this.dataWindow=h;if(this.wavesurfer){const t=(null!==(e=null===(s=this.dataWindow)||void 0===s?void 0:s.length)&&void 0!==e?e:0)/wt;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 mt(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 mt(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||Nt.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 mt(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 kt=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 bt!=="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=this.resolveWaveColor();this.wavesurfer=bt.create({container:this.waveformContainer,waveColor:s,progressColor:s,height:28,width:i,barWidth:2,barGap:2,barRadius:2,interact:false,cursorWidth:0});this.recordPlugin=this.wavesurfer.registerPlugin(Tt.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;const i=((t=this.waveformContainer)===null||t===void 0?void 0:t.clientWidth)||this.el.clientWidth;if(i&&this.wavesurfer){try{this.wavesurfer.setOptions({width:i})}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=bt.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:"670b82c67119d4d4c74867a94b4737c16dd8cf57",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:"b797e83c979987e4d1d616cfc1507bb5cf177333",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:"8f0dc7991e61e5f534dff91d6c54e31d6287197b",class:"wave-host",ref:t=>{this.waveformContainer=t},style:{flex:"1",height:t?"28px":"40px",minHeight:t?"28px":"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"]}}};kt.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 min-height: 28px;\n }";const Dt="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNS42MjUgMTVDNS42MjUgMTQuNTg1OCA1LjI4OTIxIDE0LjI1IDQuODc1IDE0LjI1QzQuNDYwNzkgMTQuMjUgNC4xMjUgMTQuNTg1OCA0LjEyNSAxNUg1LjYyNVpNNC44NzUgMTZINC4xMjVINC44NzVaTTE5LjI3NSAxNUMxOS4yNzUgMTQuNTg1OCAxOC45MzkyIDE0LjI1IDE4LjUyNSAxNC4yNUMxOC4xMTA4IDE0LjI1IDE3Ljc3NSAxNC41ODU4IDE3Ljc3NSAxNUgxOS4yNzVaTTExLjEwODYgMTUuNTM4N0MxMC44NTM5IDE1Ljg2NTMgMTAuOTEyMSAxNi4zMzY2IDExLjIzODcgMTYuNTkxNEMxMS41NjUzIDE2Ljg0NjEgMTIuMDM2NiAxNi43ODc5IDEyLjI5MTQgMTYuNDYxM0wxMS4xMDg2IDE1LjUzODdaTTE2LjE5MTQgMTEuNDYxM0MxNi40NDYxIDExLjEzNDcgMTYuMzg3OSAxMC42NjM0IDE2LjA2MTMgMTAuNDA4NkMxNS43MzQ3IDEwLjE1MzkgMTUuMjYzNCAxMC4yMTIxIDE1LjAwODYgMTAuNTM4N0wxNi4xOTE0IDExLjQ2MTNaTTExLjEwODYgMTYuNDYxM0MxMS4zNjM0IDE2Ljc4NzkgMTEuODM0NyAxNi44NDYxIDEyLjE2MTMgMTYuNTkxNEMxMi40ODc5IDE2LjMzNjYgMTIuNTQ2MSAxNS44NjUzIDEyLjI5MTQgMTUuNTM4N0wxMS4xMDg2IDE2LjQ2MTNaTTguMzkxMzggMTAuNTM4N0M4LjEzNjYyIDEwLjIxMjEgNy42NjUzMyAxMC4xNTM5IDcuMzM4NzMgMTAuNDA4NkM3LjAxMjEyIDEwLjY2MzQgNi45NTM4NyAxMS4xMzQ3IDcuMjA4NjIgMTEuNDYxM0w4LjM5MTM4IDEwLjUzODdaTTEwLjk1IDE2QzEwLjk1IDE2LjQxNDIgMTEuMjg1OCAxNi43NSAxMS43IDE2Ljc1QzEyLjExNDIgMTYuNzUgMTIuNDUgMTYuNDE0MiAxMi40NSAxNkgxMC45NVpNMTIuNDUgNUMxMi40NSA0LjU4NTc5IDEyLjExNDIgNC4yNSAxMS43IDQuMjVDMTEuMjg1OCA0LjI1IDEwLjk1IDQuNTg1NzkgMTAuOTUgNUgxMi40NVpNNC4xMjUgMTVWMTZINS42MjVWMTVINC4xMjVaTTQuMTI1IDE2QzQuMTI1IDE4LjA1MzEgNS43NTI1NyAxOS43NSA3LjggMTkuNzVWMTguMjVDNi42MTY1NyAxOC4yNSA1LjYyNSAxNy4yNjA3IDUuNjI1IDE2SDQuMTI1Wk03LjggMTkuNzVIMTUuNlYxOC4yNUg3LjhWMTkuNzVaTTE1LjYgMTkuNzVDMTcuNjQ3NCAxOS43NSAxOS4yNzUgMTguMDUzMSAxOS4yNzUgMTZIMTcuNzc1QzE3Ljc3NSAxNy4yNjA3IDE2Ljc4MzQgMTguMjUgMTUuNiAxOC4yNVYxOS43NVpNMTkuMjc1IDE2VjE1SDE3Ljc3NVYxNkgxOS4yNzVaTTEyLjI5MTQgMTYuNDYxM0wxNi4xOTE0IDExLjQ2MTNMMTUuMDA4NiAxMC41Mzg3TDExLjEwODYgMTUuNTM4N0wxMi4yOTE0IDE2LjQ2MTNaTTEyLjI5MTQgMTUuNTM4N0w4LjM5MTM4IDEwLjUzODdMNy4yMDg2MiAxMS40NjEzTDExLjEwODYgMTYuNDYxM0wxMi4yOTE0IDE1LjUzODdaTTEyLjQ1IDE2VjVIMTAuOTVWMTZIMTIuNDVaIiBmaWxsPSIjMDAwMDAwIi8+Cjwvc3ZnPg==";const jt=Dt;const St=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 o;if(t.includes("spreadsheet")||t.includes("excel")||/\.xlsx?$/.test(i)||i.endsWith(".csv"))return a;if(t.includes("rtf")||i.endsWith(".rtf"))return c;if(t.includes("text/plain")||i.endsWith(".txt"))return l;return o}render(){const t=this.truncateDocName(this.docName||"Document");const i=this.message&&!String(this.message).includes("AttachmentMessage:");const e=this.isPdf();return s("message-bubble",{key:"b6ace1cd0668f471bf64d89d3d7861955411c8ec",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",{key:"96fefa9df08407f2df4be3b72af9dbf5873fe928",class:"doc-container",style:{backgroundColor:this.documentNameBg||"var(--bg-tertiary)",width:this.width||"auto"}},s("div",{key:"e3c866721409745fe12168f5ae0fa53a31527b3b",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",{key:"70247e85e8d862ed0f475650df7d3fd299d58c77",class:"attachment-icon"},s("img",{key:"9d234ea89459c3385086fe17abfcfaa037753c2f",src:this.iconSrc(),alt:""})),s("span",{key:"8c35191f12fbcd1ee972703296059c4ab1b666d9"},t.firstLine,s("br",{key:"4b206833e3181384fbeb683d0459b8a03a285be4"}),t.secondLine)),s("div",{key:"0cb86e8a218cc577287e9be3589a1cd4441a685c",class:"doc-actions"},e&&this.href?s("button",{class:"preview-btn",type:"button",onClick:this.openPreview,"aria-label":"Preview PDF"},"View"):null,s("a",{key:"3351a7680f4f71cd0c05b8b4bb462bfdc4b6b948",class:"download-btn",href:this.href,download:this.fileName,target:"_blank",rel:"noopener noreferrer","aria-label":"Download"},s("img",{key:"30d9286c55c66a6944c46d68fdb9098cb1a31a75",src:jt,alt:""})))),i?s("div",{style:{fontSize:"8px",color:this.textColor,marginTop:"4px"}},r(this.message,this.mentionedUsers,(t=>h(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)}};St.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 It=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.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.imageSrc=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:"b3c7b9f8e05923e0955bff3e8f71740baf5e42b7"},s("message-bubble",{key:"7bca9fc47d0dde8e111bdc445a3fa65a90322def",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:"fb3cf820d1ba04c2e73024700016660ddcffee3a",class:"image-container",style:{width:this.width||"250px",height:this.height||"220px",borderRadius:this.borderRadius},onClick:this.openGallery},s("img",{key:"883f683d9833d06ae7c1c7a375ac3208385cc8c7",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=>h(this.tagUserClick,t)),!!this.isSelf)):null),this.galleryOpen?s("div",{class:"gallery-overlay",onClick:()=>this.galleryOpen=false},s("button",{type:"button",class:"gallery-close","aria-label":"Close"},"×"),s("img",{src:this.imageSrc,alt:"full",onClick:t=>t.stopPropagation()})):null)}};It.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; align-items: center; justify-content: center;\n }\n .gallery-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; }\n .gallery-close {\n position: absolute; top: var(--space-16); right: var(--space-16);\n color: var(--text-on-brand); font-size: var(--text-24);\n background: transparent; border: none; cursor: pointer;\n }";const Et=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.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.videoSrc=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}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("message-bubble",{key:"da362910daf539e1199b49e8c3ff7982d9df2237",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:"d97ba1095677d53316a3726aafe9431165a2c32d",class:"video-wrap"},s("video",{key:"3ef7bf3df763e4f5b3c15cd97338c7cfce87530f",style:{height:this.height||"150px",width:this.width||"150px",objectFit:"cover",borderRadius:this.borderRadius||"8px"},poster:this.poster||undefined,preload:this.poster?"none":"metadata",onClick:this.toggle},s("source",{key:"6893915436d9223c0245d2ddacbd0b8a486d0f15",src:this.videoSrc,type:this.videoType||"video/mp4"})),s("div",{key:"3276ef69508d305500603c9b58c6eb5c2346f44d",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:"955b8fafd989952d44358a0fc831c99db4704cdc",type:"button",class:"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=>h(this.tagUserClick,t)),!!this.isSelf)):null)}get el(){return e(this)}};Et.style=":host { display: block; position: relative; }\n .video-wrap { position: relative; width: fit-content; }\n .controls {\n position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; 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_fullscreen { position: absolute; right: 8px; bottom: 8px; }";export{kt as audio_bubble,St as document_message,It as image_message,Et as video_message};
|
|
2
|
+
//# sourceMappingURL=p-3120b9d3.entry.js.map
|