comisai 1.0.23 → 1.0.25
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/node_modules/@comis/agent/dist/executor/pi-executor.js +17 -0
- package/node_modules/@comis/agent/dist/index.d.ts +2 -1
- package/node_modules/@comis/agent/dist/index.js +1 -1
- package/node_modules/@comis/agent/dist/model/auth-storage-adapter.d.ts +21 -0
- package/node_modules/@comis/agent/dist/model/auth-storage-adapter.js +15 -1
- package/node_modules/@comis/agent/dist/model/model-registry-adapter.d.ts +46 -0
- package/node_modules/@comis/agent/dist/model/model-registry-adapter.js +108 -0
- package/node_modules/@comis/agent/package.json +1 -1
- package/node_modules/@comis/channels/package.json +1 -1
- package/node_modules/@comis/cli/package.json +1 -1
- package/node_modules/@comis/core/dist/bootstrap.js +5 -0
- package/node_modules/@comis/core/dist/config/env-layer.d.ts +31 -0
- package/node_modules/@comis/core/dist/config/env-layer.js +41 -0
- package/node_modules/@comis/core/dist/config/layered.d.ts +9 -0
- package/node_modules/@comis/core/dist/config/layered.js +11 -0
- package/node_modules/@comis/core/package.json +1 -1
- package/node_modules/@comis/daemon/dist/daemon.js +3 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-agents.js +15 -3
- package/node_modules/@comis/daemon/package.json +1 -1
- package/node_modules/@comis/gateway/package.json +1 -1
- package/node_modules/@comis/infra/package.json +1 -1
- package/node_modules/@comis/memory/package.json +1 -1
- package/node_modules/@comis/scheduler/package.json +1 -1
- package/node_modules/@comis/shared/package.json +1 -1
- package/node_modules/@comis/skills/package.json +1 -1
- package/node_modules/@comis/web/dist/assets/{agent-detail-BG9MGWWj.js → agent-detail-ru-AhppM.js} +270 -270
- package/node_modules/@comis/web/dist/assets/agent-editor-hjwRuFVp.js +2173 -0
- package/node_modules/@comis/web/dist/assets/{agent-list-LHCJ4rw2.js → agent-list-6Uotjatr.js} +170 -170
- package/node_modules/@comis/web/dist/assets/{approvals-q9VH_IKr.js → approvals-C-K6hN2U.js} +13 -13
- package/node_modules/@comis/web/dist/assets/billing-view-CxysXH0p.js +375 -0
- package/node_modules/@comis/web/dist/assets/{channel-detail-CaInesJM.js → channel-detail-BBCKtmne.js} +265 -265
- package/node_modules/@comis/web/dist/assets/channel-list-FkfeOLBQ.js +323 -0
- package/node_modules/@comis/web/dist/assets/{chat-console-CNmzl0JW.js → chat-console-BumBaIgO.js} +243 -246
- package/node_modules/@comis/web/dist/assets/{config-editor-DX4ITw6y.js → config-editor-C9BSwHGy.js} +477 -477
- package/node_modules/@comis/web/dist/assets/{context-dag-browser-BwiaF5tf.js → context-dag-browser-BHm00mJD.js} +105 -105
- package/node_modules/@comis/web/dist/assets/{context-engine-BZ5Am6hA.js → context-engine-BENY3pWE.js} +136 -136
- package/node_modules/@comis/web/dist/assets/decorate-BvWYovGE.js +38 -0
- package/node_modules/@comis/web/dist/assets/{delivery-view-OfBZof-m.js → delivery-view-BCnkPsAp.js} +134 -134
- package/node_modules/@comis/web/dist/assets/{diagnostics-view-YFwCxgr2.js → diagnostics-view-C_jQFG2H.js} +82 -82
- package/node_modules/@comis/web/dist/assets/directive-BOYXJ-K-.js +1 -0
- package/node_modules/@comis/web/dist/assets/{extract-variables-BM5qyK-s.js → extract-variables-B7-Doo7l.js} +39 -39
- package/node_modules/@comis/web/dist/assets/{ic-array-editor-B7m6x7-S.js → ic-array-editor-BLoEyeLS.js} +29 -29
- package/node_modules/@comis/web/dist/assets/{ic-breadcrumb-CUMpp3BL.js → ic-breadcrumb-DqN6G3gc.js} +16 -16
- package/node_modules/@comis/web/dist/assets/{ic-budget-segment-bar-BtJ6x5mN.js → ic-budget-segment-bar-zLsMzjDO.js} +20 -20
- package/node_modules/@comis/web/dist/assets/ic-chat-message-FdQcZsSQ.js +352 -0
- package/node_modules/@comis/web/dist/assets/{ic-confirm-dialog-CCDbB04e.js → ic-confirm-dialog-DGlPbV1T.js} +26 -26
- package/node_modules/@comis/web/dist/assets/{ic-connection-dot-CnT1b8xr.js → ic-connection-dot-BgYiK2N4.js} +13 -13
- package/node_modules/@comis/web/dist/assets/ic-data-table-CKIvr-ag.js +277 -0
- package/node_modules/@comis/web/dist/assets/ic-delivery-row-B3YwjjuM.js +67 -0
- package/node_modules/@comis/web/dist/assets/{ic-detail-panel-BF83r-if.js → ic-detail-panel-DiCe4hLr.js} +27 -27
- package/node_modules/@comis/web/dist/assets/{ic-empty-state-60l2ePhd.js → ic-empty-state-CM3Wbj2f.js} +19 -19
- package/node_modules/@comis/web/dist/assets/ic-graph-canvas-ByRjij68.js +359 -0
- package/node_modules/@comis/web/dist/assets/ic-icon-BGNCCPpZ.js +33 -0
- package/node_modules/@comis/web/dist/assets/{ic-layer-waterfall-COvEYMg5.js → ic-layer-waterfall-WkaFyu-l.js} +18 -18
- package/node_modules/@comis/web/dist/assets/ic-relative-time-B3UAnTqg.js +12 -0
- package/node_modules/@comis/web/dist/assets/{ic-search-input-CSOxY9g7.js → ic-search-input-B02AGw1i.js} +22 -22
- package/node_modules/@comis/web/dist/assets/{ic-select-Ce-Raudx.js → ic-select-BqfZISjw.js} +29 -29
- package/node_modules/@comis/web/dist/assets/ic-tabs-yBjkWKJH.js +95 -0
- package/node_modules/@comis/web/dist/assets/ic-tag-CvMVQFRR.js +33 -0
- package/node_modules/@comis/web/dist/assets/{ic-time-range-picker-CypCT68y.js → ic-time-range-picker-DXbYeBmY.js} +31 -31
- package/node_modules/@comis/web/dist/assets/{ic-tool-call-7MaXSsCW.js → ic-tool-call-DMPHsLyx.js} +51 -51
- package/node_modules/@comis/web/dist/assets/index-CVEaS9aY.css +2 -0
- package/node_modules/@comis/web/dist/assets/index-FLPhHz8p.js +2792 -0
- package/node_modules/@comis/web/dist/assets/{mcp-management-BNZPnpDn.js → mcp-management-5jyScQis.js} +209 -209
- package/node_modules/@comis/web/dist/assets/{media-config-BBvTYxOX.js → media-config-J9oT9PPs.js} +154 -154
- package/node_modules/@comis/web/dist/assets/{media-test-BkK3RCRK.js → media-test-DGTCtM8-.js} +259 -259
- package/node_modules/@comis/web/dist/assets/{memory-inspector-1hDGCGat.js → memory-inspector-D5Re9ptG.js} +450 -450
- package/node_modules/@comis/web/dist/assets/{message-center-CXefwsUu.js → message-center-cRLK6ZmG.js} +290 -290
- package/node_modules/@comis/web/dist/assets/{models-C1qcU_j3.js → models-D5vu07MR.js} +371 -371
- package/node_modules/@comis/web/dist/assets/observability-types-D0tkwElU.js +1 -0
- package/node_modules/@comis/web/dist/assets/{observe-view-C0VBhX4C.js → observe-view-CalNNEmd.js} +399 -399
- package/node_modules/@comis/web/dist/assets/pipeline-builder-DUYDGwZf.js +1495 -0
- package/node_modules/@comis/web/dist/assets/{pipeline-history-DkfOQ6SW.js → pipeline-history-BAO8brOe.js} +124 -124
- package/node_modules/@comis/web/dist/assets/{pipeline-history-detail-hyHgD0ai.js → pipeline-history-detail-DectIoQt.js} +65 -65
- package/node_modules/@comis/web/dist/assets/{pipeline-list-BPW8hV-q.js → pipeline-list-BHlaBKww.js} +227 -227
- package/node_modules/@comis/web/dist/assets/{pipeline-monitor-Bip16T7e.js → pipeline-monitor-BhtpNEHf.js} +298 -298
- package/node_modules/@comis/web/dist/assets/{scheduler-BGgwKd06.js → scheduler-VafN_8xi.js} +486 -486
- package/node_modules/@comis/web/dist/assets/{security-D15st4xx.js → security-QQXMRTlo.js} +389 -389
- package/node_modules/@comis/web/dist/assets/{session-detail-SGEYNJ0M.js → session-detail-BpZ_8Yih.js} +294 -294
- package/node_modules/@comis/web/dist/assets/session-key-parser-Dkqcj2Ss.js +1 -0
- package/node_modules/@comis/web/dist/assets/session-list-DfCm8Cec.js +231 -0
- package/node_modules/@comis/web/dist/assets/{setup-wizard-nT0tz9QP.js → setup-wizard-C-z477CG.js} +486 -494
- package/node_modules/@comis/web/dist/assets/{skills-D8yVfSUy.js → skills-BCOGPf6s.js} +329 -329
- package/node_modules/@comis/web/dist/assets/{subagents-HHXMeHYo.js → subagents-l-auUraL.js} +74 -74
- package/node_modules/@comis/web/dist/assets/{workspace-manager-BQlr10iH.js → workspace-manager-DlvBixiq.js} +236 -236
- package/node_modules/@comis/web/dist/index.html +3 -2
- package/node_modules/@comis/web/package.json +1 -1
- package/package.json +15 -15
- package/node_modules/@comis/web/dist/assets/agent-editor-C26Q_xCs.js +0 -2173
- package/node_modules/@comis/web/dist/assets/billing-view-CtYvBqTE.js +0 -375
- package/node_modules/@comis/web/dist/assets/channel-list-B8dj3O9a.js +0 -323
- package/node_modules/@comis/web/dist/assets/directive-DoeGSK_T.js +0 -1
- package/node_modules/@comis/web/dist/assets/ic-chat-message-CFyDJd0z.js +0 -352
- package/node_modules/@comis/web/dist/assets/ic-data-table-CKUNTxHw.js +0 -277
- package/node_modules/@comis/web/dist/assets/ic-delivery-row-GP5Fkygs.js +0 -67
- package/node_modules/@comis/web/dist/assets/ic-graph-canvas-C8FuSMe1.js +0 -359
- package/node_modules/@comis/web/dist/assets/ic-icon-xeGTVhVG.js +0 -33
- package/node_modules/@comis/web/dist/assets/ic-relative-time-3FqpjeAI.js +0 -12
- package/node_modules/@comis/web/dist/assets/ic-tabs-B7QtM_v8.js +0 -95
- package/node_modules/@comis/web/dist/assets/ic-tag-CPPUnDLF.js +0 -33
- package/node_modules/@comis/web/dist/assets/index-CEcM1R_C.js +0 -2830
- package/node_modules/@comis/web/dist/assets/index-CIJFuItj.css +0 -1
- package/node_modules/@comis/web/dist/assets/observability-types-D7jUtSde.js +0 -1
- package/node_modules/@comis/web/dist/assets/pipeline-builder-DcUUIrm0.js +0 -1496
- package/node_modules/@comis/web/dist/assets/session-key-parser-DPORMVyU.js +0 -1
- package/node_modules/@comis/web/dist/assets/session-list-6ybUTxbY.js +0 -231
|
@@ -1,292 +1,4 @@
|
|
|
1
|
-
import{a as _,I as l,b as r,A as d,s as g,f as v,i as b,n as f,r as o,t as y}from"./index-CEcM1R_C.js";import"./ic-breadcrumb-CUMpp3BL.js";import"./ic-empty-state-60l2ePhd.js";import"./ic-confirm-dialog-CCDbB04e.js";import"./ic-relative-time-3FqpjeAI.js";import"./ic-icon-xeGTVhVG.js";var C=Object.defineProperty,x=Object.getOwnPropertyDescriptor,c=(e,t,s,i)=>{for(var a=i>1?void 0:i?x(t,s):t,h=e.length-1,p;h>=0;h--)(p=e[h])&&(a=(i?p(t,s,a):p(a))||a);return i&&a&&C(t,s,a),a};const w=["👍","👎","❤️","😂","😢","🤔","🔥","💯","👏","🚀","👀","👋","✅","❌","⭐","🎉","🙏","💪","🧠","💡","👑","💎","✨","🌈"],I={discord:[{group:"Messages",actions:[{action:"pin",label:"Pin Message",needsMessageId:!0},{action:"unpin",label:"Unpin Message",needsMessageId:!0}]},{group:"Moderation",actions:[{action:"kick",label:"Kick User",needsInput:"userId"},{action:"ban",label:"Ban User",needsInput:"userId"},{action:"unban",label:"Unban User",needsInput:"userId"}]},{group:"Channel",actions:[{action:"set_topic",label:"Set Topic",needsInput:"topic"},{action:"set_slowmode",label:"Set Slowmode",needsInput:"seconds"},{action:"sendTyping",label:"Send Typing Indicator"}]},{group:"Threads",actions:[{action:"threadCreate",label:"Create Thread",needsInput:"name"},{action:"threadList",label:"List Threads"}]},{group:"Info",actions:[{action:"guild_info",label:"Guild Info"},{action:"channel_info",label:"Channel Info"}]}],telegram:[{group:"Messages",actions:[{action:"pin",label:"Pin Message",needsMessageId:!0},{action:"unpin",label:"Unpin Message",needsMessageId:!0}]},{group:"Moderation",actions:[{action:"ban",label:"Ban User",needsInput:"userId"},{action:"unban",label:"Unban User",needsInput:"userId"},{action:"restrict",label:"Restrict User",needsInput:"userId"},{action:"promote",label:"Promote User",needsInput:"userId"},{action:"demote",label:"Demote User",needsInput:"userId"}]},{group:"Chat",actions:[{action:"set_title",label:"Set Chat Title",needsInput:"title"},{action:"set_description",label:"Set Description",needsInput:"description"},{action:"sendTyping",label:"Send Typing Indicator"}]},{group:"Info",actions:[{action:"chat_info",label:"Chat Info"},{action:"member_count",label:"Member Count"},{action:"get_admins",label:"Get Admins"}]}],slack:[{group:"Messages",actions:[{action:"pin",label:"Pin Message",needsMessageId:!0},{action:"unpin",label:"Unpin Message",needsMessageId:!0}]},{group:"Channel",actions:[{action:"set_topic",label:"Set Topic",needsInput:"topic"},{action:"set_purpose",label:"Set Purpose",needsInput:"purpose"},{action:"archive",label:"Archive Channel"},{action:"unarchive",label:"Unarchive Channel"},{action:"sendTyping",label:"Send Typing Indicator"}]},{group:"Members",actions:[{action:"invite",label:"Invite User",needsInput:"userId"},{action:"kick",label:"Kick User",needsInput:"userId"},{action:"members_list",label:"List Members"}]},{group:"Info",actions:[{action:"channel_info",label:"Channel Info"},{action:"bookmark_add",label:"Add Bookmark",needsInput:"url"}]}],whatsapp:[{group:"Group",actions:[{action:"group_info",label:"Group Info"},{action:"group_update_subject",label:"Update Subject",needsInput:"subject"},{action:"group_update_description",label:"Update Description",needsInput:"description"},{action:"group_invite_code",label:"Get Invite Code"}]},{group:"Members",actions:[{action:"group_participants_add",label:"Add Participant",needsInput:"participant"},{action:"group_participants_remove",label:"Remove Participant",needsInput:"participant"},{action:"group_promote",label:"Promote to Admin",needsInput:"participant"},{action:"group_demote",label:"Demote from Admin",needsInput:"participant"}]},{group:"Settings",actions:[{action:"group_settings",label:"Group Settings"}]}]},$={discord:"discord.action",telegram:"telegram.action",slack:"slack.action",whatsapp:"whatsapp.action"};let n=class extends _{constructor(){super(...arguments),this.rpcClient=null,this.eventDispatcher=null,this.channelType="",this._loadState="idle",this._error="",this._messages=[],this._effectiveChannel="",this._capabilities=null,this._channelList=[],this._sendText="",this._showSendConfirm=!1,this._actionPending=!1,this._botName="",this._replyToId="",this._replyText="",this._showReplyConfirm=!1,this._editingId="",this._editText="",this._deleteTargetId="",this._showDeleteConfirm=!1,this._reactTargetId="",this._showEmojiPicker=!1,this._attachUrl="",this._attachType="file",this._attachCaption="",this._showAttachForm=!1,this._chatList=[],this._selectedChatId="",this._platformActionPending=!1,this._selectedMessageId="",this._actionResult="",this._actionInputs={},this._hasLoaded=!1,this._previousChannelType="",this._boundEmojiOutsideClick=null,this._autoSelectAttempted=!1}disconnectedCallback(){super.disconnectedCallback(),this._removeEmojiOutsideListener()}updated(e){const t=this.rpcClient&&this.rpcClient.status==="connected";e.has("channelType")&&this.channelType&&(this._effectiveChannel=this.channelType,this._selectedChatId="",this._chatList=[]),e.has("channelType")&&this.channelType&&this.channelType!==this._previousChannelType?(this._previousChannelType=this.channelType,this._hasLoaded=!1,this._loadData()):e.has("rpcClient")&&t&&this._effectiveChannel&&!this._hasLoaded&&this._loadData(),!this.channelType&&this.rpcClient&&!this._autoSelectAttempted&&(this._autoSelectAttempted=!0,this._autoSelectChannel())}async _autoSelectChannel(){if(!this.rpcClient)return;const e=this.rpcClient;if(e.status!=="connected"&&await new Promise(t=>{const s=()=>{if(e.status==="connected"){t();return}if(e.status==="disconnected"){t();return}setTimeout(s,100)};s()}),e.status!=="connected"){this._loadState="error",this._error="RPC connection failed";return}try{const s=(await e.call("channels.list"))?.channels??[];this._channelList=s;const i=s.filter(a=>a.status==="running");i.length>0?(this._effectiveChannel=i[0].channelType,this._loadChats(),this._loadData()):this._loadState="loaded"}catch{this._loadState="error",this._error="Failed to load channel list"}}async _loadData(){const e=this._effectiveChannel;if(!(!this.rpcClient||!e)){this._loadState="loading",this._error="";try{const[t,s,i]=await Promise.allSettled([this.rpcClient.call("channels.list"),this.rpcClient.call("channels.capabilities",{channel_type:e}),this.rpcClient.call("channels.get",{channel_type:e})]);t.status==="fulfilled"&&t.value?.channels&&(this._channelList=t.value.channels),s.status==="fulfilled"&&s.value?.features&&(this._capabilities=s.value.features),i.status==="fulfilled"&&i.value&&(this._botName=i.value.botName??i.value.name??e),await this._loadChats(),await this._refetchMessages(),this._loadState="loaded",this._hasLoaded=!0}catch(t){this._loadState="error",this._error=t instanceof Error?t.message:"Failed to load message center data"}}}async _loadChats(){if(!(!this.rpcClient||!this._effectiveChannel))try{const t=(await this.rpcClient.call("obs.channels.all"))?.channels??[],s=new Map;for(const i of t){if(i.channelType!==this._effectiveChannel||!i.channelId||i.channelId==="unknown")continue;const a=i.messagesSent+i.messagesReceived;s.set(i.channelId,`${i.channelId} (${a} msgs)`)}this._chatList=Array.from(s.entries()).map(([i,a])=>({chatId:i,label:a})),this._chatList.length>0&&!this._selectedChatId&&(this._selectedChatId=this._chatList[0].chatId)}catch{}}async _refetchMessages(){if(this.rpcClient){if(this._capabilities?.fetchHistory){try{const e=await this.rpcClient.call("message.fetch",{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,limit:50});this._messages=e?.messages??[]}catch{}return}try{const t=(await this.rpcClient.call("session.list",{kind:"all"}))?.sessions??[],s=this._selectedChatId,i=s?t.filter(m=>m.channelId===s):[];if(i.length===0){this._messages=[];return}i.sort((m,u)=>u.updatedAt-m.updatedAt);const a=i[0],p=(await this.rpcClient.call("session.history",{session_key:a.sessionKey,limit:50}))?.messages??[];this._messages=p.map((m,u)=>({id:`stored-${u}`,senderId:m.role,text:m.content,timestamp:m.timestamp}))}catch{this._messages=[]}}}_handleChannelChange(e){const s=e.target.value;s&&s!==this._effectiveChannel&&this.dispatchEvent(new CustomEvent("navigate",{detail:`messages/${s}`,bubbles:!0,composed:!0}))}_handleChatChange(e){const t=e.target;this._selectedChatId=t.value,this._refetchMessages()}_handleSendClick(){this._sendText.trim()&&(this._showSendConfirm=!0)}async _handleSendConfirm(){if(this._showSendConfirm=!1,!(!this.rpcClient||!this._sendText.trim())){this._actionPending=!0;try{await this.rpcClient.call("message.send",{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,text:this._sendText.trim()}),l.show("Message sent","success"),this._sendText="",await this._refetchMessages()}catch(e){const t=e instanceof Error?e.message:"Failed to send message";l.show(t,"error")}finally{this._actionPending=!1}}}_handleSendCancel(){this._showSendConfirm=!1}_handleKeydown(e){e.key==="Enter"&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._handleSendClick())}_handleReplyClick(e){this._replyToId=e,this._replyText="",this.updateComplete.then(()=>{this.shadowRoot?.querySelector(".reply-input")?.focus()})}_handleReplyCancelClick(){this._replyToId="",this._replyText="",this._showReplyConfirm=!1}_handleReplySendClick(){!this._replyText.trim()||!this._replyToId||(this._showReplyConfirm=!0)}async _handleReplyConfirm(){if(this._showReplyConfirm=!1,!(!this.rpcClient||!this._replyText.trim()||!this._replyToId)){this._actionPending=!0;try{await this.rpcClient.call("message.reply",{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,text:this._replyText.trim(),message_id:this._replyToId}),l.show("Reply sent","success"),this._replyToId="",this._replyText="",await this._refetchMessages()}catch(e){const t=e instanceof Error?e.message:"Failed to send reply";l.show(t,"error")}finally{this._actionPending=!1}}}_handleReplyCancel(){this._showReplyConfirm=!1}_handleReplyKeydown(e){e.key==="Enter"&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._handleReplySendClick()),e.key==="Escape"&&this._handleReplyCancelClick()}_handleEditClick(e){this._editingId=e.id,this._editText=e.text,this.updateComplete.then(()=>{this.shadowRoot?.querySelector(".edit-input")?.focus()})}_handleEditCancelClick(){this._editingId="",this._editText=""}async _handleEditSave(){if(!(!this.rpcClient||!this._editText.trim()||!this._editingId)){this._actionPending=!0;try{await this.rpcClient.call("message.edit",{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,message_id:this._editingId,text:this._editText.trim()}),l.show("Message edited","success"),this._editingId="",this._editText="",await this._refetchMessages()}catch(e){const t=e instanceof Error?e.message:"Failed to edit message";l.show(t,"error")}finally{this._actionPending=!1}}}_handleEditKeydown(e){e.key==="Enter"&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._handleEditSave()),e.key==="Escape"&&this._handleEditCancelClick()}_handleDeleteClick(e){this._deleteTargetId=e,this._showDeleteConfirm=!0}async _handleDeleteConfirm(){if(this._showDeleteConfirm=!1,!(!this.rpcClient||!this._deleteTargetId)){this._actionPending=!0;try{await this.rpcClient.call("message.delete",{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,message_id:this._deleteTargetId}),l.show("Message deleted","success"),this._messages=this._messages.filter(e=>e.id!==this._deleteTargetId),this._deleteTargetId=""}catch(e){const t=e instanceof Error?e.message:"Failed to delete message";l.show(t,"error"),this._deleteTargetId="",await this._refetchMessages()}finally{this._actionPending=!1}}}_handleDeleteCancel(){this._showDeleteConfirm=!1,this._deleteTargetId=""}_handleReactClick(e){if(this._reactTargetId===e&&this._showEmojiPicker){this._closeEmojiPicker();return}this._reactTargetId=e,this._showEmojiPicker=!0,requestAnimationFrame(()=>this._installEmojiOutsideListener())}async _handleEmojiSelect(e){if(!(!this.rpcClient||!this._reactTargetId)){this._closeEmojiPicker(),this._actionPending=!0;try{await this.rpcClient.call("message.react",{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,message_id:this._reactTargetId,emoji:e}),l.show("Reaction added","success")}catch(t){const s=t instanceof Error?t.message:"Failed to add reaction";l.show(s,"error")}finally{this._actionPending=!1,this._reactTargetId=""}}}_closeEmojiPicker(){this._showEmojiPicker=!1,this._reactTargetId="",this._removeEmojiOutsideListener()}_installEmojiOutsideListener(){this._removeEmojiOutsideListener(),this._boundEmojiOutsideClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".emoji-picker"),i=this.shadowRoot?.querySelector(`[data-react-id="${this._reactTargetId}"]`);s&&!t.includes(s)&&(!i||!t.includes(i))&&this._closeEmojiPicker()},document.addEventListener("click",this._boundEmojiOutsideClick,!0)}_removeEmojiOutsideListener(){this._boundEmojiOutsideClick&&(document.removeEventListener("click",this._boundEmojiOutsideClick,!0),this._boundEmojiOutsideClick=null)}_toggleAttachForm(){this._showAttachForm=!this._showAttachForm,this._showAttachForm||(this._attachUrl="",this._attachType="file",this._attachCaption="")}async _handleAttachSend(){if(!(!this.rpcClient||!this._attachUrl.trim())){this._actionPending=!0;try{await this.rpcClient.call("message.attach",{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,attachment_url:this._attachUrl.trim(),attachment_type:this._attachType,caption:this._attachCaption.trim()||void 0}),l.show("Attachment sent","success"),this._attachUrl="",this._attachType="file",this._attachCaption="",this._showAttachForm=!1}catch(e){const t=e instanceof Error?e.message:"Failed to send attachment";l.show(t,"error")}finally{this._actionPending=!1}}}_handleMessageClick(e){this._selectedMessageId=this._selectedMessageId===e?"":e}_getActionInputKey(e,t){return`${e}-${t}`}_handleActionInputChange(e,t){this._actionInputs={...this._actionInputs,[e]:t}}async _handlePlatformAction(e){if(!this.rpcClient)return;const t=$[this._effectiveChannel];if(!t)return;const s={action:e.action};if(this._effectiveChannel==="telegram"?s.chat_id=this._selectedChatId||this._effectiveChannel:this._effectiveChannel==="whatsapp"?s.group_jid=this._selectedChatId||this._effectiveChannel:s.channel_id=this._selectedChatId||this._effectiveChannel,e.needsMessageId&&this._selectedMessageId&&(s.message_id=this._selectedMessageId),e.needsInput){const i=this._getActionInputKey("",e.action),a=this._actionInputs[i]?.trim();a&&(s[e.needsInput]=a)}this._platformActionPending=!0,this._actionResult="";try{const i=await this.rpcClient.call(t,s);l.show("Action completed","success"),this._actionResult=typeof i=="string"?i:JSON.stringify(i,null,2)}catch(i){const a=i instanceof Error?i.message:"Action failed";l.show(a,"error"),this._actionResult=""}finally{this._platformActionPending=!1}}render(){return r`
|
|
2
|
-
<div class="message-center">
|
|
3
|
-
${this._renderBreadcrumb()}
|
|
4
|
-
${this._renderHeader()}
|
|
5
|
-
${this._renderBody()}
|
|
6
|
-
${this._renderSendConfirmDialog()}
|
|
7
|
-
${this._renderReplyConfirmDialog()}
|
|
8
|
-
${this._renderDeleteConfirmDialog()}
|
|
9
|
-
</div>
|
|
10
|
-
`}_renderBreadcrumb(){return r`
|
|
11
|
-
<ic-breadcrumb .items=${[{label:"Channels",route:"channels"},{label:this._effectiveChannel||"...",route:`channels/${this._effectiveChannel}`},{label:"Messages"}]}></ic-breadcrumb>
|
|
12
|
-
`}_renderHeader(){return r`
|
|
13
|
-
<div class="header-row">
|
|
14
|
-
<div class="header-left">
|
|
15
|
-
<h1 class="page-title">Messages</h1>
|
|
16
|
-
</div>
|
|
17
|
-
<div class="channel-selector">
|
|
18
|
-
<label for="channel-select">Channel:</label>
|
|
19
|
-
<select
|
|
20
|
-
id="channel-select"
|
|
21
|
-
class="channel-select"
|
|
22
|
-
.value=${this._effectiveChannel}
|
|
23
|
-
@change=${this._handleChannelChange}
|
|
24
|
-
>
|
|
25
|
-
${this._channelList.length===0?r`<option value=${this._effectiveChannel}>${this._effectiveChannel}</option>`:this._channelList.map(e=>r`<option value=${e.channelType} ?selected=${e.channelType===this._effectiveChannel}>${e.channelType}</option>`)}
|
|
26
|
-
</select>
|
|
27
|
-
</div>
|
|
28
|
-
<div class="channel-selector">
|
|
29
|
-
<label for="chat-select">Chat:</label>
|
|
30
|
-
<select
|
|
31
|
-
id="chat-select"
|
|
32
|
-
class="channel-select"
|
|
33
|
-
.value=${this._selectedChatId}
|
|
34
|
-
@change=${this._handleChatChange}
|
|
35
|
-
?disabled=${this._chatList.length===0}
|
|
36
|
-
>
|
|
37
|
-
${this._chatList.length===0?r`<option value="">No chats found</option>`:this._chatList.map(e=>r`<option value=${e.chatId} ?selected=${e.chatId===this._selectedChatId}>${e.label}</option>`)}
|
|
38
|
-
</select>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
`}_renderBody(){switch(this._loadState){case"idle":case"loading":return r`<ic-loading></ic-loading>`;case"error":return r`
|
|
42
|
-
<div class="error-container">
|
|
43
|
-
<div class="error-text">${this._error||"Failed to load"}</div>
|
|
44
|
-
<button class="retry-btn" @click=${()=>{this._loadData()}}>Retry</button>
|
|
45
|
-
</div>
|
|
46
|
-
`;case"loaded":return r`
|
|
47
|
-
${this._renderMessageList()}
|
|
48
|
-
${this._renderSendForm()}
|
|
49
|
-
${this._renderAttachForm()}
|
|
50
|
-
${this._renderPlatformActions()}
|
|
51
|
-
`;default:return d}}_renderMessageList(){if(this._messages.length===0)return r`
|
|
52
|
-
<ic-empty-state
|
|
53
|
-
message="No messages found"
|
|
54
|
-
description="No recent messages in this channel."
|
|
55
|
-
></ic-empty-state>
|
|
56
|
-
`;const e=[...this._messages].sort((a,h)=>a.timestamp-h.timestamp),t=this._capabilities?.editMessages===!0,s=this._capabilities?.deleteMessages===!0,i=this._capabilities?.reactions===!0;return r`
|
|
57
|
-
<div class="section">
|
|
58
|
-
<div class="section-title">Recent Messages (${e.length})</div>
|
|
59
|
-
<div class="message-list">
|
|
60
|
-
${e.map(a=>r`
|
|
61
|
-
<div class="msg-row ${this._selectedMessageId===a.id?"msg-row--selected":""}" @click=${()=>this._handleMessageClick(a.id)}>
|
|
62
|
-
<span class="msg-sender" title=${a.senderId}>${a.senderId}</span>
|
|
63
|
-
${this._editingId===a.id?this._renderEditForm(a):r`<span class="msg-text">${a.text}</span>`}
|
|
64
|
-
<span class="msg-time"><ic-relative-time .timestamp=${a.timestamp}></ic-relative-time></span>
|
|
65
|
-
<span class="msg-actions">
|
|
66
|
-
<button class="msg-action-btn" title="Reply" @click=${()=>this._handleReplyClick(a.id)}>Reply</button>
|
|
67
|
-
${t?r`
|
|
68
|
-
<button class="msg-action-btn" title="Edit" @click=${()=>this._handleEditClick(a)}>Edit</button>
|
|
69
|
-
`:d}
|
|
70
|
-
${s?r`
|
|
71
|
-
<button class="msg-action-btn msg-action-btn--danger" title="Delete" @click=${()=>this._handleDeleteClick(a.id)}>Delete</button>
|
|
72
|
-
`:d}
|
|
73
|
-
${i?r`
|
|
74
|
-
<span class="emoji-picker-anchor">
|
|
75
|
-
<button class="msg-action-btn" title="React" data-react-id=${a.id} @click=${()=>this._handleReactClick(a.id)}>React</button>
|
|
76
|
-
${this._showEmojiPicker&&this._reactTargetId===a.id?this._renderEmojiPicker():d}
|
|
77
|
-
</span>
|
|
78
|
-
`:d}
|
|
79
|
-
</span>
|
|
80
|
-
</div>
|
|
81
|
-
${this._replyToId===a.id?this._renderReplyForm(a):d}
|
|
82
|
-
`)}
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
`}_renderReplyForm(e){return r`
|
|
86
|
-
<div class="inline-form">
|
|
87
|
-
<div class="inline-form-label">
|
|
88
|
-
Replying to ${e.senderId}
|
|
89
|
-
<button class="inline-form-cancel" title="Cancel reply" @click=${this._handleReplyCancelClick}>X</button>
|
|
90
|
-
</div>
|
|
91
|
-
<div class="inline-form-row">
|
|
92
|
-
<textarea
|
|
93
|
-
class="inline-form-input reply-input"
|
|
94
|
-
placeholder="Type your reply..."
|
|
95
|
-
.value=${this._replyText}
|
|
96
|
-
@input=${t=>{this._replyText=t.target.value}}
|
|
97
|
-
@keydown=${this._handleReplyKeydown}
|
|
98
|
-
?disabled=${this._actionPending}
|
|
99
|
-
rows="1"
|
|
100
|
-
></textarea>
|
|
101
|
-
<button
|
|
102
|
-
class="btn-sm btn-sm-primary"
|
|
103
|
-
@click=${this._handleReplySendClick}
|
|
104
|
-
?disabled=${this._actionPending||!this._replyText.trim()}
|
|
105
|
-
>Send Reply</button>
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
`}_renderEditForm(e){return r`
|
|
109
|
-
<span class="msg-text" style="flex:1;min-width:0;">
|
|
110
|
-
<div class="inline-form" style="margin:0;">
|
|
111
|
-
<div class="inline-form-row">
|
|
112
|
-
<textarea
|
|
113
|
-
class="inline-form-input edit-input"
|
|
114
|
-
.value=${this._editText}
|
|
115
|
-
@input=${t=>{this._editText=t.target.value}}
|
|
116
|
-
@keydown=${this._handleEditKeydown}
|
|
117
|
-
?disabled=${this._actionPending}
|
|
118
|
-
rows="1"
|
|
119
|
-
></textarea>
|
|
120
|
-
<button
|
|
121
|
-
class="btn-sm btn-sm-primary"
|
|
122
|
-
@click=${()=>{this._handleEditSave()}}
|
|
123
|
-
?disabled=${this._actionPending||!this._editText.trim()}
|
|
124
|
-
>Save</button>
|
|
125
|
-
<button
|
|
126
|
-
class="btn-sm btn-sm-ghost"
|
|
127
|
-
@click=${this._handleEditCancelClick}
|
|
128
|
-
?disabled=${this._actionPending}
|
|
129
|
-
>Cancel</button>
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
</span>
|
|
133
|
-
`}_renderEmojiPicker(){return r`
|
|
134
|
-
<div class="emoji-picker">
|
|
135
|
-
${w.map(e=>r`
|
|
136
|
-
<button class="emoji-btn" title=${e} @click=${()=>{this._handleEmojiSelect(e)}}>${e}</button>
|
|
137
|
-
`)}
|
|
138
|
-
</div>
|
|
139
|
-
`}_renderSendForm(){const e=this._capabilities?.attachments===!0;return r`
|
|
140
|
-
<div class="section">
|
|
141
|
-
<div class="section-title">Send Message</div>
|
|
142
|
-
<div class="send-form">
|
|
143
|
-
<textarea
|
|
144
|
-
class="send-input"
|
|
145
|
-
placeholder="Type a message to send as ${this._botName||this._effectiveChannel}..."
|
|
146
|
-
.value=${this._sendText}
|
|
147
|
-
@input=${t=>{this._sendText=t.target.value}}
|
|
148
|
-
@keydown=${this._handleKeydown}
|
|
149
|
-
?disabled=${this._actionPending}
|
|
150
|
-
rows="2"
|
|
151
|
-
></textarea>
|
|
152
|
-
<button
|
|
153
|
-
class="btn btn-primary"
|
|
154
|
-
@click=${this._handleSendClick}
|
|
155
|
-
?disabled=${this._actionPending||!this._sendText.trim()}
|
|
156
|
-
>
|
|
157
|
-
${this._actionPending?"Sending...":"Send"}
|
|
158
|
-
</button>
|
|
159
|
-
${e?r`
|
|
160
|
-
<button
|
|
161
|
-
class="btn-sm btn-sm-ghost"
|
|
162
|
-
@click=${this._toggleAttachForm}
|
|
163
|
-
?disabled=${this._actionPending}
|
|
164
|
-
title="Attach File"
|
|
165
|
-
>
|
|
166
|
-
${this._showAttachForm?"Close Attach":"Attach File"}
|
|
167
|
-
</button>
|
|
168
|
-
`:r`
|
|
169
|
-
<button
|
|
170
|
-
class="btn-sm btn-sm-ghost"
|
|
171
|
-
disabled
|
|
172
|
-
title="Attachments not supported on ${this._effectiveChannel}"
|
|
173
|
-
>Attach File</button>
|
|
174
|
-
`}
|
|
175
|
-
</div>
|
|
176
|
-
</div>
|
|
177
|
-
`}_renderAttachForm(){return!this._showAttachForm||this._capabilities?.attachments!==!0?d:r`
|
|
178
|
-
<div class="section">
|
|
179
|
-
<div class="section-title">Send Attachment</div>
|
|
180
|
-
<div class="attach-form">
|
|
181
|
-
<div class="attach-form-row">
|
|
182
|
-
<input
|
|
183
|
-
class="attach-input"
|
|
184
|
-
type="text"
|
|
185
|
-
placeholder="File URL or Path"
|
|
186
|
-
.value=${this._attachUrl}
|
|
187
|
-
@input=${e=>{this._attachUrl=e.target.value}}
|
|
188
|
-
?disabled=${this._actionPending}
|
|
189
|
-
/>
|
|
190
|
-
<select
|
|
191
|
-
class="attach-select"
|
|
192
|
-
.value=${this._attachType}
|
|
193
|
-
@change=${e=>{this._attachType=e.target.value}}
|
|
194
|
-
?disabled=${this._actionPending}
|
|
195
|
-
>
|
|
196
|
-
<option value="file">File</option>
|
|
197
|
-
<option value="image">Image</option>
|
|
198
|
-
<option value="audio">Audio</option>
|
|
199
|
-
<option value="video">Video</option>
|
|
200
|
-
</select>
|
|
201
|
-
</div>
|
|
202
|
-
<div class="attach-form-row">
|
|
203
|
-
<input
|
|
204
|
-
class="attach-input"
|
|
205
|
-
type="text"
|
|
206
|
-
placeholder="Caption (optional)"
|
|
207
|
-
.value=${this._attachCaption}
|
|
208
|
-
@input=${e=>{this._attachCaption=e.target.value}}
|
|
209
|
-
?disabled=${this._actionPending}
|
|
210
|
-
/>
|
|
211
|
-
<button
|
|
212
|
-
class="btn-sm btn-sm-primary"
|
|
213
|
-
@click=${()=>{this._handleAttachSend()}}
|
|
214
|
-
?disabled=${this._actionPending||!this._attachUrl.trim()}
|
|
215
|
-
>
|
|
216
|
-
Send Attachment
|
|
217
|
-
</button>
|
|
218
|
-
<button
|
|
219
|
-
class="btn-sm btn-sm-ghost"
|
|
220
|
-
@click=${this._toggleAttachForm}
|
|
221
|
-
?disabled=${this._actionPending}
|
|
222
|
-
>Cancel</button>
|
|
223
|
-
</div>
|
|
224
|
-
</div>
|
|
225
|
-
</div>
|
|
226
|
-
`}_renderPlatformActions(){const e=I[this._effectiveChannel];if(!e)return d;const t=this._effectiveChannel.charAt(0).toUpperCase()+this._effectiveChannel.slice(1);return r`
|
|
227
|
-
<div class="platform-actions">
|
|
228
|
-
<div class="platform-actions-title">
|
|
229
|
-
<ic-platform-icon platform=${this._effectiveChannel}></ic-platform-icon>
|
|
230
|
-
${t} Actions
|
|
231
|
-
</div>
|
|
232
|
-
${e.map(s=>r`
|
|
233
|
-
<div class="action-group-header">${s.group}</div>
|
|
234
|
-
<div class="action-buttons">
|
|
235
|
-
${s.actions.map(i=>{const a=this._getActionInputKey("",i.action),h=i.needsMessageId&&!this._selectedMessageId;return r`
|
|
236
|
-
${i.needsInput?r`
|
|
237
|
-
<input
|
|
238
|
-
class="action-input"
|
|
239
|
-
type="text"
|
|
240
|
-
placeholder=${i.needsInput}
|
|
241
|
-
.value=${this._actionInputs[a]??""}
|
|
242
|
-
@input=${p=>this._handleActionInputChange(a,p.target.value)}
|
|
243
|
-
?disabled=${this._platformActionPending}
|
|
244
|
-
/>
|
|
245
|
-
`:d}
|
|
246
|
-
<button
|
|
247
|
-
class="btn-sm btn-sm-ghost"
|
|
248
|
-
@click=${()=>{this._handlePlatformAction(i)}}
|
|
249
|
-
?disabled=${this._platformActionPending||h}
|
|
250
|
-
title=${h?"Select a message first":i.label}
|
|
251
|
-
>
|
|
252
|
-
${i.label}
|
|
253
|
-
</button>
|
|
254
|
-
`})}
|
|
255
|
-
</div>
|
|
256
|
-
`)}
|
|
257
|
-
${this._actionResult?r`
|
|
258
|
-
<div class="action-result">${this._actionResult}</div>
|
|
259
|
-
`:d}
|
|
260
|
-
</div>
|
|
261
|
-
`}_renderSendConfirmDialog(){return this._showSendConfirm?r`
|
|
262
|
-
<ic-confirm-dialog
|
|
263
|
-
open
|
|
264
|
-
title="Send Message"
|
|
265
|
-
message="This message will be sent as ${this._botName||this._effectiveChannel} on ${this._effectiveChannel}. You are acting as operator."
|
|
266
|
-
confirmLabel="Send"
|
|
267
|
-
@confirm=${this._handleSendConfirm}
|
|
268
|
-
@cancel=${this._handleSendCancel}
|
|
269
|
-
></ic-confirm-dialog>
|
|
270
|
-
`:d}_renderReplyConfirmDialog(){return this._showReplyConfirm?r`
|
|
271
|
-
<ic-confirm-dialog
|
|
272
|
-
open
|
|
273
|
-
title="Send Reply"
|
|
274
|
-
message="This reply will be sent as ${this._botName||this._effectiveChannel} on ${this._effectiveChannel}. You are acting as operator."
|
|
275
|
-
confirmLabel="Send Reply"
|
|
276
|
-
@confirm=${this._handleReplyConfirm}
|
|
277
|
-
@cancel=${this._handleReplyCancel}
|
|
278
|
-
></ic-confirm-dialog>
|
|
279
|
-
`:d}_renderDeleteConfirmDialog(){return this._showDeleteConfirm?r`
|
|
280
|
-
<ic-confirm-dialog
|
|
281
|
-
open
|
|
282
|
-
title="Delete Message"
|
|
283
|
-
message="This will permanently delete this message from ${this._effectiveChannel}. This cannot be undone."
|
|
284
|
-
variant="danger"
|
|
285
|
-
confirmLabel="Delete"
|
|
286
|
-
@confirm=${this._handleDeleteConfirm}
|
|
287
|
-
@cancel=${this._handleDeleteCancel}
|
|
288
|
-
></ic-confirm-dialog>
|
|
289
|
-
`:d}};n.styles=[g,v,b`
|
|
1
|
+
import{c as e,f as t,h as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./decorate-BvWYovGE.js";import{a as u}from"./index-FLPhHz8p.js";import"./ic-breadcrumb-DqN6G3gc.js";import"./ic-confirm-dialog-DGlPbV1T.js";import"./ic-relative-time-B3UAnTqg.js";import"./ic-empty-state-CM3Wbj2f.js";var d=[`👍`,`👎`,`❤️`,`😂`,`😢`,`🤔`,`🔥`,`💯`,`👏`,`🚀`,`👀`,`👋`,`✅`,`❌`,`⭐`,`🎉`,`🙏`,`💪`,`🧠`,`💡`,`👑`,`💎`,`✨`,`🌈`],f={discord:[{group:`Messages`,actions:[{action:`pin`,label:`Pin Message`,needsMessageId:!0},{action:`unpin`,label:`Unpin Message`,needsMessageId:!0}]},{group:`Moderation`,actions:[{action:`kick`,label:`Kick User`,needsInput:`userId`},{action:`ban`,label:`Ban User`,needsInput:`userId`},{action:`unban`,label:`Unban User`,needsInput:`userId`}]},{group:`Channel`,actions:[{action:`set_topic`,label:`Set Topic`,needsInput:`topic`},{action:`set_slowmode`,label:`Set Slowmode`,needsInput:`seconds`},{action:`sendTyping`,label:`Send Typing Indicator`}]},{group:`Threads`,actions:[{action:`threadCreate`,label:`Create Thread`,needsInput:`name`},{action:`threadList`,label:`List Threads`}]},{group:`Info`,actions:[{action:`guild_info`,label:`Guild Info`},{action:`channel_info`,label:`Channel Info`}]}],telegram:[{group:`Messages`,actions:[{action:`pin`,label:`Pin Message`,needsMessageId:!0},{action:`unpin`,label:`Unpin Message`,needsMessageId:!0}]},{group:`Moderation`,actions:[{action:`ban`,label:`Ban User`,needsInput:`userId`},{action:`unban`,label:`Unban User`,needsInput:`userId`},{action:`restrict`,label:`Restrict User`,needsInput:`userId`},{action:`promote`,label:`Promote User`,needsInput:`userId`},{action:`demote`,label:`Demote User`,needsInput:`userId`}]},{group:`Chat`,actions:[{action:`set_title`,label:`Set Chat Title`,needsInput:`title`},{action:`set_description`,label:`Set Description`,needsInput:`description`},{action:`sendTyping`,label:`Send Typing Indicator`}]},{group:`Info`,actions:[{action:`chat_info`,label:`Chat Info`},{action:`member_count`,label:`Member Count`},{action:`get_admins`,label:`Get Admins`}]}],slack:[{group:`Messages`,actions:[{action:`pin`,label:`Pin Message`,needsMessageId:!0},{action:`unpin`,label:`Unpin Message`,needsMessageId:!0}]},{group:`Channel`,actions:[{action:`set_topic`,label:`Set Topic`,needsInput:`topic`},{action:`set_purpose`,label:`Set Purpose`,needsInput:`purpose`},{action:`archive`,label:`Archive Channel`},{action:`unarchive`,label:`Unarchive Channel`},{action:`sendTyping`,label:`Send Typing Indicator`}]},{group:`Members`,actions:[{action:`invite`,label:`Invite User`,needsInput:`userId`},{action:`kick`,label:`Kick User`,needsInput:`userId`},{action:`members_list`,label:`List Members`}]},{group:`Info`,actions:[{action:`channel_info`,label:`Channel Info`},{action:`bookmark_add`,label:`Add Bookmark`,needsInput:`url`}]}],whatsapp:[{group:`Group`,actions:[{action:`group_info`,label:`Group Info`},{action:`group_update_subject`,label:`Update Subject`,needsInput:`subject`},{action:`group_update_description`,label:`Update Description`,needsInput:`description`},{action:`group_invite_code`,label:`Get Invite Code`}]},{group:`Members`,actions:[{action:`group_participants_add`,label:`Add Participant`,needsInput:`participant`},{action:`group_participants_remove`,label:`Remove Participant`,needsInput:`participant`},{action:`group_promote`,label:`Promote to Admin`,needsInput:`participant`},{action:`group_demote`,label:`Demote from Admin`,needsInput:`participant`}]},{group:`Settings`,actions:[{action:`group_settings`,label:`Group Settings`}]}]},p={discord:`discord.action`,telegram:`telegram.action`,slack:`slack.action`,whatsapp:`whatsapp.action`},m=class extends r{constructor(...e){super(...e),this.rpcClient=null,this.eventDispatcher=null,this.channelType=``,this._loadState=`idle`,this._error=``,this._messages=[],this._effectiveChannel=``,this._capabilities=null,this._channelList=[],this._sendText=``,this._showSendConfirm=!1,this._actionPending=!1,this._botName=``,this._replyToId=``,this._replyText=``,this._showReplyConfirm=!1,this._editingId=``,this._editText=``,this._deleteTargetId=``,this._showDeleteConfirm=!1,this._reactTargetId=``,this._showEmojiPicker=!1,this._attachUrl=``,this._attachType=`file`,this._attachCaption=``,this._showAttachForm=!1,this._chatList=[],this._selectedChatId=``,this._platformActionPending=!1,this._selectedMessageId=``,this._actionResult=``,this._actionInputs={},this._hasLoaded=!1,this._previousChannelType=``,this._boundEmojiOutsideClick=null,this._autoSelectAttempted=!1}static{this.styles=[o,i,n`
|
|
290
2
|
:host {
|
|
291
3
|
display: block;
|
|
292
4
|
}
|
|
@@ -782,4 +494,292 @@ import{a as _,I as l,b as r,A as d,s as g,f as v,i as b,n as f,r as o,t as y}fro
|
|
|
782
494
|
.retry-btn:hover {
|
|
783
495
|
background: var(--ic-border, #374151);
|
|
784
496
|
}
|
|
785
|
-
`];c([f({attribute:!1})],n.prototype,"rpcClient",2);c([f({attribute:!1})],n.prototype,"eventDispatcher",2);c([f()],n.prototype,"channelType",2);c([o()],n.prototype,"_loadState",2);c([o()],n.prototype,"_error",2);c([o()],n.prototype,"_messages",2);c([o()],n.prototype,"_effectiveChannel",2);c([o()],n.prototype,"_capabilities",2);c([o()],n.prototype,"_channelList",2);c([o()],n.prototype,"_sendText",2);c([o()],n.prototype,"_showSendConfirm",2);c([o()],n.prototype,"_actionPending",2);c([o()],n.prototype,"_botName",2);c([o()],n.prototype,"_replyToId",2);c([o()],n.prototype,"_replyText",2);c([o()],n.prototype,"_showReplyConfirm",2);c([o()],n.prototype,"_editingId",2);c([o()],n.prototype,"_editText",2);c([o()],n.prototype,"_deleteTargetId",2);c([o()],n.prototype,"_showDeleteConfirm",2);c([o()],n.prototype,"_reactTargetId",2);c([o()],n.prototype,"_showEmojiPicker",2);c([o()],n.prototype,"_attachUrl",2);c([o()],n.prototype,"_attachType",2);c([o()],n.prototype,"_attachCaption",2);c([o()],n.prototype,"_showAttachForm",2);c([o()],n.prototype,"_chatList",2);c([o()],n.prototype,"_selectedChatId",2);c([o()],n.prototype,"_platformActionPending",2);c([o()],n.prototype,"_selectedMessageId",2);c([o()],n.prototype,"_actionResult",2);n=c([y("ic-message-center")],n);export{n as IcMessageCenter};
|
|
497
|
+
`]}disconnectedCallback(){super.disconnectedCallback(),this._removeEmojiOutsideListener()}updated(e){let t=this.rpcClient&&this.rpcClient.status===`connected`;e.has(`channelType`)&&this.channelType&&(this._effectiveChannel=this.channelType,this._selectedChatId=``,this._chatList=[]),e.has(`channelType`)&&this.channelType&&this.channelType!==this._previousChannelType?(this._previousChannelType=this.channelType,this._hasLoaded=!1,this._loadData()):e.has(`rpcClient`)&&t&&this._effectiveChannel&&!this._hasLoaded&&this._loadData(),!this.channelType&&this.rpcClient&&!this._autoSelectAttempted&&(this._autoSelectAttempted=!0,this._autoSelectChannel())}async _autoSelectChannel(){if(!this.rpcClient)return;let e=this.rpcClient;if(e.status!==`connected`&&await new Promise(t=>{let n=()=>{if(e.status===`connected`){t();return}if(e.status===`disconnected`){t();return}setTimeout(n,100)};n()}),e.status!==`connected`){this._loadState=`error`,this._error=`RPC connection failed`;return}try{let t=(await e.call(`channels.list`))?.channels??[];this._channelList=t;let n=t.filter(e=>e.status===`running`);n.length>0?(this._effectiveChannel=n[0].channelType,this._loadChats(),this._loadData()):this._loadState=`loaded`}catch{this._loadState=`error`,this._error=`Failed to load channel list`}}async _loadData(){let e=this._effectiveChannel;if(!(!this.rpcClient||!e)){this._loadState=`loading`,this._error=``;try{let[t,n,r]=await Promise.allSettled([this.rpcClient.call(`channels.list`),this.rpcClient.call(`channels.capabilities`,{channel_type:e}),this.rpcClient.call(`channels.get`,{channel_type:e})]);t.status===`fulfilled`&&t.value?.channels&&(this._channelList=t.value.channels),n.status===`fulfilled`&&n.value?.features&&(this._capabilities=n.value.features),r.status===`fulfilled`&&r.value&&(this._botName=r.value.botName??r.value.name??e),await this._loadChats(),await this._refetchMessages(),this._loadState=`loaded`,this._hasLoaded=!0}catch(e){this._loadState=`error`,this._error=e instanceof Error?e.message:`Failed to load message center data`}}}async _loadChats(){if(!(!this.rpcClient||!this._effectiveChannel))try{let e=(await this.rpcClient.call(`obs.channels.all`))?.channels??[],t=new Map;for(let n of e){if(n.channelType!==this._effectiveChannel||!n.channelId||n.channelId===`unknown`)continue;let e=n.messagesSent+n.messagesReceived;t.set(n.channelId,`${n.channelId} (${e} msgs)`)}this._chatList=Array.from(t.entries()).map(([e,t])=>({chatId:e,label:t})),this._chatList.length>0&&!this._selectedChatId&&(this._selectedChatId=this._chatList[0].chatId)}catch{}}async _refetchMessages(){if(this.rpcClient){if(this._capabilities?.fetchHistory){try{let e=await this.rpcClient.call(`message.fetch`,{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,limit:50});this._messages=e?.messages??[]}catch{}return}try{let e=(await this.rpcClient.call(`session.list`,{kind:`all`}))?.sessions??[],t=this._selectedChatId,n=t?e.filter(e=>e.channelId===t):[];if(n.length===0){this._messages=[];return}n.sort((e,t)=>t.updatedAt-e.updatedAt);let r=n[0],i=(await this.rpcClient.call(`session.history`,{session_key:r.sessionKey,limit:50}))?.messages??[];this._messages=i.map((e,t)=>({id:`stored-${t}`,senderId:e.role,text:e.content,timestamp:e.timestamp}))}catch{this._messages=[]}}}_handleChannelChange(e){let t=e.target.value;t&&t!==this._effectiveChannel&&this.dispatchEvent(new CustomEvent(`navigate`,{detail:`messages/${t}`,bubbles:!0,composed:!0}))}_handleChatChange(e){let t=e.target;this._selectedChatId=t.value,this._refetchMessages()}_handleSendClick(){this._sendText.trim()&&(this._showSendConfirm=!0)}async _handleSendConfirm(){if(this._showSendConfirm=!1,!(!this.rpcClient||!this._sendText.trim())){this._actionPending=!0;try{await this.rpcClient.call(`message.send`,{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,text:this._sendText.trim()}),u.show(`Message sent`,`success`),this._sendText=``,await this._refetchMessages()}catch(e){let t=e instanceof Error?e.message:`Failed to send message`;u.show(t,`error`)}finally{this._actionPending=!1}}}_handleSendCancel(){this._showSendConfirm=!1}_handleKeydown(e){e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._handleSendClick())}_handleReplyClick(e){this._replyToId=e,this._replyText=``,this.updateComplete.then(()=>{(this.shadowRoot?.querySelector(`.reply-input`))?.focus()})}_handleReplyCancelClick(){this._replyToId=``,this._replyText=``,this._showReplyConfirm=!1}_handleReplySendClick(){!this._replyText.trim()||!this._replyToId||(this._showReplyConfirm=!0)}async _handleReplyConfirm(){if(this._showReplyConfirm=!1,!(!this.rpcClient||!this._replyText.trim()||!this._replyToId)){this._actionPending=!0;try{await this.rpcClient.call(`message.reply`,{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,text:this._replyText.trim(),message_id:this._replyToId}),u.show(`Reply sent`,`success`),this._replyToId=``,this._replyText=``,await this._refetchMessages()}catch(e){let t=e instanceof Error?e.message:`Failed to send reply`;u.show(t,`error`)}finally{this._actionPending=!1}}}_handleReplyCancel(){this._showReplyConfirm=!1}_handleReplyKeydown(e){e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._handleReplySendClick()),e.key===`Escape`&&this._handleReplyCancelClick()}_handleEditClick(e){this._editingId=e.id,this._editText=e.text,this.updateComplete.then(()=>{(this.shadowRoot?.querySelector(`.edit-input`))?.focus()})}_handleEditCancelClick(){this._editingId=``,this._editText=``}async _handleEditSave(){if(!(!this.rpcClient||!this._editText.trim()||!this._editingId)){this._actionPending=!0;try{await this.rpcClient.call(`message.edit`,{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,message_id:this._editingId,text:this._editText.trim()}),u.show(`Message edited`,`success`),this._editingId=``,this._editText=``,await this._refetchMessages()}catch(e){let t=e instanceof Error?e.message:`Failed to edit message`;u.show(t,`error`)}finally{this._actionPending=!1}}}_handleEditKeydown(e){e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._handleEditSave()),e.key===`Escape`&&this._handleEditCancelClick()}_handleDeleteClick(e){this._deleteTargetId=e,this._showDeleteConfirm=!0}async _handleDeleteConfirm(){if(this._showDeleteConfirm=!1,!(!this.rpcClient||!this._deleteTargetId)){this._actionPending=!0;try{await this.rpcClient.call(`message.delete`,{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,message_id:this._deleteTargetId}),u.show(`Message deleted`,`success`),this._messages=this._messages.filter(e=>e.id!==this._deleteTargetId),this._deleteTargetId=``}catch(e){let t=e instanceof Error?e.message:`Failed to delete message`;u.show(t,`error`),this._deleteTargetId=``,await this._refetchMessages()}finally{this._actionPending=!1}}}_handleDeleteCancel(){this._showDeleteConfirm=!1,this._deleteTargetId=``}_handleReactClick(e){if(this._reactTargetId===e&&this._showEmojiPicker){this._closeEmojiPicker();return}this._reactTargetId=e,this._showEmojiPicker=!0,requestAnimationFrame(()=>this._installEmojiOutsideListener())}async _handleEmojiSelect(e){if(!(!this.rpcClient||!this._reactTargetId)){this._closeEmojiPicker(),this._actionPending=!0;try{await this.rpcClient.call(`message.react`,{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,message_id:this._reactTargetId,emoji:e}),u.show(`Reaction added`,`success`)}catch(e){let t=e instanceof Error?e.message:`Failed to add reaction`;u.show(t,`error`)}finally{this._actionPending=!1,this._reactTargetId=``}}}_closeEmojiPicker(){this._showEmojiPicker=!1,this._reactTargetId=``,this._removeEmojiOutsideListener()}_installEmojiOutsideListener(){this._removeEmojiOutsideListener(),this._boundEmojiOutsideClick=e=>{let t=e.composedPath(),n=this.shadowRoot?.querySelector(`.emoji-picker`),r=this.shadowRoot?.querySelector(`[data-react-id="${this._reactTargetId}"]`);n&&!t.includes(n)&&(!r||!t.includes(r))&&this._closeEmojiPicker()},document.addEventListener(`click`,this._boundEmojiOutsideClick,!0)}_removeEmojiOutsideListener(){this._boundEmojiOutsideClick&&=(document.removeEventListener(`click`,this._boundEmojiOutsideClick,!0),null)}_toggleAttachForm(){this._showAttachForm=!this._showAttachForm,this._showAttachForm||(this._attachUrl=``,this._attachType=`file`,this._attachCaption=``)}async _handleAttachSend(){if(!(!this.rpcClient||!this._attachUrl.trim())){this._actionPending=!0;try{await this.rpcClient.call(`message.attach`,{channel_type:this._effectiveChannel,channel_id:this._selectedChatId||this._effectiveChannel,attachment_url:this._attachUrl.trim(),attachment_type:this._attachType,caption:this._attachCaption.trim()||void 0}),u.show(`Attachment sent`,`success`),this._attachUrl=``,this._attachType=`file`,this._attachCaption=``,this._showAttachForm=!1}catch(e){let t=e instanceof Error?e.message:`Failed to send attachment`;u.show(t,`error`)}finally{this._actionPending=!1}}}_handleMessageClick(e){this._selectedMessageId=this._selectedMessageId===e?``:e}_getActionInputKey(e,t){return`${e}-${t}`}_handleActionInputChange(e,t){this._actionInputs={...this._actionInputs,[e]:t}}async _handlePlatformAction(e){if(!this.rpcClient)return;let t=p[this._effectiveChannel];if(!t)return;let n={action:e.action};if(this._effectiveChannel===`telegram`?n.chat_id=this._selectedChatId||this._effectiveChannel:this._effectiveChannel===`whatsapp`?n.group_jid=this._selectedChatId||this._effectiveChannel:n.channel_id=this._selectedChatId||this._effectiveChannel,e.needsMessageId&&this._selectedMessageId&&(n.message_id=this._selectedMessageId),e.needsInput){let t=this._getActionInputKey(``,e.action),r=this._actionInputs[t]?.trim();r&&(n[e.needsInput]=r)}this._platformActionPending=!0,this._actionResult=``;try{let e=await this.rpcClient.call(t,n);u.show(`Action completed`,`success`),this._actionResult=typeof e==`string`?e:JSON.stringify(e,null,2)}catch(e){let t=e instanceof Error?e.message:`Action failed`;u.show(t,`error`),this._actionResult=``}finally{this._platformActionPending=!1}}render(){return t`
|
|
498
|
+
<div class="message-center">
|
|
499
|
+
${this._renderBreadcrumb()}
|
|
500
|
+
${this._renderHeader()}
|
|
501
|
+
${this._renderBody()}
|
|
502
|
+
${this._renderSendConfirmDialog()}
|
|
503
|
+
${this._renderReplyConfirmDialog()}
|
|
504
|
+
${this._renderDeleteConfirmDialog()}
|
|
505
|
+
</div>
|
|
506
|
+
`}_renderBreadcrumb(){return t`
|
|
507
|
+
<ic-breadcrumb .items=${[{label:`Channels`,route:`channels`},{label:this._effectiveChannel||`...`,route:`channels/${this._effectiveChannel}`},{label:`Messages`}]}></ic-breadcrumb>
|
|
508
|
+
`}_renderHeader(){return t`
|
|
509
|
+
<div class="header-row">
|
|
510
|
+
<div class="header-left">
|
|
511
|
+
<h1 class="page-title">Messages</h1>
|
|
512
|
+
</div>
|
|
513
|
+
<div class="channel-selector">
|
|
514
|
+
<label for="channel-select">Channel:</label>
|
|
515
|
+
<select
|
|
516
|
+
id="channel-select"
|
|
517
|
+
class="channel-select"
|
|
518
|
+
.value=${this._effectiveChannel}
|
|
519
|
+
@change=${this._handleChannelChange}
|
|
520
|
+
>
|
|
521
|
+
${this._channelList.length===0?t`<option value=${this._effectiveChannel}>${this._effectiveChannel}</option>`:this._channelList.map(e=>t`<option value=${e.channelType} ?selected=${e.channelType===this._effectiveChannel}>${e.channelType}</option>`)}
|
|
522
|
+
</select>
|
|
523
|
+
</div>
|
|
524
|
+
<div class="channel-selector">
|
|
525
|
+
<label for="chat-select">Chat:</label>
|
|
526
|
+
<select
|
|
527
|
+
id="chat-select"
|
|
528
|
+
class="channel-select"
|
|
529
|
+
.value=${this._selectedChatId}
|
|
530
|
+
@change=${this._handleChatChange}
|
|
531
|
+
?disabled=${this._chatList.length===0}
|
|
532
|
+
>
|
|
533
|
+
${this._chatList.length===0?t`<option value="">No chats found</option>`:this._chatList.map(e=>t`<option value=${e.chatId} ?selected=${e.chatId===this._selectedChatId}>${e.label}</option>`)}
|
|
534
|
+
</select>
|
|
535
|
+
</div>
|
|
536
|
+
</div>
|
|
537
|
+
`}_renderBody(){switch(this._loadState){case`idle`:case`loading`:return t`<ic-loading></ic-loading>`;case`error`:return t`
|
|
538
|
+
<div class="error-container">
|
|
539
|
+
<div class="error-text">${this._error||`Failed to load`}</div>
|
|
540
|
+
<button class="retry-btn" @click=${()=>void this._loadData()}>Retry</button>
|
|
541
|
+
</div>
|
|
542
|
+
`;case`loaded`:return t`
|
|
543
|
+
${this._renderMessageList()}
|
|
544
|
+
${this._renderSendForm()}
|
|
545
|
+
${this._renderAttachForm()}
|
|
546
|
+
${this._renderPlatformActions()}
|
|
547
|
+
`;default:return l}}_renderMessageList(){if(this._messages.length===0)return t`
|
|
548
|
+
<ic-empty-state
|
|
549
|
+
message="No messages found"
|
|
550
|
+
description="No recent messages in this channel."
|
|
551
|
+
></ic-empty-state>
|
|
552
|
+
`;let e=[...this._messages].sort((e,t)=>e.timestamp-t.timestamp),n=this._capabilities?.editMessages===!0,r=this._capabilities?.deleteMessages===!0,i=this._capabilities?.reactions===!0;return t`
|
|
553
|
+
<div class="section">
|
|
554
|
+
<div class="section-title">Recent Messages (${e.length})</div>
|
|
555
|
+
<div class="message-list">
|
|
556
|
+
${e.map(e=>t`
|
|
557
|
+
<div class="msg-row ${this._selectedMessageId===e.id?`msg-row--selected`:``}" @click=${()=>this._handleMessageClick(e.id)}>
|
|
558
|
+
<span class="msg-sender" title=${e.senderId}>${e.senderId}</span>
|
|
559
|
+
${this._editingId===e.id?this._renderEditForm(e):t`<span class="msg-text">${e.text}</span>`}
|
|
560
|
+
<span class="msg-time"><ic-relative-time .timestamp=${e.timestamp}></ic-relative-time></span>
|
|
561
|
+
<span class="msg-actions">
|
|
562
|
+
<button class="msg-action-btn" title="Reply" @click=${()=>this._handleReplyClick(e.id)}>Reply</button>
|
|
563
|
+
${n?t`
|
|
564
|
+
<button class="msg-action-btn" title="Edit" @click=${()=>this._handleEditClick(e)}>Edit</button>
|
|
565
|
+
`:l}
|
|
566
|
+
${r?t`
|
|
567
|
+
<button class="msg-action-btn msg-action-btn--danger" title="Delete" @click=${()=>this._handleDeleteClick(e.id)}>Delete</button>
|
|
568
|
+
`:l}
|
|
569
|
+
${i?t`
|
|
570
|
+
<span class="emoji-picker-anchor">
|
|
571
|
+
<button class="msg-action-btn" title="React" data-react-id=${e.id} @click=${()=>this._handleReactClick(e.id)}>React</button>
|
|
572
|
+
${this._showEmojiPicker&&this._reactTargetId===e.id?this._renderEmojiPicker():l}
|
|
573
|
+
</span>
|
|
574
|
+
`:l}
|
|
575
|
+
</span>
|
|
576
|
+
</div>
|
|
577
|
+
${this._replyToId===e.id?this._renderReplyForm(e):l}
|
|
578
|
+
`)}
|
|
579
|
+
</div>
|
|
580
|
+
</div>
|
|
581
|
+
`}_renderReplyForm(e){return t`
|
|
582
|
+
<div class="inline-form">
|
|
583
|
+
<div class="inline-form-label">
|
|
584
|
+
Replying to ${e.senderId}
|
|
585
|
+
<button class="inline-form-cancel" title="Cancel reply" @click=${this._handleReplyCancelClick}>X</button>
|
|
586
|
+
</div>
|
|
587
|
+
<div class="inline-form-row">
|
|
588
|
+
<textarea
|
|
589
|
+
class="inline-form-input reply-input"
|
|
590
|
+
placeholder="Type your reply..."
|
|
591
|
+
.value=${this._replyText}
|
|
592
|
+
@input=${e=>{this._replyText=e.target.value}}
|
|
593
|
+
@keydown=${this._handleReplyKeydown}
|
|
594
|
+
?disabled=${this._actionPending}
|
|
595
|
+
rows="1"
|
|
596
|
+
></textarea>
|
|
597
|
+
<button
|
|
598
|
+
class="btn-sm btn-sm-primary"
|
|
599
|
+
@click=${this._handleReplySendClick}
|
|
600
|
+
?disabled=${this._actionPending||!this._replyText.trim()}
|
|
601
|
+
>Send Reply</button>
|
|
602
|
+
</div>
|
|
603
|
+
</div>
|
|
604
|
+
`}_renderEditForm(e){return t`
|
|
605
|
+
<span class="msg-text" style="flex:1;min-width:0;">
|
|
606
|
+
<div class="inline-form" style="margin:0;">
|
|
607
|
+
<div class="inline-form-row">
|
|
608
|
+
<textarea
|
|
609
|
+
class="inline-form-input edit-input"
|
|
610
|
+
.value=${this._editText}
|
|
611
|
+
@input=${e=>{this._editText=e.target.value}}
|
|
612
|
+
@keydown=${this._handleEditKeydown}
|
|
613
|
+
?disabled=${this._actionPending}
|
|
614
|
+
rows="1"
|
|
615
|
+
></textarea>
|
|
616
|
+
<button
|
|
617
|
+
class="btn-sm btn-sm-primary"
|
|
618
|
+
@click=${()=>void this._handleEditSave()}
|
|
619
|
+
?disabled=${this._actionPending||!this._editText.trim()}
|
|
620
|
+
>Save</button>
|
|
621
|
+
<button
|
|
622
|
+
class="btn-sm btn-sm-ghost"
|
|
623
|
+
@click=${this._handleEditCancelClick}
|
|
624
|
+
?disabled=${this._actionPending}
|
|
625
|
+
>Cancel</button>
|
|
626
|
+
</div>
|
|
627
|
+
</div>
|
|
628
|
+
</span>
|
|
629
|
+
`}_renderEmojiPicker(){return t`
|
|
630
|
+
<div class="emoji-picker">
|
|
631
|
+
${d.map(e=>t`
|
|
632
|
+
<button class="emoji-btn" title=${e} @click=${()=>void this._handleEmojiSelect(e)}>${e}</button>
|
|
633
|
+
`)}
|
|
634
|
+
</div>
|
|
635
|
+
`}_renderSendForm(){let e=this._capabilities?.attachments===!0;return t`
|
|
636
|
+
<div class="section">
|
|
637
|
+
<div class="section-title">Send Message</div>
|
|
638
|
+
<div class="send-form">
|
|
639
|
+
<textarea
|
|
640
|
+
class="send-input"
|
|
641
|
+
placeholder="Type a message to send as ${this._botName||this._effectiveChannel}..."
|
|
642
|
+
.value=${this._sendText}
|
|
643
|
+
@input=${e=>{this._sendText=e.target.value}}
|
|
644
|
+
@keydown=${this._handleKeydown}
|
|
645
|
+
?disabled=${this._actionPending}
|
|
646
|
+
rows="2"
|
|
647
|
+
></textarea>
|
|
648
|
+
<button
|
|
649
|
+
class="btn btn-primary"
|
|
650
|
+
@click=${this._handleSendClick}
|
|
651
|
+
?disabled=${this._actionPending||!this._sendText.trim()}
|
|
652
|
+
>
|
|
653
|
+
${this._actionPending?`Sending...`:`Send`}
|
|
654
|
+
</button>
|
|
655
|
+
${e?t`
|
|
656
|
+
<button
|
|
657
|
+
class="btn-sm btn-sm-ghost"
|
|
658
|
+
@click=${this._toggleAttachForm}
|
|
659
|
+
?disabled=${this._actionPending}
|
|
660
|
+
title="Attach File"
|
|
661
|
+
>
|
|
662
|
+
${this._showAttachForm?`Close Attach`:`Attach File`}
|
|
663
|
+
</button>
|
|
664
|
+
`:t`
|
|
665
|
+
<button
|
|
666
|
+
class="btn-sm btn-sm-ghost"
|
|
667
|
+
disabled
|
|
668
|
+
title="Attachments not supported on ${this._effectiveChannel}"
|
|
669
|
+
>Attach File</button>
|
|
670
|
+
`}
|
|
671
|
+
</div>
|
|
672
|
+
</div>
|
|
673
|
+
`}_renderAttachForm(){return!this._showAttachForm||this._capabilities?.attachments!==!0?l:t`
|
|
674
|
+
<div class="section">
|
|
675
|
+
<div class="section-title">Send Attachment</div>
|
|
676
|
+
<div class="attach-form">
|
|
677
|
+
<div class="attach-form-row">
|
|
678
|
+
<input
|
|
679
|
+
class="attach-input"
|
|
680
|
+
type="text"
|
|
681
|
+
placeholder="File URL or Path"
|
|
682
|
+
.value=${this._attachUrl}
|
|
683
|
+
@input=${e=>{this._attachUrl=e.target.value}}
|
|
684
|
+
?disabled=${this._actionPending}
|
|
685
|
+
/>
|
|
686
|
+
<select
|
|
687
|
+
class="attach-select"
|
|
688
|
+
.value=${this._attachType}
|
|
689
|
+
@change=${e=>{this._attachType=e.target.value}}
|
|
690
|
+
?disabled=${this._actionPending}
|
|
691
|
+
>
|
|
692
|
+
<option value="file">File</option>
|
|
693
|
+
<option value="image">Image</option>
|
|
694
|
+
<option value="audio">Audio</option>
|
|
695
|
+
<option value="video">Video</option>
|
|
696
|
+
</select>
|
|
697
|
+
</div>
|
|
698
|
+
<div class="attach-form-row">
|
|
699
|
+
<input
|
|
700
|
+
class="attach-input"
|
|
701
|
+
type="text"
|
|
702
|
+
placeholder="Caption (optional)"
|
|
703
|
+
.value=${this._attachCaption}
|
|
704
|
+
@input=${e=>{this._attachCaption=e.target.value}}
|
|
705
|
+
?disabled=${this._actionPending}
|
|
706
|
+
/>
|
|
707
|
+
<button
|
|
708
|
+
class="btn-sm btn-sm-primary"
|
|
709
|
+
@click=${()=>void this._handleAttachSend()}
|
|
710
|
+
?disabled=${this._actionPending||!this._attachUrl.trim()}
|
|
711
|
+
>
|
|
712
|
+
Send Attachment
|
|
713
|
+
</button>
|
|
714
|
+
<button
|
|
715
|
+
class="btn-sm btn-sm-ghost"
|
|
716
|
+
@click=${this._toggleAttachForm}
|
|
717
|
+
?disabled=${this._actionPending}
|
|
718
|
+
>Cancel</button>
|
|
719
|
+
</div>
|
|
720
|
+
</div>
|
|
721
|
+
</div>
|
|
722
|
+
`}_renderPlatformActions(){let e=f[this._effectiveChannel];if(!e)return l;let n=this._effectiveChannel.charAt(0).toUpperCase()+this._effectiveChannel.slice(1);return t`
|
|
723
|
+
<div class="platform-actions">
|
|
724
|
+
<div class="platform-actions-title">
|
|
725
|
+
<ic-platform-icon platform=${this._effectiveChannel}></ic-platform-icon>
|
|
726
|
+
${n} Actions
|
|
727
|
+
</div>
|
|
728
|
+
${e.map(e=>t`
|
|
729
|
+
<div class="action-group-header">${e.group}</div>
|
|
730
|
+
<div class="action-buttons">
|
|
731
|
+
${e.actions.map(e=>{let n=this._getActionInputKey(``,e.action),r=e.needsMessageId&&!this._selectedMessageId;return t`
|
|
732
|
+
${e.needsInput?t`
|
|
733
|
+
<input
|
|
734
|
+
class="action-input"
|
|
735
|
+
type="text"
|
|
736
|
+
placeholder=${e.needsInput}
|
|
737
|
+
.value=${this._actionInputs[n]??``}
|
|
738
|
+
@input=${e=>this._handleActionInputChange(n,e.target.value)}
|
|
739
|
+
?disabled=${this._platformActionPending}
|
|
740
|
+
/>
|
|
741
|
+
`:l}
|
|
742
|
+
<button
|
|
743
|
+
class="btn-sm btn-sm-ghost"
|
|
744
|
+
@click=${()=>void this._handlePlatformAction(e)}
|
|
745
|
+
?disabled=${this._platformActionPending||r}
|
|
746
|
+
title=${r?`Select a message first`:e.label}
|
|
747
|
+
>
|
|
748
|
+
${e.label}
|
|
749
|
+
</button>
|
|
750
|
+
`})}
|
|
751
|
+
</div>
|
|
752
|
+
`)}
|
|
753
|
+
${this._actionResult?t`
|
|
754
|
+
<div class="action-result">${this._actionResult}</div>
|
|
755
|
+
`:l}
|
|
756
|
+
</div>
|
|
757
|
+
`}_renderSendConfirmDialog(){return this._showSendConfirm?t`
|
|
758
|
+
<ic-confirm-dialog
|
|
759
|
+
open
|
|
760
|
+
title="Send Message"
|
|
761
|
+
message="This message will be sent as ${this._botName||this._effectiveChannel} on ${this._effectiveChannel}. You are acting as operator."
|
|
762
|
+
confirmLabel="Send"
|
|
763
|
+
@confirm=${this._handleSendConfirm}
|
|
764
|
+
@cancel=${this._handleSendCancel}
|
|
765
|
+
></ic-confirm-dialog>
|
|
766
|
+
`:l}_renderReplyConfirmDialog(){return this._showReplyConfirm?t`
|
|
767
|
+
<ic-confirm-dialog
|
|
768
|
+
open
|
|
769
|
+
title="Send Reply"
|
|
770
|
+
message="This reply will be sent as ${this._botName||this._effectiveChannel} on ${this._effectiveChannel}. You are acting as operator."
|
|
771
|
+
confirmLabel="Send Reply"
|
|
772
|
+
@confirm=${this._handleReplyConfirm}
|
|
773
|
+
@cancel=${this._handleReplyCancel}
|
|
774
|
+
></ic-confirm-dialog>
|
|
775
|
+
`:l}_renderDeleteConfirmDialog(){return this._showDeleteConfirm?t`
|
|
776
|
+
<ic-confirm-dialog
|
|
777
|
+
open
|
|
778
|
+
title="Delete Message"
|
|
779
|
+
message="This will permanently delete this message from ${this._effectiveChannel}. This cannot be undone."
|
|
780
|
+
variant="danger"
|
|
781
|
+
confirmLabel="Delete"
|
|
782
|
+
@confirm=${this._handleDeleteConfirm}
|
|
783
|
+
@cancel=${this._handleDeleteCancel}
|
|
784
|
+
></ic-confirm-dialog>
|
|
785
|
+
`:l}};c([s({attribute:!1})],m.prototype,`rpcClient`,void 0),c([s({attribute:!1})],m.prototype,`eventDispatcher`,void 0),c([s()],m.prototype,`channelType`,void 0),c([a()],m.prototype,`_loadState`,void 0),c([a()],m.prototype,`_error`,void 0),c([a()],m.prototype,`_messages`,void 0),c([a()],m.prototype,`_effectiveChannel`,void 0),c([a()],m.prototype,`_capabilities`,void 0),c([a()],m.prototype,`_channelList`,void 0),c([a()],m.prototype,`_sendText`,void 0),c([a()],m.prototype,`_showSendConfirm`,void 0),c([a()],m.prototype,`_actionPending`,void 0),c([a()],m.prototype,`_botName`,void 0),c([a()],m.prototype,`_replyToId`,void 0),c([a()],m.prototype,`_replyText`,void 0),c([a()],m.prototype,`_showReplyConfirm`,void 0),c([a()],m.prototype,`_editingId`,void 0),c([a()],m.prototype,`_editText`,void 0),c([a()],m.prototype,`_deleteTargetId`,void 0),c([a()],m.prototype,`_showDeleteConfirm`,void 0),c([a()],m.prototype,`_reactTargetId`,void 0),c([a()],m.prototype,`_showEmojiPicker`,void 0),c([a()],m.prototype,`_attachUrl`,void 0),c([a()],m.prototype,`_attachType`,void 0),c([a()],m.prototype,`_attachCaption`,void 0),c([a()],m.prototype,`_showAttachForm`,void 0),c([a()],m.prototype,`_chatList`,void 0),c([a()],m.prototype,`_selectedChatId`,void 0),c([a()],m.prototype,`_platformActionPending`,void 0),c([a()],m.prototype,`_selectedMessageId`,void 0),c([a()],m.prototype,`_actionResult`,void 0),m=c([e(`ic-message-center`)],m);export{m as IcMessageCenter};
|