@ycodium-ai/plugin-im 0.2.3254 → 0.2.3272
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/README.md +33 -6
- package/assets/ui.js +1 -1
- package/dist/index.js +661 -108
- package/locales/en.json +50 -2
- package/locales/zh-CN.json +50 -2
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -167,7 +167,17 @@ An adapter opts in with the optional `turnCards` surface (`src/adapter.ts`).
|
|
|
167
167
|
Approval messages are posted for every pending request on platforms with
|
|
168
168
|
buttons and replaced with a settled notice when the request is answered, here or
|
|
169
169
|
elsewhere (`thread.request-resolved`); WeCom, which answers by number, posts only
|
|
170
|
-
the first and just stops accepting its number.
|
|
170
|
+
the first and just stops accepting its number. Each bot's **More settings** includes
|
|
171
|
+
an approval timeout in minutes: the default is 60, and 0 turns automatic denial off
|
|
172
|
+
(integers from 0 to 1440). Unanswered approvals are denied automatically at the
|
|
173
|
+
deadline. Lark and Telegram replace the approval card or message with a notice
|
|
174
|
+
stating the number of minutes; platforms without editable approval cards, and
|
|
175
|
+
failed card updates, send the same notice as chat text. The timeout continues from
|
|
176
|
+
the approval's creation time after a restart, including immediately denying
|
|
177
|
+
overdue requests. Changing the setting recalculates pending deadlines immediately;
|
|
178
|
+
setting it to 0 cancels them. Questions have no timeout.
|
|
179
|
+
|
|
180
|
+
On a platform whose `turnCards` set
|
|
171
181
|
`rotatesOnInteraction` (Lark: patching a card does not move it), an approval or
|
|
172
182
|
question that someone answered seals the open reply card as "continues below" and the
|
|
173
183
|
next tick opens a new one under the interaction card (`rotate` in `turnCards.ts`, on
|
|
@@ -200,11 +210,13 @@ the host does not let a plugin dispatch `thread.turn-intent.edit`.
|
|
|
200
210
|
|
|
201
211
|
A chat keeps its place across restarts. Which project a chat picked, which thread
|
|
202
212
|
it is talking in, the team it is pointed at, the model and plan mode set from the
|
|
203
|
-
chat, the threads this plugin has opened, and the approval, question and
|
|
213
|
+
chat, whether this chat's session list includes archived sessions, the threads this plugin has opened, and the approval, question and
|
|
204
214
|
queued-message buttons still waiting in the chat are
|
|
205
215
|
written as plugin facts (`ctx.events.append`) and folded back by a pure function
|
|
206
216
|
(`ctx.derivedState`, see `src/chatState.ts`). A saved thread that was deleted,
|
|
207
217
|
archived or no longer on the chat's project is dropped on the next message.
|
|
218
|
+
Listing archived sessions does not keep that thread. Unarchive it on the web or in another client
|
|
219
|
+
before the next message can continue in it.
|
|
208
220
|
The chat key is `<bot row id>:<chat id>`: two bots in the same person's private chat share
|
|
209
221
|
the chat id, so the key has to carry the bot.
|
|
210
222
|
|
|
@@ -260,9 +272,9 @@ is sent to the chat. `chat_type` (1 single, 2 group) comes from the last inbound
|
|
|
260
272
|
conversation and is left out when none has arrived since the plugin started, as plain text does.
|
|
261
273
|
A picture goes as `image` only when it is PNG, JPEG or GIF within 10 MB (`imageMimeTypes`).
|
|
262
274
|
|
|
263
|
-
Chat commands: `/stop`, `/continue`, `/status`, `/version`, `/new`, `/sessions`, `/resume`, `/history [count]`, `/model`,
|
|
264
|
-
`/reasoning`, `/plan`, `/repo`, `/group`, `/team`, `/thread`, `/help`, `/panel`. In a chat with no project
|
|
265
|
-
`/sessions`, `/resume` and the team commands answer with the project picker. `/version` still
|
|
275
|
+
Chat commands: `/stop`, `/continue`, `/compact`, `/status`, `/version`, `/new`, `/sessions`, `/archived`, `/resume`, `/history [count]`, `/model`,
|
|
276
|
+
`/reasoning`, `/permission`, `/plan`, `/repo`, `/group`, `/team`, `/thread`, `/help`, `/panel`. In a chat with no project
|
|
277
|
+
`/sessions`, `/resume` and the team commands answer with the project picker. `/version` and `/archived` still answer. `/sessions` and `/resume` only list and
|
|
266
278
|
switch threads this plugin opened, since the host lets a plugin send only into
|
|
267
279
|
its own threads. `/continue` calls `threads.turnQueue.resume` for the chat's thread
|
|
268
280
|
when its queue is paused (a `/stop` or a failure pauses it), which is how WeCom
|
|
@@ -272,6 +284,21 @@ resumes a paused queue from the chat; it is not `/resume`, which already switche
|
|
|
272
284
|
|
|
273
285
|
`/version` answers with one line, the plugin name and its version. It takes no arguments; if anything follows it, the reply is a usage reminder. It works in private chats and groups, does not read the session, and does not start a turn. Type it; panels and native command menus do not list it. There is no Chinese alias.
|
|
274
286
|
|
|
287
|
+
`/permission` lists the four numbered permission modes and marks the current mode,
|
|
288
|
+
the bot ceiling, and modes above that ceiling as unavailable. `/permission <number or mode id>`
|
|
289
|
+
saves a choice for this chat; `/permission default` clears it. Only senders explicitly in
|
|
290
|
+
the bot's allowlist can change or clear the choice, including in open chats; admitted
|
|
291
|
+
senders outside the list can view it. Each turn uses the stricter of the chat choice
|
|
292
|
+
and the bot's current setting, so tightening the bot setting also limits saved choices.
|
|
293
|
+
Changes apply from the next turn, survive restarts, and do not change a running turn.
|
|
294
|
+
With Chinese replies, `权限` and `权限 默认` work too. This is a typed command in private
|
|
295
|
+
chats and groups, listed in `/help`; command panels, Telegram menus, Lark native menus
|
|
296
|
+
and WeCom panels do not add a permission picker. See [Chat permissions](../../docs/user/im-bots.md#chat-permissions).
|
|
297
|
+
|
|
298
|
+
`/compact` asks the current session to compact its context. It takes no arguments; if anything follows it, the reply is a usage reminder. With no current session, while a turn is still running, or when the current model's agent does not support compaction, it replies and does not start compaction. When the request is accepted, it replies that compaction has started, then sends one message to the chat that requested it when compaction completes or fails. If two chats request compaction for the same session, only the latest chat receives the result. Pending replies are kept in memory: after Ycodium or the plugin restarts, it no longer sends results for those requests. Type it; panels and native command menus do not list it, because support depends on the current model and the WeCom main menu already holds six buttons. With the reply language set to Chinese, `压缩` works too.
|
|
299
|
+
|
|
300
|
+
`/archived on` makes this chat's session list (`/sessions`, and the same list on the command panel) include archived sessions, each marked as archived. `/archived off` lists only sessions that are not archived. `/archived` with no argument replies with the current setting and how to use it; anything other than on or off gets the same reply and does not change the setting. on and off ignore case. The choice is remembered on this chat and kept across restarts. A chat that has never set it lists only sessions that are not archived. An archived session shows up only as a row in that list; open it on the web to read it. `/resume` by number or by the start of an id, and a tap on that row in the command panel, does not switch to it or unarchive it. The bot says the session is archived and cannot be continued, and the chat stays on its current session. Unarchive it on the web or in another client first, then switch to it, or send `/new` to start a new one. It works before a project is picked. Type it; panels and native command menus do not list it, because it is a low-frequency switch and the WeCom main menu already holds six buttons. There is no Chinese alias.
|
|
301
|
+
|
|
275
302
|
On Lark, Telegram, and the WeCom smart bot, `/panel` sends a command panel, and `/help` stays text and ends with a pointer to it. WeCom App does not implement the panel surface, so `/panel` answers with the text list and `/help` does not mention `/panel`. Lark cards and Telegram inline keyboards show all command buttons. The WeCom smart bot uses a template card from `src/wecomPanel.ts`; its main menu is limited to six buttons. Commands that do not fit are listed in `/help` and can be typed into the chat. Commands that take an argument (a thread, a project, a model) open a second view on the same message with a Back button. These lists let you reach every option by paging: Lark and Telegram show eight items per page, and WeCom shows three, leaving room for Back, Previous, and Next. A tap on the WeCom card updates that same card; when the update cannot be applied, `src/panelController.ts` posts a new card and the old one stops accepting taps. A busy placeholder is not drawn on that card: it stays as it is until the next interactive view. Telegram buttons carry only a short `pn:<version>:<index>` token (`callback_data` is capped at 64 bytes); the action stays in memory and a tap on an older keyboard version counts as expired. Each card keeps its own view stack in memory (`src/panelController.ts`), so after a restart an old card only answers that it has expired. A tap runs the same handler as the typed command and waits in the same per-chat queue as typed messages. Another platform opts in by implementing the optional `panel` surface on its adapter (`src/adapter.ts`).
|
|
276
303
|
|
|
277
304
|
`/reasoning` shows the current model's reasoning efforts; `/reasoning <value>` or `/reasoning <number>` switches it. Numbers follow the available values at the time you send the command, so send `/reasoning` first to check the choices. See [Model and Plan Mode](../../docs/user/im-bots.md#model-and-plan-mode) for details.
|
|
@@ -294,7 +321,7 @@ calls its tool (`workspace.read`, used only by `im_send_file`). Its generated se
|
|
|
294
321
|
require the `commands.dispatch` declarations for `thread.create`,
|
|
295
322
|
`thread.meta.update`, `thread.turn.start`, `thread.turn.interrupt`,
|
|
296
323
|
`thread.approval.respond`, `thread.user-input.respond`, `thread.turn-intent.run`,
|
|
297
|
-
`thread.turn-intent.cancel
|
|
324
|
+
`thread.turn-intent.cancel`, `thread.turn-queue.resume` and `thread.context.compact`. The plugin calls the generated
|
|
298
325
|
`threads` and `approvals` ports; it does not send session commands through
|
|
299
326
|
`commands.dispatch`. These ports only write to threads this plugin started.
|
|
300
327
|
|
package/assets/ui.js
CHANGED
|
@@ -2,7 +2,7 @@ var Vn=window.__ycodiumPluginHost.react;var{Activity:Zn,Children:et,Component:nt
|
|
|
2
2
|
|
|
3
3
|
`)}),i("div",{className:"im-actions",children:i(p,{variant:"ghost",size:"sm",onClick:()=>{fe(e.bridge,a.join(`
|
|
4
4
|
|
|
5
|
-
`),d)},children:d("settingsSection.copy")})})]})]})}function Hn(e){return e.length>12?`${e.slice(0,8)}\u2022\u2022\u2022\u2022${e.slice(-4)}`:"cli_\u2022\u2022\u2022\u2022"}function kn(e){return e.length<=10?`${e.slice(0,3)}\u2022\u2022\u2022`:`${e.slice(0,6)}\u2022\u2022\u2022\u2022${e.slice(-4)}`}var zn={lark:{column:"larkAppId",mask:Hn},wecom:{column:"wecomBotId",mask:kn},"wecom-app":{column:"wecomAppCorpId",mask:kn}};function Tn(e,n){let t=zn[e];if(t===void 0)return null;let o=O(n,t.column);return o===""?null:t.mask(o)}function Ne(e){return s(yn,{className:e.className===void 0?"im-collapse":`im-collapse ${e.className}`,...e.defaultOpen===void 0?{}:{defaultOpen:e.defaultOpen},...e.open===void 0?{}:{open:e.open},...e.onOpenChange===void 0?{}:{onOpenChange:e.onOpenChange},children:[s("div",{className:"im-head",children:[s(fn,{className:"im-toggle",children:[i("span",{className:"im-chevron","aria-hidden":"true"}),e.icon,i("span",{className:"im-title im-medium",children:e.title}),e.meta]}),e.actions]}),e.notice,i(pn,{children:i("div",{className:"im-panel",children:e.children})})]})}function ve(e){return i("section",{className:"im-block",children:i(Ne,{...e})})}var _e="\0empty";function Nn(e){let n=e.columns.filter(m=>Ye(m,e.values)),t=e.groupBotSettings?n.filter(m=>m.group==="essential"):n,o=e.groupBotSettings?n.filter(m=>m.group!=="essential"):[],l=e.issues.filter(m=>o.some(f=>f.key===m.column)),r=JSON.stringify(l),[a,d]=R(()=>({open:l.length>0,issues:r})),u=a.open||a.issues!==r&&l.length>0;a.issues!==r&&d({open:u,issues:r});let g=m=>i(Qn,{column:m,scope:e.scope,environmentId:e.environmentId,proxies:e.proxies,values:e.values,savedValues:e.savedValues,secrets:e.secrets,clearSecrets:e.clearSecrets,storedSecrets:e.storedSecrets,issues:e.issues,disabled:e.disabled,t:e.t,onValue:e.onValue,onSecret:e.onSecret,onToggleClear:e.onToggleClear},m.key);return s(T,{children:[t.map(g),e.publicFields.map(m=>i(jn,{field:m,scope:e.scope,environmentId:e.environmentId,bridge:e.bridge,t:e.t},m.key)),o.length===0?null:i(Ne,{className:"im-span",title:l.length>0?e.t("settingsSection.moreSettingsIssues",{count:l.length}):e.t("settingsSection.moreSettings"),open:u,onOpenChange:m=>d({open:m,issues:r}),children:i("div",{className:"im-form",children:o.map(g)})})]})}function Qn(e){let n=e.column,t=D(e.environmentId,e.scope,n.key),o=Q(e.t,n.labelKey,n.label)??n.key,l=Q(e.t,n.descriptionKey,n.description),r=Q(e.t,n.placeholderKey,n.placeholder),a=xn(e.t,e.issues.filter(u=>u.column===n.key).map(u=>u.code)),d=ee(t,a!==null,l!==void 0);return n.kind==="password"?i(B,{id:t,label:o,description:l,issue:a,children:i(ge,{id:t,value:e.secrets[n.key]??"",stored:e.storedSecrets[n.key]===!0,clearing:e.clearSecrets.includes(n.key),disabled:e.disabled,invalid:a!==null,describedBy:d,placeholder:r,savedPlaceholder:e.t("settingsSection.secret.saved"),clearLabel:e.t("settingsSection.secret.clear"),undoLabel:e.t("settingsSection.secret.clearUndo"),onChange:u=>{u!==(e.secrets[n.key]??"")&&e.onSecret(n.key,u)},onToggleClear:()=>e.onToggleClear(n.key)})}):n.kind==="select"?i(Wn,{column:n,id:t,label:o,description:l,issue:a,described:d,values:e.values,savedValues:e.savedValues,disabled:e.disabled,t:e.t,onValue:e.onValue}):n.kind==="proxy"?i("div",{className:"im-field",children:i(bn,{id:t,label:o,hint:l,value:e.values[n.key]??"",proxies:e.proxies,disabled:e.disabled,onChange:u=>{u!==(e.values[n.key]??"")&&e.onValue(n.key,u)},children:a===null?null:i("p",{id:`${t}-issue`,className:"im-small im-issue",role:"alert",children:a})})}):i(B,{id:t,label:o,description:l,issue:a,children:i($,{id:t,type:"text",value:e.values[n.key]??"",placeholder:r,disabled:e.disabled,"aria-invalid":a!==null?!0:void 0,"aria-describedby":d,onChange:u=>{let g=u.target.value;g!==(e.values[n.key]??"")&&e.onValue(n.key,g)}})})}function Wn(e){let n=e.values[e.column.key]??"",t=e.savedValues[e.column.key]??"",o=e.column.options??[],l=o.some(u=>u.value===""),r=o.find(u=>u.value===n),a=u=>e.column.unavailableLabelKey===void 0?u:e.t(e.column.unavailableLabelKey,{value:u}),d=n===""&&r===void 0?void 0:r===void 0?a(n):Q(e.t,r.labelKey,r.label)??r.value;return i(B,{id:e.id,label:e.label,description:e.description,issue:e.issue,children:s(se,{className:"im-wide",value:n===""?l?_e:null:n,disabled:e.disabled,onValueChange:u=>{let g=l&&u===_e?"":u??"";g!==n&&e.onValue(e.column.key,g)},children:[i(de,{id:e.id,"aria-invalid":e.issue!==null?!0:void 0,"aria-describedby":e.described,children:d===void 0?i(Y,{placeholder:e.t("settingsSection.select.default")}):i(Y,{children:d})}),s(ce,{children:[e.column.listsUnknownValue===!0&&t!==""&&!o.some(u=>u.value===t)?i(J,{value:t,disabled:e.column.unavailableLabelKey!==void 0,children:a(t)}):null,o.map(u=>i(J,{value:u.value===""?_e:u.value,children:Q(e.t,u.labelKey,u.label)??u.value},u.value))]})]})})}function jn(e){let n=D(e.environmentId,`${e.scope}-pub`,e.field.key);return s("div",{className:"im-field im-span",children:[i(G,{children:e.t(`settingsSection.publicField.${e.field.key}`)}),e.field.value===""?null:s("div",{className:"im-inline im-public-row",children:[i("span",{id:n,className:"im-public-value im-small",children:qn(e.field.value)}),e.field.copyable?i(p,{variant:"ghost",size:"sm",onClick:()=>{fe(e.bridge,e.field.value,e.t)},children:e.t("settingsSection.copy")}):null]}),e.field.hint===void 0?null:i("p",{className:"im-small im-muted",children:e.t(`settingsSection.publicFieldHint.${e.field.hint}`)})]})}function qn(e){let n=0;return e.split(/(?<=\/)(?!\/)/).map(t=>{let o=n;return n+=t.length,s(Le,{children:[o===0?null:i("wbr",{}),t]},o)})}function _n(e){let n={};for(let[r,a]of Object.entries(e.values))(e.baseline[r]??"")!==a&&(n[r]=a);let t={};for(let[r,a]of Object.entries(e.secrets))a!==""&&(t[r]=a);let o=[];for(let r of e.clearSecrets)Object.hasOwn(t,r)||o.includes(r)||o.push(r);return e.rowId===void 0||Object.keys(n).length>0||Object.keys(t).length>0||o.length>0?{changed:!0,edit:{...e.rowId===void 0?{}:{rowId:e.rowId},values:n,...Object.keys(t).length>0?{secrets:t}:{},...o.length>0?{clearSecrets:o}:{}}}:{changed:!1}}function Yn(e){let n=e.trim();if(!/^\d+$/.test(n))return null;let t=Number(n);return!Number.isInteger(t)||t<1||t>65535?null:t}function En(e){let n={};e.replyLanguage!==e.baseline.replyLanguage&&(n.replyLanguage=e.replyLanguage),e.enabled!==e.baseline.enabled&&(n.deliveryHttpEnabled=e.enabled);let t=!1;if(e.enabled){let o=Yn(e.port);o===null?t=!0:o!==e.baseline.port&&(n.deliveryHttpPort=o),e.token!==""?n.deliveryHttpToken=e.token:e.clearToken&&e.baseline.hasToken&&(n.clearDeliveryHttpToken=!0)}return t?{changed:!0,invalidPort:!0}:Object.keys(n).length===0?{changed:!1}:{changed:!0,invalidPort:!1,payload:n}}var Pn=ie({activeId:null,activate:()=>{}});function An(e){return i(Pn,{value:{activeId:e.activeId,activate:e.activate},children:e.children})}function be(e){let n=oe(Pn);return{chosen:n.activeId===e,activate:()=>n.activate(e)}}function Se(e,n){let t=A(!1);return{cancelProps:{autoFocus:!0,"aria-describedby":e,onClick:()=>{t.current=!0,n()}},confirmProps:{"aria-describedby":e},triggerRef:o=>{o===null||!t.current||(t.current=!1,o.focus())}}}function Ie(e,n){return{signature:n,values:{...e?.values},secrets:{},clearSecrets:[],saving:!1,failed:!1,confirming:!1,removing:!1,removeFailed:!1}}function Ee(e){let{kind:n,row:t}=e,o=t===null?n.newSlot:JSON.stringify(t),l=be(Z(n.newSlot,t?.rowId??null)),r=A(0),[a,d]=R(()=>Ie(t,o)),u=t!==null&&n.removeHintKey!==void 0?`im-remove-consequence-${n.newSlot}-${t.rowId}`:void 0,g=Se(u,()=>d(y=>({...y,confirming:!1})));a.signature!==o&&(r.current+=1,d(Ie(t,o)));let m=_n({...t===null?{}:{rowId:t.rowId},baseline:t?.values??{},values:a.values,secrets:a.secrets,clearSecrets:a.clearSecrets}),f=m.changed,h=t===null||!t.configured,b=e.status??ke(t),w=e.notice??null,c=a.saving||a.removing;function x(y){l.activate(),d(v=>({...y(v),failed:!1}))}function k(){if(!m.changed||c)return;l.activate();let y=m.edit,v=++r.current;d(I=>({...I,saving:!0,failed:!1})),X(e.bridge,n.saveCommand,y,P(e.environmentId)).then(I=>{if(r.current!==v)return;if(I===null){d(U=>({...U,saving:!1,failed:!0}));return}let E=t===null?void 0:n.rows(I).find(U=>U.rowId===t.rowId);E!==void 0&&d(Ie(E,JSON.stringify(E))),e.onSaved(I)})}function L(){if(t===null){e.onDiscard();return}let y=t.rowId,v=++r.current;d(I=>({...I,removing:!0,removeFailed:!1})),X(e.bridge,n.removeCommand,{rowId:y},P(e.environmentId)).then(I=>{if(r.current===v){if(I===null){d(E=>({...E,removing:!1,removeFailed:!0,confirming:!0}));return}e.onSaved(I)}})}return s(ve,{title:e.title(a.values),icon:e.icon?.(a.values),defaultOpen:h,meta:s(T,{children:[e.meta?.(a.values),s("span",{className:"im-status",children:[e.statusMeta,i(ue,{tone:b.tone,children:e.t(b.key)})]})]}),actions:a.confirming?s("div",{className:"im-actions",children:[i(p,{type:"button",variant:"ghost",size:"sm",disabled:a.removing||a.saving,...g.cancelProps,children:e.t("settingsSection.cancel")}),i(p,{type:"button",variant:"destructive",size:"sm",disabled:a.removing||a.saving,...g.confirmProps,onClick:L,children:e.t(n.removeConfirmKey)})]}):i(p,{type:"button",variant:"ghost",size:"sm",disabled:c,ref:g.triggerRef,onClick:()=>d(y=>({...y,confirming:!0,removeFailed:!1})),children:e.t("settingsSection.remove")}),notice:s(T,{children:[e.summary,a.confirming&&t!==null&&n.removeHintKey!==void 0?i("p",{id:u,children:e.t(n.removeHintKey)}):null,a.removeFailed?i("p",{className:"im-small im-issue",role:"alert",children:e.t(n.removeFailedKey)}):null]}),children:[w===null?null:i(H,{variant:w.variant,children:i(z,{children:w.text})}),s("div",{className:"im-form",children:[i(Nn,{scope:`${n.newSlot}-${t?.rowId??"new"}`,environmentId:e.environmentId,columns:e.columns,groupBotSettings:n.groupBotSettings===!0,proxies:e.proxies,values:a.values,savedValues:t?.values??{},secrets:a.secrets,clearSecrets:a.clearSecrets,storedSecrets:t?.secrets??{},issues:t?.issues??[],publicFields:t?.publicFields??[],disabled:c,bridge:e.bridge,t:e.t,onValue:(y,v)=>x(I=>({...I,values:{...I.values,[y]:v}})),onSecret:(y,v)=>x(I=>({...I,secrets:{...I.secrets,[y]:v}})),onToggleClear:y=>x(v=>({...v,clearSecrets:v.clearSecrets.includes(y)?v.clearSecrets.filter(I=>I!==y):[...v.clearSecrets,y]}))}),e.extra?.({dirty:f,frozen:c}),i(ye,{dirty:f,saving:a.saving,busy:a.removing,solid:l.chosen&&f,failed:a.failed,saveLabel:e.t("settingsSection.save"),revertLabel:e.t("settingsSection.revert"),failedLabel:e.t("settingsSection.saveFailed"),onSave:k,onRevert:()=>{r.current+=1,d(Ie(t,o))}})]})]})}function On(e){let n=e.bridge.useFormatTimestamp(),{error:t,t:o}=e;if(t===void 0)return null;let l=new Date(t.at),r=Number.isFinite(l.getTime())?l.toISOString():null;return s("div",{className:"im-small",role:"status",children:[s("p",{children:[i("strong",{className:"im-issue",children:o("settingsSection.lastMessageError.title")}),o("settingsSection.lastMessageError.separator"),i("span",{children:t.messageKey===void 0?t.message:o(t.messageKey,{...t.messageParams,defaultValue:t.message})})]}),s("p",{className:"im-muted",children:[o("settingsSection.lastMessageError.code",{code:t.code})," \xB7 ",o("settingsSection.lastMessageError.reference",{referenceId:t.referenceId}),r===null?null:s(T,{children:[" \xB7 ",i("time",{dateTime:r,children:n(r)})]})]})]})}var we={groupBotSettings:!0,newSlot:"im-new-row",saveCommand:De,removeCommand:Ue,rows:e=>e.bots,removeConfirmKey:"settingsSection.removeConfirm",removeHintKey:"settingsSection.removeHint",removeFailedKey:"settingsSection.removeFailed"},Ce={newSlot:"im-new-target",saveCommand:Ge,removeCommand:He,rows:e=>e.targets,removeConfirmKey:"settingsSection.target.removeConfirm",removeFailedKey:"settingsSection.target.removeFailed"},Bn=(e,n,t)=>{let o=(e.displayName??"").trim();return o.length>0?o:t(`platform.${n}`)};function Pe(e){let{bot:n,t}=e,o=e.bots.find(f=>f.rowId===(n===null?void 0:e.connections?.[n.rowId]?.duplicateOf)),l=an(n,e.connections,o===void 0?void 0:Bn(o.values,o.platform,t),t),[r,a]=R(null),[d,u]=R(!1),g=n===null?void 0:`im-reset-consequence-${n.rowId}`,m=Se(g,()=>u(!1));return i(Ee,{...e,kind:we,row:n,status:rn(n,e.connections),statusMeta:n?.configured&&e.connections?.[n.rowId]?.statusSince!==void 0?i(ln,{since:e.connections[n.rowId]?.statusSince,bridge:e.bridge,t}):null,notice:l,summary:n===null?null:i(On,{error:e.connections?.[n.rowId]?.lastMessageError,bridge:e.bridge,t}),title:f=>Bn(f,ae(f),t),icon:f=>{let h=O(f,"platform");if(h==="")return null;let w=e.columns.find(c=>c.key==="platform")?.options?.find(c=>c.value===h)?.icon;return w?i(un,{name:w}):null},meta:f=>{let h=ae(f),b=Tn(h,f),w=t(`platform.${h}`);return i("span",{className:"im-small im-muted",...b===null?{}:{title:b},children:b===null?w:`${w} \xB7 ${b}`})},extra:({dirty:f,frozen:h})=>{if(n===null)return null;let b=In(n.platform,f,h,e.connections?.[n.rowId]),w=b.actions.find(c=>c.id==="resetInbox");return s(T,{children:[s("div",{className:"im-span",children:[d&&w!==void 0?s(T,{children:[i("p",{id:g,children:w.descriptionKeys.map(c=>t(c)).join(" ")}),s("div",{className:"im-actions",children:[i(p,{type:"button",variant:"ghost",size:"sm",disabled:h,...m.cancelProps,children:t("settingsSection.cancel")}),i(p,{type:"button",variant:"destructive",size:"sm",disabled:w.disabled,...m.confirmProps,onClick:()=>{u(!1),a({id:"resetInbox",payload:{rowId:n.rowId}})},children:t("rowAction.resetInbox.confirm")})]})]}):i("div",{className:"im-actions",children:b.actions.map(c=>i(p,{type:"button",variant:"ghost",size:"sm",disabled:c.disabled,title:c.descriptionKeys.map(x=>t(x,c.descriptionParams)).join(" "),ref:c.id==="resetInbox"?m.triggerRef:void 0,onClick:()=>{c.id==="resetInbox"?u(!0):a({id:c.id,payload:{rowId:n.rowId}})},children:t(c.labelKey)},c.id))}),b.noteKey!==null?i("p",{className:"im-small im-muted",children:t(b.noteKey)}):null]}),r===null?null:i(pe,{bridge:e.bridge,command:We[r.id],payload:r.payload,items:"latest",environmentId:e.environmentId,t,onClose:()=>a(null)},r.id)]})}})}function Ae(e){let{t:n}=e;return i(Ee,{...e,kind:Ce,row:e.target,title:t=>{let o=(t.name??"").trim()||(t.targetId??"").trim();return o.length>0?o:n("settingsSection.target.untitled")}})}var Jn="im-general";function he(e,n){return{signature:n,replyLanguage:e.replyLanguage,enabled:e.delivery.enabled,port:String(e.delivery.port),token:"",clearToken:!1,saving:!1,failed:!1}}function Ln(e){let n=e.view,t=Te(n),o=be(Jn),l=A(0),[r,a]=R(()=>he(n,t));r.signature!==t&&(l.current+=1,a(he(n,t)));let d=En({baseline:{replyLanguage:n.replyLanguage,enabled:n.delivery.enabled,port:n.delivery.port,hasToken:n.delivery.hasToken},replyLanguage:r.replyLanguage,enabled:r.enabled,port:r.port,token:r.token,clearToken:r.clearToken}),u=d.changed,g=d.changed&&d.invalidPort,m=D(e.environmentId,"general","port"),f=D(e.environmentId,"general","token"),h=D(e.environmentId,"general","language");function b(c){o.activate(),a(x=>({...x,...c,failed:!1}))}function w(){if(!d.changed||r.saving)return;if(o.activate(),d.invalidPort){a(k=>({...k,failed:!0}));return}let c=d.payload,x=++l.current;a(k=>({...k,saving:!0,failed:!1})),X(e.bridge,$e,c,P(e.environmentId)).then(k=>{if(l.current===x){if(k===null){a(L=>({...L,saving:!1,failed:!0}));return}a(he(k,Te(k))),e.onSaved(k)}})}return i(ve,{title:e.t("settingsSection.general"),defaultOpen:!1,children:s("div",{className:"im-form",children:[i(B,{id:h,label:e.t("settings.language.label"),description:e.t("settings.language.description"),children:s(se,{className:"im-wide",value:r.replyLanguage,disabled:r.saving,onValueChange:c=>{let x=re.find(k=>k.value===c);x===void 0||x.value===r.replyLanguage||b({replyLanguage:x.value})},children:[i(de,{id:h,"aria-describedby":`${h}-hint`,children:i(Y,{children:re.filter(c=>c.value===r.replyLanguage).map(c=>e.t(c.labelKey))})}),i(ce,{children:re.map(c=>i(J,{value:c.value,children:e.t(c.labelKey)},c.value))})]})}),s("div",{className:"im-field",children:[s(G,{className:"im-inline",children:[i("span",{className:"im-medium",children:e.t("settings.deliveryHttp.enabled.label")}),i(cn,{checked:r.enabled,disabled:r.saving,onCheckedChange:c=>{c!==r.enabled&&b({enabled:c})}})]}),i("p",{className:"im-small im-muted",children:e.t("settings.deliveryHttp.enabled.description")})]}),r.enabled?i(B,{id:m,label:e.t("settings.deliveryHttp.port.label"),description:e.t("settings.deliveryHttp.port.description"),issue:g?e.t("settingsSection.issue.format"):null,children:i($,{id:m,type:"number",value:r.port,disabled:r.saving,"aria-invalid":g?!0:void 0,"aria-describedby":ee(m,g,!0),onChange:c=>{c.target.value!==r.port&&b({port:c.target.value})}})}):null,r.enabled?i(B,{id:f,label:e.t("settings.deliveryHttp.token.label"),description:e.t("settings.deliveryHttp.token.description"),children:i(ge,{id:f,value:r.token,stored:n.delivery.hasToken,clearing:r.clearToken,disabled:r.saving,invalid:!1,describedBy:ee(f,!1,!0),savedPlaceholder:e.t("settingsSection.secret.saved"),clearLabel:e.t("settingsSection.secret.clear"),undoLabel:e.t("settingsSection.secret.clearUndo"),onChange:c=>{c!==r.token&&b({token:c})},onToggleClear:()=>b({clearToken:!r.clearToken})})}):null,i(ye,{dirty:u,saving:r.saving,solid:o.chosen&&u,failed:r.failed,saveLabel:e.t("settingsSection.save"),revertLabel:e.t("settingsSection.revert"),failedLabel:e.t("settingsSection.saveFailed"),onSave:w,onRevert:()=>{l.current+=1,a(he(n,t))}})]})})}var Mn=`
|
|
5
|
+
`),d)},children:d("settingsSection.copy")})})]})]})}function Hn(e){return e.length>12?`${e.slice(0,8)}\u2022\u2022\u2022\u2022${e.slice(-4)}`:"cli_\u2022\u2022\u2022\u2022"}function kn(e){return e.length<=10?`${e.slice(0,3)}\u2022\u2022\u2022`:`${e.slice(0,6)}\u2022\u2022\u2022\u2022${e.slice(-4)}`}var zn={lark:{column:"larkAppId",mask:Hn},wecom:{column:"wecomBotId",mask:kn},"wecom-app":{column:"wecomAppCorpId",mask:kn}};function Tn(e,n){let t=zn[e];if(t===void 0)return null;let o=O(n,t.column);return o===""?null:t.mask(o)}function Ne(e){return s(yn,{className:e.className===void 0?"im-collapse":`im-collapse ${e.className}`,...e.defaultOpen===void 0?{}:{defaultOpen:e.defaultOpen},...e.open===void 0?{}:{open:e.open},...e.onOpenChange===void 0?{}:{onOpenChange:e.onOpenChange},children:[s("div",{className:"im-head",children:[s(fn,{className:"im-toggle",children:[i("span",{className:"im-chevron","aria-hidden":"true"}),e.icon,i("span",{className:"im-title im-medium",children:e.title}),e.meta]}),e.actions]}),e.notice,i(pn,{children:i("div",{className:"im-panel",children:e.children})})]})}function ve(e){return i("section",{className:"im-block",children:i(Ne,{...e})})}var _e="\0empty";function Nn(e){let n=e.columns.filter(m=>Ye(m,e.values)),t=e.groupBotSettings?n.filter(m=>m.group==="essential"):n,o=e.groupBotSettings?n.filter(m=>m.group!=="essential"):[],l=e.issues.filter(m=>o.some(f=>f.key===m.column)),r=JSON.stringify(l),[a,d]=R(()=>({open:l.length>0,issues:r})),u=a.open||a.issues!==r&&l.length>0;a.issues!==r&&d({open:u,issues:r});let g=m=>i(Qn,{column:m,scope:e.scope,environmentId:e.environmentId,proxies:e.proxies,values:e.values,savedValues:e.savedValues,secrets:e.secrets,clearSecrets:e.clearSecrets,storedSecrets:e.storedSecrets,issues:e.issues,disabled:e.disabled,t:e.t,onValue:e.onValue,onSecret:e.onSecret,onToggleClear:e.onToggleClear},m.key);return s(T,{children:[t.map(g),e.publicFields.map(m=>i(jn,{field:m,scope:e.scope,environmentId:e.environmentId,bridge:e.bridge,t:e.t},m.key)),o.length===0?null:i(Ne,{className:"im-span",title:l.length>0?e.t("settingsSection.moreSettingsIssues",{count:l.length}):e.t("settingsSection.moreSettings"),open:u,onOpenChange:m=>d({open:m,issues:r}),children:i("div",{className:"im-form",children:o.map(g)})})]})}function Qn(e){let n=e.column,t=D(e.environmentId,e.scope,n.key),o=Q(e.t,n.labelKey,n.label)??n.key,l=Q(e.t,n.descriptionKey,n.description),r=Q(e.t,n.placeholderKey,n.placeholder),a=xn(e.t,e.issues.filter(u=>u.column===n.key).map(u=>u.code)),d=ee(t,a!==null,l!==void 0);return n.kind==="password"?i(B,{id:t,label:o,description:l,issue:a,children:i(ge,{id:t,value:e.secrets[n.key]??"",stored:e.storedSecrets[n.key]===!0,clearing:e.clearSecrets.includes(n.key),disabled:e.disabled,invalid:a!==null,describedBy:d,placeholder:r,savedPlaceholder:e.t("settingsSection.secret.saved"),clearLabel:e.t("settingsSection.secret.clear"),undoLabel:e.t("settingsSection.secret.clearUndo"),onChange:u=>{u!==(e.secrets[n.key]??"")&&e.onSecret(n.key,u)},onToggleClear:()=>e.onToggleClear(n.key)})}):n.kind==="select"?i(Wn,{column:n,id:t,label:o,description:l,issue:a,described:d,values:e.values,savedValues:e.savedValues,disabled:e.disabled,t:e.t,onValue:e.onValue}):n.kind==="proxy"?i("div",{className:"im-field",children:i(bn,{id:t,label:o,hint:l,value:e.values[n.key]??"",proxies:e.proxies,disabled:e.disabled,onChange:u=>{u!==(e.values[n.key]??"")&&e.onValue(n.key,u)},children:a===null?null:i("p",{id:`${t}-issue`,className:"im-small im-issue",role:"alert",children:a})})}):i(B,{id:t,label:o,description:l,issue:a,children:i($,{id:t,type:n.kind==="number"?"number":"text",min:n.min,max:n.max,step:n.kind==="number"?1:void 0,value:e.values[n.key]??n.defaultValue??"",placeholder:r,disabled:e.disabled,"aria-invalid":a!==null?!0:void 0,"aria-describedby":d,onChange:u=>{let g=u.target.value;g!==(e.values[n.key]??"")&&e.onValue(n.key,g)}})})}function Wn(e){let n=e.values[e.column.key]??"",t=e.savedValues[e.column.key]??"",o=e.column.options??[],l=o.some(u=>u.value===""),r=o.find(u=>u.value===n),a=u=>e.column.unavailableLabelKey===void 0?u:e.t(e.column.unavailableLabelKey,{value:u}),d=n===""&&r===void 0?void 0:r===void 0?a(n):Q(e.t,r.labelKey,r.label)??r.value;return i(B,{id:e.id,label:e.label,description:e.description,issue:e.issue,children:s(se,{className:"im-wide",value:n===""?l?_e:null:n,disabled:e.disabled,onValueChange:u=>{let g=l&&u===_e?"":u??"";g!==n&&e.onValue(e.column.key,g)},children:[i(de,{id:e.id,"aria-invalid":e.issue!==null?!0:void 0,"aria-describedby":e.described,children:d===void 0?i(Y,{placeholder:e.t("settingsSection.select.default")}):i(Y,{children:d})}),s(ce,{children:[e.column.listsUnknownValue===!0&&t!==""&&!o.some(u=>u.value===t)?i(J,{value:t,disabled:e.column.unavailableLabelKey!==void 0,children:a(t)}):null,o.map(u=>i(J,{value:u.value===""?_e:u.value,children:Q(e.t,u.labelKey,u.label)??u.value},u.value))]})]})})}function jn(e){let n=D(e.environmentId,`${e.scope}-pub`,e.field.key);return s("div",{className:"im-field im-span",children:[i(G,{children:e.t(`settingsSection.publicField.${e.field.key}`)}),e.field.value===""?null:s("div",{className:"im-inline im-public-row",children:[i("span",{id:n,className:"im-public-value im-small",children:qn(e.field.value)}),e.field.copyable?i(p,{variant:"ghost",size:"sm",onClick:()=>{fe(e.bridge,e.field.value,e.t)},children:e.t("settingsSection.copy")}):null]}),e.field.hint===void 0?null:i("p",{className:"im-small im-muted",children:e.t(`settingsSection.publicFieldHint.${e.field.hint}`)})]})}function qn(e){let n=0;return e.split(/(?<=\/)(?!\/)/).map(t=>{let o=n;return n+=t.length,s(Le,{children:[o===0?null:i("wbr",{}),t]},o)})}function _n(e){let n={};for(let[r,a]of Object.entries(e.values))(e.baseline[r]??"")!==a&&(n[r]=a);let t={};for(let[r,a]of Object.entries(e.secrets))a!==""&&(t[r]=a);let o=[];for(let r of e.clearSecrets)Object.hasOwn(t,r)||o.includes(r)||o.push(r);return e.rowId===void 0||Object.keys(n).length>0||Object.keys(t).length>0||o.length>0?{changed:!0,edit:{...e.rowId===void 0?{}:{rowId:e.rowId},values:n,...Object.keys(t).length>0?{secrets:t}:{},...o.length>0?{clearSecrets:o}:{}}}:{changed:!1}}function Yn(e){let n=e.trim();if(!/^\d+$/.test(n))return null;let t=Number(n);return!Number.isInteger(t)||t<1||t>65535?null:t}function En(e){let n={};e.replyLanguage!==e.baseline.replyLanguage&&(n.replyLanguage=e.replyLanguage),e.enabled!==e.baseline.enabled&&(n.deliveryHttpEnabled=e.enabled);let t=!1;if(e.enabled){let o=Yn(e.port);o===null?t=!0:o!==e.baseline.port&&(n.deliveryHttpPort=o),e.token!==""?n.deliveryHttpToken=e.token:e.clearToken&&e.baseline.hasToken&&(n.clearDeliveryHttpToken=!0)}return t?{changed:!0,invalidPort:!0}:Object.keys(n).length===0?{changed:!1}:{changed:!0,invalidPort:!1,payload:n}}var Pn=ie({activeId:null,activate:()=>{}});function An(e){return i(Pn,{value:{activeId:e.activeId,activate:e.activate},children:e.children})}function be(e){let n=oe(Pn);return{chosen:n.activeId===e,activate:()=>n.activate(e)}}function Se(e,n){let t=A(!1);return{cancelProps:{autoFocus:!0,"aria-describedby":e,onClick:()=>{t.current=!0,n()}},confirmProps:{"aria-describedby":e},triggerRef:o=>{o===null||!t.current||(t.current=!1,o.focus())}}}function Ie(e,n){return{signature:n,values:{...e?.values},secrets:{},clearSecrets:[],saving:!1,failed:!1,confirming:!1,removing:!1,removeFailed:!1}}function Ee(e){let{kind:n,row:t}=e,o=t===null?n.newSlot:JSON.stringify(t),l=be(Z(n.newSlot,t?.rowId??null)),r=A(0),[a,d]=R(()=>Ie(t,o)),u=t!==null&&n.removeHintKey!==void 0?`im-remove-consequence-${n.newSlot}-${t.rowId}`:void 0,g=Se(u,()=>d(y=>({...y,confirming:!1})));a.signature!==o&&(r.current+=1,d(Ie(t,o)));let m=_n({...t===null?{}:{rowId:t.rowId},baseline:t?.values??{},values:a.values,secrets:a.secrets,clearSecrets:a.clearSecrets}),f=m.changed,h=t===null||!t.configured,b=e.status??ke(t),w=e.notice??null,c=a.saving||a.removing;function x(y){l.activate(),d(v=>({...y(v),failed:!1}))}function k(){if(!m.changed||c)return;l.activate();let y=m.edit,v=++r.current;d(I=>({...I,saving:!0,failed:!1})),X(e.bridge,n.saveCommand,y,P(e.environmentId)).then(I=>{if(r.current!==v)return;if(I===null){d(U=>({...U,saving:!1,failed:!0}));return}let E=t===null?void 0:n.rows(I).find(U=>U.rowId===t.rowId);E!==void 0&&d(Ie(E,JSON.stringify(E))),e.onSaved(I)})}function L(){if(t===null){e.onDiscard();return}let y=t.rowId,v=++r.current;d(I=>({...I,removing:!0,removeFailed:!1})),X(e.bridge,n.removeCommand,{rowId:y},P(e.environmentId)).then(I=>{if(r.current===v){if(I===null){d(E=>({...E,removing:!1,removeFailed:!0,confirming:!0}));return}e.onSaved(I)}})}return s(ve,{title:e.title(a.values),icon:e.icon?.(a.values),defaultOpen:h,meta:s(T,{children:[e.meta?.(a.values),s("span",{className:"im-status",children:[e.statusMeta,i(ue,{tone:b.tone,children:e.t(b.key)})]})]}),actions:a.confirming?s("div",{className:"im-actions",children:[i(p,{type:"button",variant:"ghost",size:"sm",disabled:a.removing||a.saving,...g.cancelProps,children:e.t("settingsSection.cancel")}),i(p,{type:"button",variant:"destructive",size:"sm",disabled:a.removing||a.saving,...g.confirmProps,onClick:L,children:e.t(n.removeConfirmKey)})]}):i(p,{type:"button",variant:"ghost",size:"sm",disabled:c,ref:g.triggerRef,onClick:()=>d(y=>({...y,confirming:!0,removeFailed:!1})),children:e.t("settingsSection.remove")}),notice:s(T,{children:[e.summary,a.confirming&&t!==null&&n.removeHintKey!==void 0?i("p",{id:u,children:e.t(n.removeHintKey)}):null,a.removeFailed?i("p",{className:"im-small im-issue",role:"alert",children:e.t(n.removeFailedKey)}):null]}),children:[w===null?null:i(H,{variant:w.variant,children:i(z,{children:w.text})}),s("div",{className:"im-form",children:[i(Nn,{scope:`${n.newSlot}-${t?.rowId??"new"}`,environmentId:e.environmentId,columns:e.columns,groupBotSettings:n.groupBotSettings===!0,proxies:e.proxies,values:a.values,savedValues:t?.values??{},secrets:a.secrets,clearSecrets:a.clearSecrets,storedSecrets:t?.secrets??{},issues:t?.issues??[],publicFields:t?.publicFields??[],disabled:c,bridge:e.bridge,t:e.t,onValue:(y,v)=>x(I=>({...I,values:{...I.values,[y]:v}})),onSecret:(y,v)=>x(I=>({...I,secrets:{...I.secrets,[y]:v}})),onToggleClear:y=>x(v=>({...v,clearSecrets:v.clearSecrets.includes(y)?v.clearSecrets.filter(I=>I!==y):[...v.clearSecrets,y]}))}),e.extra?.({dirty:f,frozen:c}),i(ye,{dirty:f,saving:a.saving,busy:a.removing,solid:l.chosen&&f,failed:a.failed,saveLabel:e.t("settingsSection.save"),revertLabel:e.t("settingsSection.revert"),failedLabel:e.t("settingsSection.saveFailed"),onSave:k,onRevert:()=>{r.current+=1,d(Ie(t,o))}})]})]})}function On(e){let n=e.bridge.useFormatTimestamp(),{error:t,t:o}=e;if(t===void 0)return null;let l=new Date(t.at),r=Number.isFinite(l.getTime())?l.toISOString():null;return s("div",{className:"im-small",role:"status",children:[s("p",{children:[i("strong",{className:"im-issue",children:o("settingsSection.lastMessageError.title")}),o("settingsSection.lastMessageError.separator"),i("span",{children:t.messageKey===void 0?t.message:o(t.messageKey,{...t.messageParams,defaultValue:t.message})})]}),s("p",{className:"im-muted",children:[o("settingsSection.lastMessageError.code",{code:t.code})," \xB7 ",o("settingsSection.lastMessageError.reference",{referenceId:t.referenceId}),r===null?null:s(T,{children:[" \xB7 ",i("time",{dateTime:r,children:n(r)})]})]})]})}var we={groupBotSettings:!0,newSlot:"im-new-row",saveCommand:De,removeCommand:Ue,rows:e=>e.bots,removeConfirmKey:"settingsSection.removeConfirm",removeHintKey:"settingsSection.removeHint",removeFailedKey:"settingsSection.removeFailed"},Ce={newSlot:"im-new-target",saveCommand:Ge,removeCommand:He,rows:e=>e.targets,removeConfirmKey:"settingsSection.target.removeConfirm",removeFailedKey:"settingsSection.target.removeFailed"},Bn=(e,n,t)=>{let o=(e.displayName??"").trim();return o.length>0?o:t(`platform.${n}`)};function Pe(e){let{bot:n,t}=e,o=e.bots.find(f=>f.rowId===(n===null?void 0:e.connections?.[n.rowId]?.duplicateOf)),l=an(n,e.connections,o===void 0?void 0:Bn(o.values,o.platform,t),t),[r,a]=R(null),[d,u]=R(!1),g=n===null?void 0:`im-reset-consequence-${n.rowId}`,m=Se(g,()=>u(!1));return i(Ee,{...e,kind:we,row:n,status:rn(n,e.connections),statusMeta:n?.configured&&e.connections?.[n.rowId]?.statusSince!==void 0?i(ln,{since:e.connections[n.rowId]?.statusSince,bridge:e.bridge,t}):null,notice:l,summary:n===null?null:i(On,{error:e.connections?.[n.rowId]?.lastMessageError,bridge:e.bridge,t}),title:f=>Bn(f,ae(f),t),icon:f=>{let h=O(f,"platform");if(h==="")return null;let w=e.columns.find(c=>c.key==="platform")?.options?.find(c=>c.value===h)?.icon;return w?i(un,{name:w}):null},meta:f=>{let h=ae(f),b=Tn(h,f),w=t(`platform.${h}`);return i("span",{className:"im-small im-muted",...b===null?{}:{title:b},children:b===null?w:`${w} \xB7 ${b}`})},extra:({dirty:f,frozen:h})=>{if(n===null)return null;let b=In(n.platform,f,h,e.connections?.[n.rowId]),w=b.actions.find(c=>c.id==="resetInbox");return s(T,{children:[s("div",{className:"im-span",children:[d&&w!==void 0?s(T,{children:[i("p",{id:g,children:w.descriptionKeys.map(c=>t(c)).join(" ")}),s("div",{className:"im-actions",children:[i(p,{type:"button",variant:"ghost",size:"sm",disabled:h,...m.cancelProps,children:t("settingsSection.cancel")}),i(p,{type:"button",variant:"destructive",size:"sm",disabled:w.disabled,...m.confirmProps,onClick:()=>{u(!1),a({id:"resetInbox",payload:{rowId:n.rowId}})},children:t("rowAction.resetInbox.confirm")})]})]}):i("div",{className:"im-actions",children:b.actions.map(c=>i(p,{type:"button",variant:"ghost",size:"sm",disabled:c.disabled,title:c.descriptionKeys.map(x=>t(x,c.descriptionParams)).join(" "),ref:c.id==="resetInbox"?m.triggerRef:void 0,onClick:()=>{c.id==="resetInbox"?u(!0):a({id:c.id,payload:{rowId:n.rowId}})},children:t(c.labelKey)},c.id))}),b.noteKey!==null?i("p",{className:"im-small im-muted",children:t(b.noteKey)}):null]}),r===null?null:i(pe,{bridge:e.bridge,command:We[r.id],payload:r.payload,items:"latest",environmentId:e.environmentId,t,onClose:()=>a(null)},r.id)]})}})}function Ae(e){let{t:n}=e;return i(Ee,{...e,kind:Ce,row:e.target,title:t=>{let o=(t.name??"").trim()||(t.targetId??"").trim();return o.length>0?o:n("settingsSection.target.untitled")}})}var Jn="im-general";function he(e,n){return{signature:n,replyLanguage:e.replyLanguage,enabled:e.delivery.enabled,port:String(e.delivery.port),token:"",clearToken:!1,saving:!1,failed:!1}}function Ln(e){let n=e.view,t=Te(n),o=be(Jn),l=A(0),[r,a]=R(()=>he(n,t));r.signature!==t&&(l.current+=1,a(he(n,t)));let d=En({baseline:{replyLanguage:n.replyLanguage,enabled:n.delivery.enabled,port:n.delivery.port,hasToken:n.delivery.hasToken},replyLanguage:r.replyLanguage,enabled:r.enabled,port:r.port,token:r.token,clearToken:r.clearToken}),u=d.changed,g=d.changed&&d.invalidPort,m=D(e.environmentId,"general","port"),f=D(e.environmentId,"general","token"),h=D(e.environmentId,"general","language");function b(c){o.activate(),a(x=>({...x,...c,failed:!1}))}function w(){if(!d.changed||r.saving)return;if(o.activate(),d.invalidPort){a(k=>({...k,failed:!0}));return}let c=d.payload,x=++l.current;a(k=>({...k,saving:!0,failed:!1})),X(e.bridge,$e,c,P(e.environmentId)).then(k=>{if(l.current===x){if(k===null){a(L=>({...L,saving:!1,failed:!0}));return}a(he(k,Te(k))),e.onSaved(k)}})}return i(ve,{title:e.t("settingsSection.general"),defaultOpen:!1,children:s("div",{className:"im-form",children:[i(B,{id:h,label:e.t("settings.language.label"),description:e.t("settings.language.description"),children:s(se,{className:"im-wide",value:r.replyLanguage,disabled:r.saving,onValueChange:c=>{let x=re.find(k=>k.value===c);x===void 0||x.value===r.replyLanguage||b({replyLanguage:x.value})},children:[i(de,{id:h,"aria-describedby":`${h}-hint`,children:i(Y,{children:re.filter(c=>c.value===r.replyLanguage).map(c=>e.t(c.labelKey))})}),i(ce,{children:re.map(c=>i(J,{value:c.value,children:e.t(c.labelKey)},c.value))})]})}),s("div",{className:"im-field",children:[s(G,{className:"im-inline",children:[i("span",{className:"im-medium",children:e.t("settings.deliveryHttp.enabled.label")}),i(cn,{checked:r.enabled,disabled:r.saving,onCheckedChange:c=>{c!==r.enabled&&b({enabled:c})}})]}),i("p",{className:"im-small im-muted",children:e.t("settings.deliveryHttp.enabled.description")})]}),r.enabled?i(B,{id:m,label:e.t("settings.deliveryHttp.port.label"),description:e.t("settings.deliveryHttp.port.description"),issue:g?e.t("settingsSection.issue.format"):null,children:i($,{id:m,type:"number",value:r.port,disabled:r.saving,"aria-invalid":g?!0:void 0,"aria-describedby":ee(m,g,!0),onChange:c=>{c.target.value!==r.port&&b({port:c.target.value})}})}):null,r.enabled?i(B,{id:f,label:e.t("settings.deliveryHttp.token.label"),description:e.t("settings.deliveryHttp.token.description"),children:i(ge,{id:f,value:r.token,stored:n.delivery.hasToken,clearing:r.clearToken,disabled:r.saving,invalid:!1,describedBy:ee(f,!1,!0),savedPlaceholder:e.t("settingsSection.secret.saved"),clearLabel:e.t("settingsSection.secret.clear"),undoLabel:e.t("settingsSection.secret.clearUndo"),onChange:c=>{c!==r.token&&b({token:c})},onToggleClear:()=>b({clearToken:!r.clearToken})})}):null,i(ye,{dirty:u,saving:r.saving,solid:o.chosen&&u,failed:r.failed,saveLabel:e.t("settingsSection.save"),revertLabel:e.t("settingsSection.revert"),failedLabel:e.t("settingsSection.saveFailed"),onSave:w,onRevert:()=>{l.current+=1,a(he(n,t))}})]})})}var Mn=`
|
|
6
6
|
.im-settings {
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
color: var(--foreground);
|