@xopcai/xopc 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/dingtalk/src/plugin.js +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/api/api.js +2 -2
- package/dist/extensions/weixin/src/auth/accounts.js +1 -1
- package/dist/extensions/weixin/src/cdn/upload.js +1 -1
- package/dist/extensions/weixin/src/media/data-url.js +1 -1
- package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
- package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
- package/dist/gateway/static/root/assets/{agents-koRRzxbf.js → agents-C0b6j9Kk.js} +2 -2
- package/dist/gateway/static/root/assets/{agents-koRRzxbf.js.map → agents-C0b6j9Kk.js.map} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-D_aWJQl6.js → apps-page-BtKY2glj.js} +2 -2
- package/dist/gateway/static/root/assets/{apps-page-D_aWJQl6.js.map → apps-page-BtKY2glj.js.map} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-OVIjvEhV.js → channels-settings-CaxrdDzq.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-settings-OVIjvEhV.js.map → channels-settings-CaxrdDzq.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-api-DuKLRD5h.js → cron-api-BMAYh86a.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-api-DuKLRD5h.js.map → cron-api-BMAYh86a.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-BJ-PTCWZ.js → cron-page-DxXnOz-l.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-page-BJ-PTCWZ.js.map → cron-page-DxXnOz-l.js.map} +1 -1
- package/dist/gateway/static/root/assets/{dist-BmWGCLpp.js → dist-tEQzKijF.js} +2 -2
- package/dist/gateway/static/root/assets/{dist-BmWGCLpp.js.map → dist-tEQzKijF.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-UuHqRdRY.js → extension-debug-page-DJrTJlUb.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-debug-page-UuHqRdRY.js.map → extension-debug-page-DJrTJlUb.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BfVmZyDY.js → extension-page-Db0Jkez6.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-page-BfVmZyDY.js.map → extension-page-Db0Jkez6.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-bb27iUl0.js → extension-settings-page-C5MfwifV.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-settings-page-bb27iUl0.js.map → extension-settings-page-C5MfwifV.js.map} +1 -1
- package/dist/gateway/static/root/assets/{index-JEcQYChp.js → index-xAzvk1zE.js} +4 -4
- package/dist/gateway/static/root/assets/{index-JEcQYChp.js.map → index-xAzvk1zE.js.map} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CCYv5vDQ.js → logs-page-BWNM_MTa.js} +2 -2
- package/dist/gateway/static/root/assets/{logs-page-CCYv5vDQ.js.map → logs-page-BWNM_MTa.js.map} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-C1T-K4sK.js → sessions-page-Dwvpsn7p.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-C1T-K4sK.js.map → sessions-page-Dwvpsn7p.js.map} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BoRVhtGO.js → settings-page-DqWAZbrP.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-BoRVhtGO.js.map → settings-page-DqWAZbrP.js.map} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-D98E2LLR.js → skills-page-C6MuRJhq.js} +2 -2
- package/dist/gateway/static/root/assets/{skills-page-D98E2LLR.js.map → skills-page-C6MuRJhq.js.map} +1 -1
- package/dist/gateway/static/root/assets/{use-image-provider-credentials-CXCQFOJF.js → use-image-provider-credentials-B1TYItC3.js} +2 -2
- package/dist/gateway/static/root/assets/{use-image-provider-credentials-CXCQFOJF.js.map → use-image-provider-credentials-B1TYItC3.js.map} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +6 -6
- package/dist/src/agent/context/workspace-seed.js +2 -2
- package/dist/src/agent/goals/post-turn.js +1 -1
- package/dist/src/agent/image/load-image-media.js +1 -1
- package/dist/src/agent/ipc/bus.js +1 -1
- package/dist/src/agent/ipc/inbox.js +2 -2
- package/dist/src/agent/ipc/socket.js +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
- package/dist/src/agent/memory/dreaming/events.js +1 -1
- package/dist/src/agent/memory/dreaming/last-run.js +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
- package/dist/src/agent/memory/dreaming/preview.js +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
- package/dist/src/agent/memory/dreaming/utils.js +1 -1
- package/dist/src/agent/memory/plugin-discovery.js +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
- package/dist/src/agent/service.js +5 -5
- package/dist/src/agent/skills/config.js +1 -1
- package/dist/src/agent/skills/hub-hash.js +2 -2
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/scanner.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/skill-manager.js +1 -1
- package/dist/src/agent/tools/dreaming-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -1
- package/dist/src/agent/tools/send-media.js +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/auth/credentials.js +3 -3
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/channels/attachments/inbound-persist.js +1 -1
- package/dist/src/channels/attachments/outbound-tts-persist.js +1 -1
- package/dist/src/channels/outbound/persist-store.js +1 -1
- package/dist/src/channels/pairing/allow-from-file.js +1 -1
- package/dist/src/channels/pairing/pairing-store.js +2 -2
- package/dist/src/chat-commands/builtins/config.js +2 -2
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/config.js +1 -1
- package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/doctor/checks/session-integrity.js +1 -1
- package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
- package/dist/src/cli/commands/extension-dev.js +2 -2
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/extension-pack.js +1 -1
- package/dist/src/cli/commands/image.js +1 -1
- package/dist/src/cli/commands/init.js +4 -4
- package/dist/src/cli/utils/init-workspace.js +2 -2
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/profile.js +2 -2
- package/dist/src/cron/executor.js +2 -2
- package/dist/src/cron/persistence.js +1 -1
- package/dist/src/cron/run-log-store.js +1 -1
- package/dist/src/daemon/launchd.js +2 -2
- package/dist/src/daemon/systemd.js +2 -2
- package/dist/src/extensions/health.js +1 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/lockfile.js +2 -2
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/hono/lib/extension-store.js +1 -1
- package/dist/src/gateway/hono/lib/static-ui.js +1 -1
- package/dist/src/gateway/hono/oauth.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config.js +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +1 -1
- package/dist/src/gateway/hono/routes/host-fs.js +1 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +3 -3
- package/dist/src/gateway/hono/sse.js +2 -2
- package/dist/src/gateway/lock.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.js +2 -2
- package/dist/src/gateway/service.js +4 -4
- package/dist/src/gateway/workspace-fs-file-list.js +1 -1
- package/dist/src/gateway/workspace-heartbeat-path.js +1 -1
- package/dist/src/infra/update-check.js +1 -1
- package/dist/src/infra/update-lock.js +3 -3
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/infra/update-startup.js +2 -2
- package/dist/src/infra/write-file-atomic.js +2 -2
- package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/session/config-store.js +2 -2
- package/dist/src/session/search-index-cache.js +1 -1
- package/dist/src/session/search-index.js +1 -1
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/store.js +5 -5
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/utils/logger/audit.js +1 -1
- package/dist/src/utils/logger/log-store.js +1 -1
- package/dist/src/utils/logger/rotation.js +1 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/voice/tts/providers/edge-speech.js +1 -1
- package/package.json +2 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{i as t,t as n}from"./vendor-react-DbimaAId.js";import{i as r}from"./vendor-swr-B5fPo7KK.js";import{At as i,Dn as a,Dt as o,En as s,Et as c,Gr as l,Kr as u,Mn as d,On as f,Ot as p,Pn as m,Tt as h,Vn as g,Wr as _,Zr as v,_t as y,bn as b,br as x,cn as S,di as C,gn as w,hn as T,kn as E,kt as D,mr as O,pn as k,qr as A,tr as j,ui as M,vr as ee,vt as N,wn as te,wt as ne,x as P,yt as re}from"./index-JEcQYChp.js";import{a as ie,i as ae,n as oe,r as F,t as se}from"./dist-BmWGCLpp.js";import{t as ce}from"./browser-DNXWYwzc.js";var I=n();function L({icon:e,title:t,subtitle:n,configured:r,enabled:i,onToggle:a,toggleDisabled:o,onConfigure:s,onEdit:c,onRemove:l,ch:u}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-2xl border border-edge bg-surface-base px-4 py-4 dark:border-edge sm:flex-row sm:items-center sm:gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[(0,I.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:e}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),r?(0,I.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-xs font-medium text-success`,children:u.hubConnectedBadge}):null]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n})]})]}),r?(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,I.jsxs)(ae,{children:[(0,I.jsx)(ie,{asChild:!0,children:(0,I.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u.menuMoreAria,children:(0,I.jsx)(A,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,I.jsx)(F,{children:(0,I.jsxs)(se,{className:`z-[70] min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,I.jsx)(oe,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>c(),children:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(O,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),u.menuEditConfig]})}),(0,I.jsx)(oe,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>l(),children:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(g,{className:`size-4 shrink-0`,strokeWidth:1.75}),u.menuRemoveConfig]})})]})})]}),(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} — ${u.enableChannelAria}`,disabled:o,className:d(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,i?`justify-end bg-accent`:`justify-start bg-surface-hover`,o&&`cursor-not-allowed opacity-50`),onClick:()=>void a(!i),children:(0,I.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,I.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,I.jsx)(E,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:s,children:u.hubConfigureButton})})]})}function le({open:e,onOpenChange:t,ch:n,removeTarget:r,onCancel:a,saving:s,onConfirmRemove:l}){return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[70] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsx)(i,{className:`text-base font-semibold text-fg`,children:n.removeChannelTitle}),(0,I.jsx)(c,{className:`mt-2 text-sm text-fg-muted`,children:r?n.removeChannelConfirm.replace(`{{name}}`,r===`weixin`?n.weixinTitle:r===`telegram`?n.telegramTitle:r===`feishu`?n.feishuTitle:n.dingtalkTitle):`\xA0`}),(0,I.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}),(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:s,onClick:l,children:s?n.saving:n.removeChannelAction})]})]})]})})}function R(e){return(e??``).trim().toLowerCase()}function z(e){let t=e.match;return!(!t?.channel||!t.accountId||t.peerId||t.peerKind||t.guildId||t.teamId||t.memberRoleIds&&t.memberRoleIds.length>0)}function ue(e){return Object.keys(e.accounts??{}).sort()}function de(e){return Object.keys(e.accounts??{}).sort()}function fe(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.appId==`string`&&e.appId.trim()&&typeof e.appSecret==`string`&&e.appSecret.trim()?[`default`]:[]}function pe(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.clientId==`string`&&e.clientId.trim()&&typeof e.clientSecret==`string`&&e.clientSecret.trim()?[`default`]:[]}function me(e,t,n,r,i,a){let o={},s={},c={},l={};for(let n of t)o[n]=(e.find(e=>R(e.match?.channel)===`telegram`&&R(e.match?.accountId)===R(n)&&z(e))?.agentId??a).trim().toLowerCase();for(let t of n)s[t]=(e.find(e=>R(e.match?.channel)===`weixin`&&R(e.match?.accountId)===R(t)&&z(e))?.agentId??a).trim().toLowerCase();for(let t of r)c[t]=(e.find(e=>R(e.match?.channel)===`feishu`&&R(e.match?.accountId)===R(t)&&z(e))?.agentId??a).trim().toLowerCase();for(let t of i)l[t]=(e.find(e=>R(e.match?.channel)===`dingtalk`&&R(e.match?.accountId)===R(t)&&z(e))?.agentId??a).trim().toLowerCase();return{telegram:o,weixin:s,feishu:c,dingtalk:l}}function B(e,t,n,r,i,a,o){let s=new Set(n.map(R)),c=new Set(r.map(R)),l=new Set(i.map(R)),u=new Set(a.map(R)),d=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!z(e))return!0;let t=R(e.match.channel),n=R(e.match.accountId);return!n||n===`*`?!0:!(t===`telegram`&&s.has(n)||t===`weixin`&&c.has(n)||t===`feishu`&&l.has(n)||t===`dingtalk`&&u.has(n))}),f=[];for(let e of n){let n=(t.telegram[e]??t.telegram[R(e)]??o).trim().toLowerCase();f.push({id:`ui:route:account:telegram:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`telegram`,accountId:e}})}for(let e of r){let n=(t.weixin[e]??t.weixin[R(e)]??o).trim().toLowerCase();f.push({id:`ui:route:account:weixin:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`weixin`,accountId:e}})}for(let e of i){let n=(t.feishu[e]??t.feishu[R(e)]??o).trim().toLowerCase();f.push({id:`ui:route:account:feishu:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`feishu`,accountId:e}})}for(let e of a){let n=(t.dingtalk[e]??t.dingtalk[R(e)]??o).trim().toLowerCase();f.push({id:`ui:route:account:dingtalk:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`dingtalk`,accountId:e}})}return[...d,...f]}function V(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,a,`dark:border-edge`)}function H(){return d(s,te)}function U(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).map(e=>/^-?\d+$/.test(e)?Number(e):e)}function W(e){return e.map(String).join(`, `)}function he(e){let t=e.accounts?.default?.botToken;return typeof t==`string`?t:``}function ge(e){return Object.values(e.accounts??{}).some(e=>typeof e.botToken==`string`&&e.botToken.trim().length>0)}function G(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function _e(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}function ve(e){return!!(e.clientId?.trim()&&e.clientSecret?.trim())||Object.keys(e.accounts??{}).length>0}function K({children:e}){return(0,I.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e})}function q({children:e}){return(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:e})}function J({label:e,value:t,onChange:n,options:r}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e}),(0,I.jsx)(`select`,{className:H(),value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function Y({accountIds:e,routes:t,defaultAgentId:n,agentItems:r,disabled:i,onChange:a,ch:o}){let s=f(b(e=>e.language)).agentsSettings;if(e.length===0)return null;let c=r.length>0?r:[{id:n}];return(0,I.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(K,{children:o.agentRoutingTitle}),(0,I.jsx)(q,{children:o.agentRoutingHint})]}),(0,I.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2.5 sm:grid-cols-2 sm:items-center dark:border-edge`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:o.agentRoutingAccountLabel}),(0,I.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:e,children:e})]}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${e}`,children:o.agentRoutingAgentLabel}),(0,I.jsx)(`select`,{id:`agent-route-${e}`,className:d(V(),te),disabled:i,value:(t[e]??n).toLowerCase(),onChange:t=>a(e,t.target.value),children:c.map(e=>(0,I.jsx)(`option`,{value:e.id,children:`${P(e,s)} (${e.id})`},e.id))})]})]},e))})]})}function ye({ch:e,form:t,baseline:n,showDingtalkSecret:r,setShowDingtalkSecret:i,dingtalkCopied:a,copyDingtalkSecret:o,updateDingtalk:s,updateChannelAgentRoute:c,dingtalkAccountsDraft:u,setDingtalkAccountsDraft:f,dingtalkAccountsError:p,onDingtalkAccountsBlur:m,dmOpts:h,groupOpts:g,chatAgents:y,saving:b,dirty:x,save:S,discard:w}){let T=V,D=t.dingtalk,O=n?.dingtalk?.clientSecret??``,k=!r&&!!String(O).trim()&&D.clientSecret===O;return(0,I.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,I.jsx)(M,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.dingtalkAdvancedHint}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:D.enabled,onChange:e=>s({enabled:e.target.checked})}),(0,I.jsx)(`span`,{children:e.enableDingtalkAria})]}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[e.dingtalkClientId,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),value:D.clientId,onChange:e=>s({clientId:e.target.value}),placeholder:`dingxxx`}),(0,I.jsx)(q,{children:e.dingtalkClientIdDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[e.dingtalkClientSecret,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),type:r?`text`:`password`,autoComplete:`off`,readOnly:k,value:k?`*`.repeat(Math.max(1,D.clientSecret.length)):D.clientSecret,onChange:e=>{k||s({clientSecret:e.target.value})},placeholder:`••••••••`}),D.clientSecret?(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void o(),children:[a?(0,I.jsx)(C,{className:`size-3.5`}):(0,I.jsx)(v,{className:`size-3.5`}),a?e.copied:e.copy]}):null,(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>i(e=>!e),children:[r?(0,I.jsx)(l,{className:`size-3.5`}):(0,I.jsx)(_,{className:`size-3.5`}),r?e.hide:e.show]})]}),(0,I.jsx)(q,{children:e.dingtalkClientSecretDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.dingtalkEndpoint}),(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),value:D.endpoint,onChange:e=>s({endpoint:e.target.value}),placeholder:`https://api.dingtalk.com`}),(0,I.jsx)(q,{children:e.dingtalkEndpointDesc})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.debug,onChange:e=>s({debug:e.target.checked})}),e.dingtalkDebug]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.dmPolicy}),(0,I.jsx)(`select`,{className:T(),value:D.dmPolicy,onChange:e=>s({dmPolicy:e.target.value}),children:h.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.groupPolicy}),(0,I.jsx)(`select`,{className:T(),value:D.groupPolicy,onChange:e=>s({groupPolicy:e.target.value}),children:g.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.requireMention,onChange:e=>s({requireMention:e.target.checked})}),e.requireMention]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.allowFromDm}),(0,I.jsx)(`textarea`,{className:d(T(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`userId1, userId2`,value:W(D.allowFrom),onChange:e=>s({allowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:e.allowFromDmDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.allowFromGroups}),(0,I.jsx)(`textarea`,{className:d(T(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`openConversationId1`,value:W(D.groupAllowFrom),onChange:e=>s({groupAllowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:e.allowFromGroupsDesc})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.historyLimit}),(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(D.historyLimit),onChange:e=>s({historyLimit:Number(e.target.value||`0`)||0})})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.textChunkLimit}),(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(D.textChunkLimit),onChange:e=>s({textChunkLimit:Number(e.target.value||`0`)||0})})]})]}),(0,I.jsx)(Y,{accountIds:pe(D),routes:t.channelAgentRoutes.dingtalk,defaultAgentId:t.defaultAgentId,agentItems:y?.items??[],disabled:b,onChange:(e,t)=>c(`dingtalk`,e,t),ch:e}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.multiAccountJson}),(0,I.jsx)(`textarea`,{className:d(T(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:u,onChange:e=>f(e.target.value),onBlur:m,placeholder:`{ "default": { "clientId": "...", "clientSecret": "...", "enabled": true } }`}),p?(0,I.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:p}):(0,I.jsx)(q,{children:e.multiAccountJsonDesc})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!x||b,onClick:w,children:e.discard}),(0,I.jsx)(E,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!x||b,onClick:async()=>{await S()},children:b?e.saving:e.save})]})]})]})}var X=e(t(),1),Z=e(ce(),1);function be(e){return{accountId:e,name:``,enabled:!0,botToken:``,allowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,apiRoot:``,proxy:``,historyLimit:50,textChunkLimit:4e3,streamMode:`partial`}}function xe(){return{bindingsFull:[],channelAgentRoutes:{telegram:{},weixin:{},feishu:{},dingtalk:{}},defaultAgentId:`main`,telegram:{enabled:!1,apiRoot:``,debug:!1,allowFrom:[],groupAllowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,proxy:``,accounts:{default:be(`default`)}},weixin:{enabled:!1,dmPolicy:`pairing`,allowFrom:[],debug:!1,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,routeTag:``,accounts:{}},feishu:{enabled:!1,defaultAccount:``,appId:``,appSecret:``,domain:`feishu`,connectionMode:`websocket`,verificationToken:``,encryptKey:``,webhookHost:`127.0.0.1`,webhookPort:3e3,webhookPath:`/feishu/events`,dmPolicy:`pairing`,groupPolicy:`allowlist`,allowFrom:[],groupAllowFrom:[],requireMention:!0,historyLimit:50,textChunkLimit:4e3,renderMode:`auto`,streaming:!1,reactionNotifications:`own`,tools:{doc:!0,wiki:!0,drive:!0,scopes:!0,bitable:!0,perm:!1},actions:{reactions:!0},accounts:{}},dingtalk:{enabled:!1,defaultAccount:``,clientId:``,clientSecret:``,dmPolicy:`pairing`,groupPolicy:`open`,allowFrom:[],groupAllowFrom:[],requireMention:!1,debug:!1,endpoint:`https://api.dingtalk.com`,historyLimit:50,textChunkLimit:4e3,accounts:{}}}}function Se(e){let t=e&&typeof e==`object`?e.channels:void 0,n=t&&typeof t==`object`?t:{},r=n.telegram,i=n.weixin,a=n.feishu,o=n.dingtalk,s=r?.accounts,c=s&&typeof s==`object`&&!Array.isArray(s)?{...s}:{},l=typeof r?.botToken==`string`?r.botToken.trim():``,u=c.default?.botToken?.trim()??``;l&&!u&&(c={...c,default:{...c.default??be(`default`),accountId:`default`,botToken:l}}),c.default||(c={...c,default:be(`default`)});let d=i?.accounts,f=d&&typeof d==`object`&&!Array.isArray(d)?d:{},p=(()=>{let t=(e&&typeof e==`object`?e:{}).bindings;return Array.isArray(t)?t:[]})(),m=(()=>{let t=(e&&typeof e==`object`?e:{}).agents;return t&&typeof t==`object`?t:{}})(),h=typeof m.defaultId==`string`&&m.defaultId.trim()?m.defaultId.trim().toLowerCase():`main`,g={telegram:{enabled:!!r?.enabled,apiRoot:typeof r?.apiRoot==`string`?r.apiRoot:``,debug:!!r?.debug,allowFrom:Array.isArray(r?.allowFrom)?[...r.allowFrom]:[],groupAllowFrom:Array.isArray(r?.groupAllowFrom)?[...r.groupAllowFrom]:[],dmPolicy:r?.dmPolicy||`pairing`,groupPolicy:r?.groupPolicy||`open`,replyToMode:r?.replyToMode||`off`,streamMode:r?.streamMode??`partial`,historyLimit:typeof r?.historyLimit==`number`?r.historyLimit:50,textChunkLimit:typeof r?.textChunkLimit==`number`?r.textChunkLimit:4e3,proxy:typeof r?.proxy==`string`?r.proxy:``,accounts:{...c}},weixin:{enabled:!!i?.enabled,dmPolicy:i?.dmPolicy||`pairing`,allowFrom:Array.isArray(i?.allowFrom)?[...i.allowFrom]:[],debug:!!i?.debug,streamMode:i?.streamMode??`partial`,historyLimit:typeof i?.historyLimit==`number`?i.historyLimit:50,textChunkLimit:typeof i?.textChunkLimit==`number`?i.textChunkLimit:4e3,routeTag:i?.routeTag==null?``:String(i.routeTag),accounts:{...f}},feishu:{enabled:!!a?.enabled,defaultAccount:typeof a?.defaultAccount==`string`?a.defaultAccount:``,appId:typeof a?.appId==`string`?a.appId:``,appSecret:typeof a?.appSecret==`string`?a.appSecret:``,domain:typeof a?.domain==`string`&&a.domain||`feishu`,connectionMode:a?.connectionMode||`websocket`,verificationToken:typeof a?.verificationToken==`string`?a.verificationToken:``,encryptKey:typeof a?.encryptKey==`string`?a.encryptKey:``,webhookHost:typeof a?.webhookHost==`string`?a.webhookHost:`127.0.0.1`,webhookPort:typeof a?.webhookPort==`number`?a.webhookPort:3e3,webhookPath:typeof a?.webhookPath==`string`?a.webhookPath:`/feishu/events`,dmPolicy:a?.dmPolicy||`pairing`,groupPolicy:a?.groupPolicy||`allowlist`,allowFrom:Array.isArray(a?.allowFrom)?[...a.allowFrom]:[],groupAllowFrom:Array.isArray(a?.groupAllowFrom)?[...a.groupAllowFrom]:[],requireMention:a?.requireMention===void 0?!0:!!a.requireMention,historyLimit:typeof a?.historyLimit==`number`?a.historyLimit:50,textChunkLimit:typeof a?.textChunkLimit==`number`?a.textChunkLimit:4e3,renderMode:a?.renderMode||`auto`,streaming:a?.streaming===void 0?!1:!!a.streaming,reactionNotifications:a?.reactionNotifications||`own`,tools:a?.tools&&typeof a.tools==`object`&&!Array.isArray(a.tools)?{...a.tools}:void 0,actions:a?.actions&&typeof a.actions==`object`&&!Array.isArray(a.actions)?{...a.actions}:void 0,accounts:a?.accounts&&typeof a.accounts==`object`&&!Array.isArray(a.accounts)?{...a.accounts}:{}},dingtalk:{enabled:!!o?.enabled,defaultAccount:typeof o?.defaultAccount==`string`?o.defaultAccount:``,clientId:typeof o?.clientId==`string`?o.clientId:``,clientSecret:typeof o?.clientSecret==`string`?o.clientSecret:``,dmPolicy:o?.dmPolicy||`pairing`,groupPolicy:o?.groupPolicy||`open`,allowFrom:Array.isArray(o?.allowFrom)?[...o.allowFrom]:[],groupAllowFrom:Array.isArray(o?.groupAllowFrom)?[...o.groupAllowFrom]:[],requireMention:o?.requireMention===!0,debug:!!o?.debug,endpoint:typeof o?.endpoint==`string`&&o.endpoint.trim()?o.endpoint.trim():`https://api.dingtalk.com`,historyLimit:typeof o?.historyLimit==`number`?o.historyLimit:50,textChunkLimit:typeof o?.textChunkLimit==`number`?o.textChunkLimit:4e3,accounts:o?.accounts&&typeof o.accounts==`object`&&!Array.isArray(o.accounts)?{...o.accounts}:{}}},_=me(p,ue(g.telegram),de(g.weixin),fe(g.feishu),pe(g.dingtalk),h);return{...g,bindingsFull:p.map(e=>({...e})),channelAgentRoutes:_,defaultAgentId:h}}async function Q(e){return(await k(S(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Ce(e){return(await k(S(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function we(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=e.dingtalk,a=B(e.bindingsFull,e.channelAgentRoutes,ue(t),de(n),fe(r),pe(i),e.defaultAgentId),o=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),s=(await k(S(`/api/config`),{method:`PATCH`,body:JSON.stringify({bindings:a,channels:{telegram:{enabled:t.enabled,apiRoot:t.apiRoot||void 0,debug:t.debug,allowFrom:t.allowFrom,groupAllowFrom:t.groupAllowFrom.length?t.groupAllowFrom:void 0,dmPolicy:t.dmPolicy,groupPolicy:t.groupPolicy,replyToMode:t.replyToMode,streamMode:t.streamMode,historyLimit:t.historyLimit,textChunkLimit:t.textChunkLimit,proxy:t.proxy||void 0,accounts:t.accounts},weixin:{enabled:n.enabled,dmPolicy:n.dmPolicy,allowFrom:n.allowFrom,debug:n.debug,streamMode:n.streamMode,historyLimit:n.historyLimit,textChunkLimit:n.textChunkLimit,routeTag:o,accounts:n.accounts},feishu:{enabled:r.enabled,defaultAccount:r.defaultAccount||void 0,appId:r.appId,appSecret:r.appSecret||void 0,domain:r.domain||void 0,connectionMode:r.connectionMode,verificationToken:r.verificationToken?.trim()?r.verificationToken:void 0,encryptKey:r.encryptKey?.trim()?r.encryptKey:void 0,webhookHost:r.webhookHost?.trim()?r.webhookHost:void 0,webhookPort:typeof r.webhookPort==`number`?r.webhookPort:void 0,webhookPath:r.webhookPath?.trim()?r.webhookPath:void 0,dmPolicy:r.dmPolicy,groupPolicy:r.groupPolicy,allowFrom:r.allowFrom,groupAllowFrom:r.groupAllowFrom.length?r.groupAllowFrom:void 0,requireMention:r.requireMention,historyLimit:r.historyLimit,textChunkLimit:r.textChunkLimit,renderMode:r.renderMode,streaming:r.streaming,reactionNotifications:r.reactionNotifications,tools:r.tools,actions:r.actions,accounts:r.accounts},dingtalk:{enabled:i.enabled,defaultAccount:i.defaultAccount||void 0,clientId:i.clientId,clientSecret:i.clientSecret||void 0,dmPolicy:i.dmPolicy,groupPolicy:i.groupPolicy,allowFrom:i.allowFrom,groupAllowFrom:i.groupAllowFrom.length?i.groupAllowFrom:void 0,requireMention:i.requireMention,debug:i.debug,endpoint:i.endpoint?.trim()?i.endpoint:void 0,historyLimit:i.historyLimit,textChunkLimit:i.textChunkLimit,accounts:i.accounts}}})})).payload?.config;return N(),s?Se(s):{...e,bindingsFull:a}}async function Te(e){return(await k(S(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Ee(e){return(await k(S(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}async function $(){return(await k(S(`/api/channels/dingtalk/setup/start`),{method:`POST`,body:JSON.stringify({})})).payload}async function De(e){return(await k(S(`/api/channels/dingtalk/setup/${encodeURIComponent(e)}`))).payload.status}function Oe({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:a}){let[s,l]=(0,X.useState)(!1),[f,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(!1),T=(0,X.useCallback)(async()=>{b(null),g(null),v(null),l(!0);try{let e=await $();v(e.qrUrl),g(e.sessionKey)}catch(e){b(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,X.useEffect)(()=>{if(!e){g(null),v(null),b(null),S(null),w(!1),l(!1);return}T()},[e,T]),(0,X.useEffect)(()=>{if(!f)return;let e=!1,n,i=async()=>{try{let i=await De(f);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),g(null),i.ok?(v(null),t(!1),r({clientId:i.clientId})):(b(i.message),v(null));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),b(i.message),g(null),v(null))}catch(t){e||(n!==void 0&&window.clearInterval(n),b(t instanceof Error?t.message:`Request failed`),g(null),v(null))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[f,t,r]),(0,X.useEffect)(()=>{if(!_){S(null),w(!1);return}let e=!1;return w(!1),Z.toDataURL(_,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||S(t)}).catch(()=>{e||(w(!0),S(null))}),()=>{e=!0}},[_]);let O=!!(_&&f),k=e&&!y&&!O;return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.dingtalkQrCloseAria,children:(0,I.jsx)(m,{className:`size-4`})})}),(0,I.jsx)(i,{className:`sr-only`,children:n.dingtalkQrModalTitle}),(0,I.jsx)(c,{className:`sr-only`,children:n.dingtalkQrModalSubtitle}),(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.dingtalkQrModalTitle}),(0,I.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.dingtalkQrModalSubtitle})]}),(0,I.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[y?(0,I.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:y}):null,!y&&(O||k)?(0,I.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg-muted`,children:k?n.dingtalkQrStarting:n.dingtalkQrScanHint}),(0,I.jsxs)(`div`,{className:d(`relative flex h-52 w-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,k&&`bg-surface-muted/40 dark:bg-surface-base`),children:[k?(0,I.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,O&&_&&!y&&x&&!C?(0,I.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,O&&_&&!y&&!x&&!C&&!k?(0,I.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.dingtalkQrEncoding}):null,O&&_&&!y&&C?(0,I.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,I.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.dingtalkQrImageError}),(0,I.jsxs)(`a`,{href:_,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,I.jsx)(u,{className:`size-3 shrink-0`}),n.dingtalkQrOpenLink]})]}):null]})]}):null]}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:s,onClick:()=>void T(),children:s?n.dingtalkQrStarting:n.dingtalkQrRegenerate})}),a?(0,I.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:a}):null]})]})})}function ke({ch:e,form:t,baseline:n,showFeishuSecret:r,setShowFeishuSecret:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuCopied:s,feishuWebhookCopied:c,copyFeishuSecret:u,copyFeishuWebhookConfig:f,updateFeishu:p,updateChannelAgentRoute:m,feishuAccountsDraft:h,setFeishuAccountsDraft:g,feishuAccountsError:y,onFeishuAccountsBlur:b,dmOpts:x,groupOpts:S,chatAgents:w,saving:T,dirty:D,save:O,discard:k}){let A=V,j=t.feishu,ee=n?.feishu?.appSecret??``,N=!r&&!!String(ee).trim()&&j.appSecret===ee;return(0,I.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,I.jsx)(M,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.feishuAdvancedHint}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:j.enabled,onChange:e=>p({enabled:e.target.checked})}),(0,I.jsx)(`span`,{children:e.enableFeishuAria})]}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[e.feishuAppId,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.appId,onChange:e=>p({appId:e.target.value}),placeholder:`cli_xxx`}),(0,I.jsx)(q,{children:e.feishuAppIdDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[e.feishuAppSecret,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:r?`text`:`password`,autoComplete:`off`,readOnly:N,value:N?`*`.repeat(Math.max(1,j.appSecret.length)):j.appSecret,onChange:e=>{N||p({appSecret:e.target.value})},placeholder:`••••••••`}),j.appSecret?(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void u(),children:[s?(0,I.jsx)(C,{className:`size-3.5`}):(0,I.jsx)(v,{className:`size-3.5`}),s?e.copied:e.copy]}):null,(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>i(e=>!e),children:[r?(0,I.jsx)(l,{className:`size-3.5`}):(0,I.jsx)(_,{className:`size-3.5`}),r?e.hide:e.show]})]}),(0,I.jsx)(q,{children:e.feishuAppSecretDesc})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.feishuDomain}),(0,I.jsxs)(`select`,{className:A(),value:String(j.domain||`feishu`),onChange:e=>p({domain:e.target.value}),children:[(0,I.jsx)(`option`,{value:`feishu`,children:`feishu`}),(0,I.jsx)(`option`,{value:`lark`,children:`lark`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.connectionMode}),(0,I.jsxs)(`select`,{className:A(),value:j.connectionMode,onChange:e=>p({connectionMode:e.target.value}),children:[(0,I.jsx)(`option`,{value:`websocket`,children:`websocket`}),(0,I.jsx)(`option`,{value:`webhook`,children:`webhook`})]}),(0,I.jsx)(q,{children:e.connectionModeDesc})]})]}),j.connectionMode===`webhook`?(0,I.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.webhookTitle}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>o(e=>!e),children:[a?(0,I.jsx)(l,{className:`size-3.5`}):(0,I.jsx)(_,{className:`size-3.5`}),a?e.hide:e.show]}),(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void f(),children:[c?(0,I.jsx)(C,{className:`size-3.5`}):(0,I.jsx)(v,{className:`size-3.5`}),c?e.copied:e.copy]})]})]}),(0,I.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.verificationToken}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:j.verificationToken??``,onChange:e=>p({verificationToken:e.target.value})}),(0,I.jsx)(q,{children:e.verificationTokenDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.encryptKey}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:j.encryptKey??``,onChange:e=>p({encryptKey:e.target.value})}),(0,I.jsx)(q,{children:e.encryptKeyDesc})]})]}),(0,I.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,I.jsx)(K,{children:e.webhookHost}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.webhookHost??``,onChange:e=>p({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.webhookPort}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(j.webhookPort??``),onChange:e=>p({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,I.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.webhookPath}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.webhookPath??``,onChange:e=>p({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,I.jsx)(q,{children:e.webhookPathDesc})]})]}):null,(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.renderMode}),(0,I.jsxs)(`select`,{className:A(),value:j.renderMode,onChange:e=>p({renderMode:e.target.value}),children:[(0,I.jsx)(`option`,{value:`auto`,children:`auto`}),(0,I.jsx)(`option`,{value:`raw`,children:`raw`}),(0,I.jsx)(`option`,{value:`card`,children:`card`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.reactionNotifications}),(0,I.jsxs)(`select`,{className:A(),value:j.reactionNotifications,onChange:e=>p({reactionNotifications:e.target.value}),children:[(0,I.jsx)(`option`,{value:`off`,children:`off`}),(0,I.jsx)(`option`,{value:`own`,children:`own`}),(0,I.jsx)(`option`,{value:`all`,children:`all`})]})]})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:j.streaming,onChange:e=>p({streaming:e.target.checked})}),e.enableStreaming]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.dmPolicy}),(0,I.jsx)(`select`,{className:A(),value:j.dmPolicy,onChange:e=>p({dmPolicy:e.target.value}),children:x.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.groupPolicy}),(0,I.jsx)(`select`,{className:A(),value:j.groupPolicy,onChange:e=>p({groupPolicy:e.target.value}),children:S.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:j.requireMention,onChange:e=>p({requireMention:e.target.checked})}),e.requireMention]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.allowFromDm}),(0,I.jsx)(`textarea`,{className:d(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`ou_xxx, on_xxx`,value:W(j.allowFrom),onChange:e=>p({allowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:e.allowFromDmDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.allowFromGroups}),(0,I.jsx)(`textarea`,{className:d(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`oc_xxx, oc_yyy`,value:W(j.groupAllowFrom),onChange:e=>p({groupAllowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:e.allowFromGroupsDesc})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.historyLimit}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(j.historyLimit),onChange:e=>p({historyLimit:Number(e.target.value||`0`)||0})})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.textChunkLimit}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(j.textChunkLimit),onChange:e=>p({textChunkLimit:Number(e.target.value||`0`)||0})})]})]}),(0,I.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feishuToolsTitle}),(0,I.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[`doc`,e.feishuToolDoc],[`wiki`,e.feishuToolWiki],[`drive`,e.feishuToolDrive],[`perm`,e.feishuToolPerm],[`bitable`,e.feishuToolBitable],[`scopes`,e.feishuToolScopes]].map(([e,t])=>(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!j.tools?.[e],onChange:t=>p({tools:{...j.tools,[e]:t.target.checked}})}),t]},e))}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(q,{children:e.feishuToolsDesc})})]}),(0,I.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feishuActionsTitle}),(0,I.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!j.actions?.reactions,onChange:e=>p({actions:{...j.actions,reactions:e.target.checked}})}),e.feishuActionReactions]})]}),(0,I.jsx)(Y,{accountIds:fe(j),routes:t.channelAgentRoutes.feishu,defaultAgentId:t.defaultAgentId,agentItems:w?.items??[],disabled:T,onChange:(e,t)=>m(`feishu`,e,t),ch:e}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.multiAccountJson}),(0,I.jsx)(`textarea`,{className:d(A(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:h,onChange:e=>g(e.target.value),onBlur:b,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),y?(0,I.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:y}):(0,I.jsx)(q,{children:e.multiAccountJsonDesc})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!D||T,onClick:k,children:e.discard}),(0,I.jsx)(E,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!D||T,onClick:async()=>{await O()},children:T?e.saving:e.save})]})]})]})}function Ae({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:a}){let[s,l]=(0,X.useState)(!1),[f,g]=(0,X.useState)(`feishu`),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),[T,O]=(0,X.useState)(!1),k=(0,X.useCallback)(async e=>{g(e),S(null),v(null),b(null),l(!0);try{let t=await Te({domain:e});b(t.qrUrl),v(t.sessionKey)}catch(e){S(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,X.useEffect)(()=>{if(!e){v(null),b(null),S(null),w(null),O(!1),g(`feishu`),l(!1);return}k(`feishu`)},[e,k]),(0,X.useEffect)(()=>{if(!_)return;let e=!1,n,i=async()=>{try{let i=await Ee(_);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),v(null),i.ok?(b(null),t(!1),r({appId:i.appId,domain:i.domain,openId:i.openId})):(S(i.message),b(null));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),S(i.message),v(null),b(null))}catch(t){e||(n!==void 0&&window.clearInterval(n),S(t instanceof Error?t.message:`Request failed`),v(null),b(null))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[_,t,r]),(0,X.useEffect)(()=>{if(!y){w(null),O(!1);return}let e=!1;return O(!1),Z.toDataURL(y,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||w(t)}).catch(()=>{e||(O(!0),w(null))}),()=>{e=!0}},[y]);let A=!!(y&&_),j=e,M=e&&!x&&!A;return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.feishuQrCloseAria,children:(0,I.jsx)(m,{className:`size-4`})})}),(0,I.jsx)(i,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,I.jsx)(c,{className:`sr-only`,children:n.feishuQrModalSubtitle}),(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.feishuQrModalTitle}),(0,I.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.feishuQrModalSubtitle})]}),(0,I.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[x?(0,I.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:x}):null,!x&&(A||M)?(0,I.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg-muted`,children:M?n.feishuQrStarting:n.feishuQrScanHint}),(0,I.jsxs)(`div`,{className:d(`relative flex h-52 w-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,M&&`bg-surface-muted/40 dark:bg-surface-base`),children:[M?(0,I.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,A&&y&&!x&&C&&!T?(0,I.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,A&&y&&!x&&!C&&!T&&!M?(0,I.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,A&&y&&!x&&T?(0,I.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,I.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.feishuQrImageError}),(0,I.jsxs)(`a`,{href:y,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,I.jsx)(u,{className:`size-3 shrink-0`}),n.feishuQrOpenLink]})]}):null]})]}):null]}),j?(0,I.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[20rem] justify-center px-1`,role:`group`,"aria-label":n.feishuRegionSwitchAria,children:(0,I.jsxs)(`div`,{className:`inline-flex w-full rounded-full border border-edge bg-surface-muted/60 p-1 dark:border-edge dark:bg-surface-base`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:s,className:d(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,f===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void k(`feishu`),children:n.feishuRegionChina}),(0,I.jsx)(`button`,{type:`button`,disabled:s,className:d(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,f===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void k(`lark`),children:n.feishuRegionInternational})]})}):null,(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:s,onClick:()=>void k(f),children:s?n.feishuQrStarting:n.feishuQrRegenerate})}),a?(0,I.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:a}):null]})]})})}function je({tg:e,updateTelegram:t,ch:n,dmOpts:r,groupOpts:i,replyOpts:a,streamOpts:o,tgAccountsDraft:s,setTgAccountsDraft:c,tgAccountsError:l,onTgAccountsBlur:u}){let f=V;return(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.apiRoot}),(0,I.jsx)(`input`,{className:f(),value:e.apiRoot,onChange:e=>t({apiRoot:e.target.value}),placeholder:`https://api.telegram.org`})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.proxy}),(0,I.jsx)(`input`,{className:f(),value:e.proxy,onChange:e=>t({proxy:e.target.value}),placeholder:`http://proxy.example.com:8080`})]}),(0,I.jsx)(J,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,I.jsx)(J,{label:n.groupPolicy,value:e.groupPolicy,onChange:e=>t({groupPolicy:e}),options:i}),(0,I.jsx)(J,{label:n.replyToMode,value:e.replyToMode,onChange:e=>t({replyToMode:e}),options:a}),(0,I.jsx)(J,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:o}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.allowFromGroups}),(0,I.jsx)(`textarea`,{className:d(f(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`-1001234567890`,value:W(e.groupAllowFrom),onChange:e=>t({groupAllowFrom:U(e.target.value)})})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.historyLimit}),(0,I.jsx)(`input`,{type:`number`,min:10,max:200,className:f(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.textChunkLimit}),(0,I.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:f(),value:e.textChunkLimit,onChange:e=>t({textChunkLimit:parseInt(e.target.value,10)||4e3})})]})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.telegramDebug]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.multiAccountJson}),(0,I.jsx)(`textarea`,{className:d(f(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:s,onChange:e=>c(e.target.value),onBlur:u,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),l?(0,I.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):(0,I.jsx)(q,{children:n.multiAccountJsonDesc})]})]})}function Me({open:e,onOpenChange:t,ch:n,form:r,baseline:a,tgAdvanced:s,setTgAdvanced:u,showToken:f,setShowToken:g,copied:y,copyToken:b,updateTelegram:x,updateChannelAgentRoute:S,tgAccountsDraft:w,setTgAccountsDraft:T,tgAccountsError:O,onTgAccountsBlur:k,dmOpts:A,groupOpts:j,replyOpts:ee,streamOpts:N,chatAgents:te,saving:P,dirty:re,save:ie,discard:ae}){let oe=V,F=r.telegram,se=a?he(a.telegram):``,ce=he(F),L=!f&&!!String(se).trim()&&ce===se;return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(i,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.telegramTitle}),(0,I.jsx)(c,{className:`mt-1 text-sm text-fg-muted`,children:n.telegramSubtitle})]}),(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.modalCancel,children:(0,I.jsx)(m,{className:`size-4`})})})]}),(0,I.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:F.enabled,onChange:e=>x({enabled:e.target.checked})}),(0,I.jsx)(`span`,{children:n.enableTelegramAria})]}),(0,I.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[n.telegramToken,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(`input`,{className:d(oe(),`min-w-0 flex-1 font-mono text-xs`),type:f?`text`:`password`,autoComplete:`off`,readOnly:L,value:L?`*`.repeat(Math.max(1,se.length)):ce,onChange:e=>{if(L)return;let t=F.accounts?.default??be(`default`);x({accounts:{...F.accounts,default:{...t,accountId:`default`,botToken:e.target.value}}})},placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`}),ce?(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void b(),children:[y?(0,I.jsx)(C,{className:`size-3.5`}):(0,I.jsx)(v,{className:`size-3.5`}),y?n.copied:n.copy]}):null,(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>g(e=>!e),children:[f?(0,I.jsx)(l,{className:`size-3.5`}):(0,I.jsx)(_,{className:`size-3.5`}),f?n.hide:n.show]})]}),(0,I.jsx)(q,{children:n.telegramTokenDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.allowFromDm}),(0,I.jsx)(`textarea`,{className:d(oe(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`123456789, 987654321`,value:W(F.allowFrom),onChange:e=>x({allowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:n.allowFromDmDesc})]}),(0,I.jsx)(Y,{accountIds:ue(F),routes:r.channelAgentRoutes.telegram,defaultAgentId:r.defaultAgentId,agentItems:te?.items??[],disabled:P,onChange:(e,t)=>S(`telegram`,e,t),ch:n}),(0,I.jsxs)(E,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:()=>u(e=>!e),children:[(0,I.jsx)(M,{className:d(`mr-1 size-4 transition-transform`,s&&`rotate-180`)}),s?n.advancedHide:n.advancedShow]}),s?(0,I.jsx)(je,{tg:F,updateTelegram:x,ch:n,dmOpts:A,groupOpts:j,replyOpts:ee,streamOpts:N,tgAccountsDraft:w,setTgAccountsDraft:T,tgAccountsError:O,onTgAccountsBlur:k}):null]}),(0,I.jsxs)(`div`,{className:`mt-8 flex flex-wrap justify-end gap-2 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>t(!1),children:n.modalCancel}),(0,I.jsx)(E,{type:`button`,variant:`secondary`,disabled:!re||P,onClick:ae,children:n.discard}),(0,I.jsx)(E,{type:`button`,variant:`primary`,disabled:!re||P,onClick:async()=>{await ie()&&t(!1)},children:P?n.saving:n.save})]})]})]})})}function Ne(){let e=b(e=>e.language),t=f(e),n=t.channelsSettings,i=!!T(e=>e.token),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[v,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(!1),[w,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),[ee,N]=(0,X.useState)(null),[te,ne]=(0,X.useState)(!1),[P,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!1),[F,se]=(0,X.useState)(!1),[ce,I]=(0,X.useState)(!1),[L,le]=(0,X.useState)(!1),[R,z]=(0,X.useState)(!1),[ue,de]=(0,X.useState)(!1),[fe,pe]=(0,X.useState)(!1),[me,B]=(0,X.useState)(``),[V,H]=(0,X.useState)(``),[U,W]=(0,X.useState)(``),[ge,G]=(0,X.useState)(``),[_e,ve]=(0,X.useState)(``),[K,q]=(0,X.useState)(``),[J,Y]=(0,X.useState)(``),[ye,Z]=(0,X.useState)(``),{data:be}=r(i?`gateway-chat-agents-ch`:null,y,{revalidateOnFocus:!1}),{data:Q,error:Ce,isLoading:Te,mutate:Ee}=re(i),$=(0,X.useMemo)(()=>Q?.payload?.config===void 0?null:Se(Q.payload.config),[Q]),De=(0,X.useMemo)(()=>!a||!s?!1:JSON.stringify(a)!==JSON.stringify(s),[a,s]);(0,X.useEffect)(()=>{if(!i){o(null),c(null);return}$!==null&&(De||(o($),c(structuredClone($)),B(JSON.stringify($.telegram.accounts??{},null,2)),H(``),W(JSON.stringify($.weixin.accounts??{},null,2)),G(``),ve(JSON.stringify($.feishu?.accounts??{},null,2)),q(``),Y(JSON.stringify($.dingtalk?.accounts??{},null,2)),Z(``),h(!1)))},[i,$,De]);let Oe=!!(i&&Te&&Q===void 0&&!Ce),ke=Ce instanceof Error?Ce.message:Ce?String(Ce):null,Ae=(0,X.useCallback)((e,t,n)=>{o(r=>{if(!r)return null;let i=e===`telegram`?`telegram`:e===`weixin`?`weixin`:e===`feishu`?`feishu`:`dingtalk`;return{...r,channelAgentRoutes:{...r.channelAgentRoutes,[i]:{...r.channelAgentRoutes[i],[t]:n.trim().toLowerCase()}}}})},[]),je=(0,X.useCallback)(e=>{o(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),Me=(0,X.useCallback)(e=>{o(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),Ne=(0,X.useCallback)(e=>{o(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]),Pe=(0,X.useCallback)(e=>{o(t=>t?{...t,dingtalk:{...t.dingtalk,...e}}:null)},[]),Fe=(0,X.useCallback)(async()=>{if(!a||l)return!1;u(!0),p(null),h(!1);try{let e=await we(a);o(e);let t=structuredClone(e);return c(t),B(JSON.stringify(t.telegram.accounts??{},null,2)),H(``),W(JSON.stringify(t.weixin.accounts??{},null,2)),G(``),ve(JSON.stringify(t.feishu?.accounts??{},null,2)),q(``),Y(JSON.stringify(t.dingtalk?.accounts??{},null,2)),Z(``),h(!0),window.setTimeout(()=>h(!1),2500),!0}catch(e){return p(e instanceof Error?e.message:n.saveError),!1}finally{u(!1)}},[a,l,n.saveError]),Ie=(0,X.useCallback)(()=>{if(!s)return;let e=structuredClone(s);o(e),B(JSON.stringify(e.telegram.accounts??{},null,2)),H(``),W(JSON.stringify(e.weixin.accounts??{},null,2)),G(``),ve(JSON.stringify(e.feishu?.accounts??{},null,2)),q(``),Y(JSON.stringify(e.dingtalk?.accounts??{},null,2)),Z(``),p(null),h(!1)},[s]),Le=(0,X.useCallback)(async(e,t)=>{if(!a||l)return;let r=a,i=e===`weixin`?{...a,weixin:{...a.weixin,enabled:t}}:e===`telegram`?{...a,telegram:{...a.telegram,enabled:t}}:e===`feishu`?{...a,feishu:{...a.feishu,enabled:t}}:{...a,dingtalk:{...a.dingtalk,enabled:t}};o(i),u(!0),p(null);try{let e=await we(i);o(e);let t=structuredClone(e);c(t),B(JSON.stringify(t.telegram.accounts??{},null,2)),W(JSON.stringify(t.weixin.accounts??{},null,2)),ve(JSON.stringify(t.feishu?.accounts??{},null,2)),Y(JSON.stringify(t.dingtalk?.accounts??{},null,2))}catch(e){p(e instanceof Error?e.message:n.saveError),o(r)}finally{u(!1)}},[a,l,n.saveError]),Re=(0,X.useCallback)(async()=>{if(!a||!D||l)return;let e=xe(),t=D===`weixin`?{...a,weixin:e.weixin}:D===`telegram`?{...a,telegram:e.telegram}:D===`feishu`?{...a,feishu:e.feishu}:{...a,dingtalk:e.dingtalk};u(!0),p(null);try{let e=await we(t);o(e);let n=structuredClone(e);c(n),B(JSON.stringify(n.telegram.accounts??{},null,2)),W(JSON.stringify(n.weixin.accounts??{},null,2)),H(``),G(``),ve(JSON.stringify(n.feishu?.accounts??{},null,2)),q(``),Y(JSON.stringify(n.dingtalk?.accounts??{},null,2)),Z(``),O(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:n.saveError)}finally{u(!1)}},[a,D,l,n.saveError]),ze=(0,X.useCallback)(async()=>{let e=a?he(a.telegram):``;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),le(!0),window.setTimeout(()=>le(!1),2e3))},[a]),Be=(0,X.useCallback)(e=>{Ne({appId:e.appId,domain:e.domain,enabled:!0}),Ee(),M(n.feishuQrSetupSuccess),window.setTimeout(()=>M(null),4e3)},[Ne,Ee,n.feishuQrSetupSuccess]),Ve=(0,X.useCallback)(e=>{Pe({clientId:e.clientId,enabled:!0}),Ee(),N(n.dingtalkQrSetupSuccess),window.setTimeout(()=>N(null),4e3)},[Pe,Ee,n.dingtalkQrSetupSuccess]),He=(0,X.useCallback)(async()=>{let e=a?.dingtalk?.clientSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),de(!0),window.setTimeout(()=>de(!1),2e3))},[a]);return{language:e,m:t,ch:n,hasToken:i,loading:Oe,fetchError:ke,mutate:Ee,form:a,baseline:s,dirty:De,saving:l,error:d,saveOk:m,weixinModalOpen:g,setWeixinModalOpen:_,telegramModalOpen:v,setTelegramModalOpen:x,feishuModalOpen:S,setFeishuModalOpen:C,dingtalkModalOpen:w,setDingtalkModalOpen:E,removeTarget:D,setRemoveTarget:O,weixinSuccessBanner:k,setWeixinSuccessBanner:A,feishuSetupSuccessBanner:j,dingtalkSetupSuccessBanner:ee,tgAdvanced:te,setTgAdvanced:ne,showToken:P,setShowToken:ie,showFeishuSecret:ae,setShowFeishuSecret:oe,showFeishuWebhookSecrets:F,setShowFeishuWebhookSecrets:se,showDingtalkSecret:ce,setShowDingtalkSecret:I,copied:L,feishuCopied:R,dingtalkCopied:ue,feishuWebhookCopied:fe,tgAccountsDraft:me,setTgAccountsDraft:B,tgAccountsError:V,wxAccountsDraft:U,setWxAccountsDraft:W,wxAccountsError:ge,feishuAccountsDraft:_e,setFeishuAccountsDraft:ve,feishuAccountsError:K,dingtalkAccountsDraft:J,setDingtalkAccountsDraft:Y,dingtalkAccountsError:ye,chatAgents:be,updateChannelAgentRoute:Ae,updateTelegram:je,updateWeixin:Me,updateFeishu:Ne,updateDingtalk:Pe,save:Fe,discard:Ie,toggleChannelEnabled:Le,removeChannel:Re,copyToken:ze,handleFeishuQrSetupSuccess:Be,handleDingtalkQrSetupSuccess:Ve,copyFeishuSecret:(0,X.useCallback)(async()=>{let e=a?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),z(!0),window.setTimeout(()=>z(!1),2e3))},[a]),copyDingtalkSecret:He,copyFeishuWebhookConfig:(0,X.useCallback)(async()=>{let e=a?.feishu;if(!e)return;let t={connectionMode:e.connectionMode,verificationToken:e.verificationToken||``,encryptKey:e.encryptKey||``,webhookHost:e.webhookHost||``,webhookPort:e.webhookPort||0,webhookPath:e.webhookPath||``};await navigator.clipboard.writeText(JSON.stringify(t,null,2)).catch(()=>{}),pe(!0),window.setTimeout(()=>pe(!1),2e3)},[a]),onTgAccountsBlur:(0,X.useCallback)(()=>{if(!a)return;let e=me.trim();if(!e){je({accounts:{}}),H(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);je({accounts:t}),H(``)}catch(e){H(e instanceof Error?e.message:n.jsonInvalid)}},[a,me,je,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,X.useCallback)(()=>{if(!a)return;let e=U.trim();if(!e){Me({accounts:{}}),G(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);Me({accounts:t}),G(``)}catch(e){G(e instanceof Error?e.message:n.jsonInvalid)}},[a,U,Me,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,X.useCallback)(()=>{if(!a)return;let e=_e.trim();if(!e){Ne({accounts:{}}),q(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);Ne({accounts:t}),q(``)}catch(e){q(e instanceof Error?e.message:n.jsonInvalid)}},[a,_e,Ne,n.jsonObjectAccounts,n.jsonInvalid]),onDingtalkAccountsBlur:(0,X.useCallback)(()=>{if(!a)return;let e=J.trim();if(!e){Pe({accounts:{}}),Z(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);Pe({accounts:t}),Z(``)}catch(e){Z(e instanceof Error?e.message:n.jsonInvalid)}},[a,J,Pe,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,X.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,X.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,X.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,X.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}function Pe({open:e,onOpenChange:t,ch:n,onLoginSuccess:r,moreSettings:a}){let[s,l]=(0,X.useState)(!1),[f,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),[T,O]=(0,X.useState)(!1),k=(0,X.useCallback)(async()=>{b(null),S(null),g(null),l(!0);try{let e=await Q();v(e.qrcodeUrl),g(e.sessionKey)}catch(e){b(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,X.useEffect)(()=>{if(!e){g(null),v(null),b(null),w(null),O(!1),S(null);return}k()},[e,k]),(0,X.useEffect)(()=>{if(!f)return;let e=!1,i,a=async()=>{try{let a=await Ce(f);if(e)return;if(a.phase===`polling`){v(a.qrcodeUrl),a.qrStatus===`scaned`?S(n.weixinQrLoginScanned):S(null);return}if(a.phase===`done`){i!==void 0&&(window.clearInterval(i),i=void 0),g(null),a.ok?(v(null),t(!1),await r()):(b(a.message),v(null));return}a.phase===`unknown`&&S(null)}catch(t){e||(i!==void 0&&window.clearInterval(i),b(t instanceof Error?t.message:`Request failed`),g(null),v(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[f,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,X.useEffect)(()=>{if(!_){w(null),O(!1);return}let e=!1;return O(!1),Z.toDataURL(_,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||w(t)}).catch(()=>{e||(O(!0),w(null))}),()=>{e=!0}},[_]);let A=!!(_&&f),j=e&&!y&&!A;return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.weixinQrModalCloseAria,children:(0,I.jsx)(m,{className:`size-4`})})}),(0,I.jsx)(i,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,I.jsx)(c,{className:`sr-only`,children:n.weixinQrModalSubtitle}),(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.weixinQrModalTitle}),(0,I.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.weixinQrModalSubtitle})]}),(0,I.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[y?(0,I.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:y}):null,!y&&(A||j)?(0,I.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,I.jsx)(`p`,{className:d(`min-h-[1.25rem] text-center text-sm`,x&&!j?`text-accent`:`text-fg-muted`),children:j?n.weixinQrLoginBusy:x??`\xA0`}),(0,I.jsxs)(`div`,{className:d(`relative flex h-52 w-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,j&&`bg-surface-muted/40 dark:bg-surface-base`),children:[j?(0,I.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,A&&_&&!y&&C&&!T?(0,I.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,A&&_&&!y&&!C&&!T&&!j?(0,I.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,A&&_&&!y&&T?(0,I.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,I.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.weixinQrImageError}),(0,I.jsxs)(`a`,{href:_,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,I.jsx)(u,{className:`size-3 shrink-0`}),n.weixinQrOpenLink]})]}):null]})]}):null]}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:s,onClick:()=>void k(),children:s?n.weixinQrLoginBusy:n.weixinQrRegenerate})}),a?(0,I.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:a}):null]})]})})}function Fe({wx:e,updateWeixin:t,ch:n,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,channelAgentRoutesWx:l,defaultAgentId:u,agentItems:f,onAgentRouteChange:p,routingDisabled:m}){let h=V;return(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.weixinAllowFrom}),(0,I.jsx)(`textarea`,{className:d(h(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`wxid_..., openid_...`,value:e.allowFrom.join(`, `),onChange:e=>t({allowFrom:e.target.value.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)})}),(0,I.jsx)(q,{children:n.weixinAllowFromDesc})]}),(0,I.jsx)(J,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,I.jsx)(J,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:i}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.historyLimit}),(0,I.jsx)(`input`,{type:`number`,min:10,max:200,className:h(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.textChunkLimit}),(0,I.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:h(),value:e.textChunkLimit,onChange:e=>t({textChunkLimit:parseInt(e.target.value,10)||4e3})})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.weixinRouteTag}),(0,I.jsx)(`input`,{className:h(),value:e.routeTag,onChange:e=>t({routeTag:e.target.value}),placeholder:n.routeTagPlaceholder}),(0,I.jsx)(q,{children:n.weixinRouteTagDesc})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.weixinDebug]}),(0,I.jsx)(q,{children:n.weixinDebugDesc}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.weixinAccountsJson}),(0,I.jsx)(`textarea`,{className:d(h(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:a,onChange:e=>o(e.target.value),onBlur:c,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),s?(0,I.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:s}):(0,I.jsx)(q,{children:n.weixinAccountsJsonDesc})]}),(0,I.jsx)(Y,{accountIds:de(e),routes:l,defaultAgentId:u,agentItems:f,disabled:m,onChange:p,ch:n})]})}function Ie({ch:e,wx:t,updateWeixin:n,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,form:l,chatAgents:u,onAgentRouteChange:d,saving:f,dirty:p,save:m,discard:h}){return(0,I.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,I.jsx)(M,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.weixinAdvancedHint}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:t.enabled,onChange:e=>n({enabled:e.target.checked})}),(0,I.jsx)(`span`,{children:e.enableWeixinAria})]}),(0,I.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,I.jsx)(Fe,{wx:t,updateWeixin:n,ch:e,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,channelAgentRoutesWx:l.channelAgentRoutes.weixin,defaultAgentId:l.defaultAgentId,agentItems:u?.items??[],onAgentRouteChange:d,routingDisabled:f})}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!p||f,onClick:h,children:e.discard}),(0,I.jsx)(E,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!p||f,onClick:async()=>{await m()},children:f?e.saving:e.save})]})]})]})}function Le(){let{language:e,m:t,ch:n,hasToken:r,loading:i,fetchError:a,mutate:o,form:s,baseline:c,dirty:l,saving:d,error:f,saveOk:p,weixinModalOpen:m,setWeixinModalOpen:h,telegramModalOpen:g,setTelegramModalOpen:_,feishuModalOpen:v,setFeishuModalOpen:y,removeTarget:b,setRemoveTarget:S,weixinSuccessBanner:C,setWeixinSuccessBanner:T,dingtalkModalOpen:D,setDingtalkModalOpen:O,feishuSetupSuccessBanner:k,dingtalkSetupSuccessBanner:A,tgAdvanced:M,setTgAdvanced:N,showToken:te,setShowToken:ne,showFeishuSecret:P,setShowFeishuSecret:re,showFeishuWebhookSecrets:ie,setShowFeishuWebhookSecrets:ae,showDingtalkSecret:oe,setShowDingtalkSecret:F,copied:se,feishuCopied:ce,dingtalkCopied:R,feishuWebhookCopied:z,tgAccountsDraft:ue,setTgAccountsDraft:de,tgAccountsError:fe,wxAccountsDraft:pe,setWxAccountsDraft:me,wxAccountsError:B,feishuAccountsDraft:V,setFeishuAccountsDraft:H,feishuAccountsError:U,dingtalkAccountsDraft:W,setDingtalkAccountsDraft:he,dingtalkAccountsError:K,chatAgents:q,updateChannelAgentRoute:J,updateTelegram:Y,updateWeixin:X,updateFeishu:Z,updateDingtalk:be,save:xe,discard:Se,toggleChannelEnabled:Q,removeChannel:Ce,copyToken:we,handleFeishuQrSetupSuccess:Te,handleDingtalkQrSetupSuccess:Ee,copyFeishuSecret:$,copyDingtalkSecret:De,copyFeishuWebhookConfig:je,onTgAccountsBlur:Fe,onWxAccountsBlur:Le,onFeishuAccountsBlur:Re,onDingtalkAccountsBlur:ze,dmOpts:Be,groupOpts:Ve,replyOpts:He,streamOpts:Ue}=Ne();if(!r)return(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,I.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.channels}),(0,I.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]});if(i)return(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,I.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,I.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,I.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:n.loading})]});if(!s)return(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f??a??n.loadError}),(0,I.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>void o(),children:n.retry})]});let We=s.weixin,Ge=s.telegram,Ke=s.feishu,qe=s.dingtalk,Je=G(We),Ye=ge(Ge),Xe=_e(Ke),Ze=ve(qe),Qe=(0,I.jsx)(ke,{ch:n,form:s,baseline:c,showFeishuSecret:P,setShowFeishuSecret:re,showFeishuWebhookSecrets:ie,setShowFeishuWebhookSecrets:ae,feishuCopied:ce,feishuWebhookCopied:z,copyFeishuSecret:$,copyFeishuWebhookConfig:je,updateFeishu:Z,updateChannelAgentRoute:J,feishuAccountsDraft:V,setFeishuAccountsDraft:H,feishuAccountsError:U,onFeishuAccountsBlur:Re,dmOpts:Be,groupOpts:Ve,chatAgents:q,saving:d,dirty:l,save:xe,discard:Se}),$e=(0,I.jsx)(ye,{ch:n,form:s,baseline:c,showDingtalkSecret:oe,setShowDingtalkSecret:F,dingtalkCopied:R,copyDingtalkSecret:De,updateDingtalk:be,updateChannelAgentRoute:J,dingtalkAccountsDraft:W,setDingtalkAccountsDraft:he,dingtalkAccountsError:K,onDingtalkAccountsBlur:ze,dmOpts:Be,groupOpts:Ve,chatAgents:q,saving:d,dirty:l,save:xe,discard:Se}),et=(0,I.jsx)(Ie,{ch:n,wx:We,updateWeixin:X,dmOpts:Be,streamOpts:Ue,wxAccountsDraft:pe,setWxAccountsDraft:me,wxAccountsError:B,onWxAccountsBlur:Le,form:s,chatAgents:q,onAgentRouteChange:(e,t)=>J(`weixin`,e,t),saving:d,dirty:l,save:xe,discard:Se});return(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,I.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.channels}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,I.jsxs)(`a`,{href:w(e,`channels`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,I.jsx)(u,{className:`size-3.5`})]})]}),l?(0,I.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,p?(0,I.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.saved}):null,f?(0,I.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}):null,C?(0,I.jsx)(`p`,{className:`text-xs text-accent`,children:C}):null,k?(0,I.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:k}):null,A?(0,I.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:A}):null,(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsx)(L,{icon:(0,I.jsx)(ee,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.weixinTitle,subtitle:n.weixinSubtitle,configured:Je,enabled:We.enabled,toggleDisabled:d,onToggle:e=>void Q(`weixin`,e),onConfigure:()=>h(!0),onEdit:()=>h(!0),onRemove:()=>S(`weixin`),ch:n}),(0,I.jsx)(L,{icon:(0,I.jsx)(j,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.telegramTitle,subtitle:n.telegramSubtitle,configured:Ye,enabled:Ge.enabled,toggleDisabled:d,onToggle:e=>void Q(`telegram`,e),onConfigure:()=>_(!0),onEdit:()=>_(!0),onRemove:()=>S(`telegram`),ch:n}),(0,I.jsx)(L,{icon:(0,I.jsx)(ee,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.feishuTitle,subtitle:n.feishuSubtitle,configured:Xe,enabled:Ke.enabled,toggleDisabled:d,onToggle:e=>void Q(`feishu`,e),onConfigure:()=>y(!0),onEdit:()=>y(!0),onRemove:()=>S(`feishu`),ch:n}),(0,I.jsx)(L,{icon:(0,I.jsx)(x,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.dingtalkTitle,subtitle:n.dingtalkSubtitle,configured:Ze,enabled:qe.enabled,toggleDisabled:d,onToggle:e=>void Q(`dingtalk`,e),onConfigure:()=>O(!0),onEdit:()=>O(!0),onRemove:()=>S(`dingtalk`),ch:n})]}),(0,I.jsx)(Pe,{open:m,onOpenChange:h,ch:n,onLoginSuccess:async()=>{await o(),T(n.weixinQrLoginSuccess),window.setTimeout(()=>T(null),4e3)},moreSettings:et}),(0,I.jsx)(Me,{open:g,onOpenChange:_,ch:n,form:s,baseline:c,tgAdvanced:M,setTgAdvanced:N,showToken:te,setShowToken:ne,copied:se,copyToken:we,updateTelegram:Y,updateChannelAgentRoute:J,tgAccountsDraft:ue,setTgAccountsDraft:de,tgAccountsError:fe,onTgAccountsBlur:Fe,dmOpts:Be,groupOpts:Ve,replyOpts:He,streamOpts:Ue,chatAgents:q,saving:d,dirty:l,save:xe,discard:Se}),(0,I.jsx)(Ae,{open:v,onOpenChange:y,ch:n,onSetupSuccess:Te,moreSettings:Qe}),(0,I.jsx)(Oe,{open:D,onOpenChange:O,ch:n,onSetupSuccess:Ee,moreSettings:$e}),(0,I.jsx)(le,{open:b!==null,onOpenChange:e=>{e||S(null)},ch:n,removeTarget:b,onCancel:()=>S(null),saving:d,onConfirmRemove:()=>void Ce()})]})}export{Le as ChannelsSettingsPanel};
|
|
2
|
-
//# sourceMappingURL=channels-settings-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{i as t,t as n}from"./vendor-react-DbimaAId.js";import{i as r}from"./vendor-swr-B5fPo7KK.js";import{At as i,Dn as a,Dt as o,En as s,Et as c,Gr as l,Kr as u,Mn as d,On as f,Ot as p,Pn as m,Tt as h,Vn as g,Wr as _,Zr as v,_t as y,bn as b,br as x,cn as S,di as C,gn as w,hn as T,kn as E,kt as D,mr as O,pn as k,qr as A,tr as j,ui as M,vr as ee,vt as N,wn as te,wt as ne,x as P,yt as re}from"./index-xAzvk1zE.js";import{a as ie,i as ae,n as oe,r as F,t as se}from"./dist-tEQzKijF.js";import{t as ce}from"./browser-DNXWYwzc.js";var I=n();function L({icon:e,title:t,subtitle:n,configured:r,enabled:i,onToggle:a,toggleDisabled:o,onConfigure:s,onEdit:c,onRemove:l,ch:u}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-2xl border border-edge bg-surface-base px-4 py-4 dark:border-edge sm:flex-row sm:items-center sm:gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[(0,I.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:e}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),r?(0,I.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-xs font-medium text-success`,children:u.hubConnectedBadge}):null]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n})]})]}),r?(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,I.jsxs)(ae,{children:[(0,I.jsx)(ie,{asChild:!0,children:(0,I.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u.menuMoreAria,children:(0,I.jsx)(A,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,I.jsx)(F,{children:(0,I.jsxs)(se,{className:`z-[70] min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,I.jsx)(oe,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>c(),children:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(O,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),u.menuEditConfig]})}),(0,I.jsx)(oe,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>l(),children:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(g,{className:`size-4 shrink-0`,strokeWidth:1.75}),u.menuRemoveConfig]})})]})})]}),(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} — ${u.enableChannelAria}`,disabled:o,className:d(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,i?`justify-end bg-accent`:`justify-start bg-surface-hover`,o&&`cursor-not-allowed opacity-50`),onClick:()=>void a(!i),children:(0,I.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,I.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,I.jsx)(E,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:s,children:u.hubConfigureButton})})]})}function le({open:e,onOpenChange:t,ch:n,removeTarget:r,onCancel:a,saving:s,onConfirmRemove:l}){return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[70] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsx)(i,{className:`text-base font-semibold text-fg`,children:n.removeChannelTitle}),(0,I.jsx)(c,{className:`mt-2 text-sm text-fg-muted`,children:r?n.removeChannelConfirm.replace(`{{name}}`,r===`weixin`?n.weixinTitle:r===`telegram`?n.telegramTitle:r===`feishu`?n.feishuTitle:n.dingtalkTitle):`\xA0`}),(0,I.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}),(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:s,onClick:l,children:s?n.saving:n.removeChannelAction})]})]})]})})}function R(e){return(e??``).trim().toLowerCase()}function z(e){let t=e.match;return!(!t?.channel||!t.accountId||t.peerId||t.peerKind||t.guildId||t.teamId||t.memberRoleIds&&t.memberRoleIds.length>0)}function ue(e){return Object.keys(e.accounts??{}).sort()}function de(e){return Object.keys(e.accounts??{}).sort()}function fe(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.appId==`string`&&e.appId.trim()&&typeof e.appSecret==`string`&&e.appSecret.trim()?[`default`]:[]}function pe(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.clientId==`string`&&e.clientId.trim()&&typeof e.clientSecret==`string`&&e.clientSecret.trim()?[`default`]:[]}function me(e,t,n,r,i,a){let o={},s={},c={},l={};for(let n of t)o[n]=(e.find(e=>R(e.match?.channel)===`telegram`&&R(e.match?.accountId)===R(n)&&z(e))?.agentId??a).trim().toLowerCase();for(let t of n)s[t]=(e.find(e=>R(e.match?.channel)===`weixin`&&R(e.match?.accountId)===R(t)&&z(e))?.agentId??a).trim().toLowerCase();for(let t of r)c[t]=(e.find(e=>R(e.match?.channel)===`feishu`&&R(e.match?.accountId)===R(t)&&z(e))?.agentId??a).trim().toLowerCase();for(let t of i)l[t]=(e.find(e=>R(e.match?.channel)===`dingtalk`&&R(e.match?.accountId)===R(t)&&z(e))?.agentId??a).trim().toLowerCase();return{telegram:o,weixin:s,feishu:c,dingtalk:l}}function B(e,t,n,r,i,a,o){let s=new Set(n.map(R)),c=new Set(r.map(R)),l=new Set(i.map(R)),u=new Set(a.map(R)),d=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!z(e))return!0;let t=R(e.match.channel),n=R(e.match.accountId);return!n||n===`*`?!0:!(t===`telegram`&&s.has(n)||t===`weixin`&&c.has(n)||t===`feishu`&&l.has(n)||t===`dingtalk`&&u.has(n))}),f=[];for(let e of n){let n=(t.telegram[e]??t.telegram[R(e)]??o).trim().toLowerCase();f.push({id:`ui:route:account:telegram:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`telegram`,accountId:e}})}for(let e of r){let n=(t.weixin[e]??t.weixin[R(e)]??o).trim().toLowerCase();f.push({id:`ui:route:account:weixin:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`weixin`,accountId:e}})}for(let e of i){let n=(t.feishu[e]??t.feishu[R(e)]??o).trim().toLowerCase();f.push({id:`ui:route:account:feishu:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`feishu`,accountId:e}})}for(let e of a){let n=(t.dingtalk[e]??t.dingtalk[R(e)]??o).trim().toLowerCase();f.push({id:`ui:route:account:dingtalk:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`dingtalk`,accountId:e}})}return[...d,...f]}function V(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,a,`dark:border-edge`)}function H(){return d(s,te)}function U(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).map(e=>/^-?\d+$/.test(e)?Number(e):e)}function W(e){return e.map(String).join(`, `)}function he(e){let t=e.accounts?.default?.botToken;return typeof t==`string`?t:``}function ge(e){return Object.values(e.accounts??{}).some(e=>typeof e.botToken==`string`&&e.botToken.trim().length>0)}function G(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function _e(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}function ve(e){return!!(e.clientId?.trim()&&e.clientSecret?.trim())||Object.keys(e.accounts??{}).length>0}function K({children:e}){return(0,I.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e})}function q({children:e}){return(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:e})}function J({label:e,value:t,onChange:n,options:r}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e}),(0,I.jsx)(`select`,{className:H(),value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function Y({accountIds:e,routes:t,defaultAgentId:n,agentItems:r,disabled:i,onChange:a,ch:o}){let s=f(b(e=>e.language)).agentsSettings;if(e.length===0)return null;let c=r.length>0?r:[{id:n}];return(0,I.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(K,{children:o.agentRoutingTitle}),(0,I.jsx)(q,{children:o.agentRoutingHint})]}),(0,I.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2.5 sm:grid-cols-2 sm:items-center dark:border-edge`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:o.agentRoutingAccountLabel}),(0,I.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:e,children:e})]}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${e}`,children:o.agentRoutingAgentLabel}),(0,I.jsx)(`select`,{id:`agent-route-${e}`,className:d(V(),te),disabled:i,value:(t[e]??n).toLowerCase(),onChange:t=>a(e,t.target.value),children:c.map(e=>(0,I.jsx)(`option`,{value:e.id,children:`${P(e,s)} (${e.id})`},e.id))})]})]},e))})]})}function ye({ch:e,form:t,baseline:n,showDingtalkSecret:r,setShowDingtalkSecret:i,dingtalkCopied:a,copyDingtalkSecret:o,updateDingtalk:s,updateChannelAgentRoute:c,dingtalkAccountsDraft:u,setDingtalkAccountsDraft:f,dingtalkAccountsError:p,onDingtalkAccountsBlur:m,dmOpts:h,groupOpts:g,chatAgents:y,saving:b,dirty:x,save:S,discard:w}){let T=V,D=t.dingtalk,O=n?.dingtalk?.clientSecret??``,k=!r&&!!String(O).trim()&&D.clientSecret===O;return(0,I.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,I.jsx)(M,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.dingtalkAdvancedHint}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:D.enabled,onChange:e=>s({enabled:e.target.checked})}),(0,I.jsx)(`span`,{children:e.enableDingtalkAria})]}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[e.dingtalkClientId,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),value:D.clientId,onChange:e=>s({clientId:e.target.value}),placeholder:`dingxxx`}),(0,I.jsx)(q,{children:e.dingtalkClientIdDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[e.dingtalkClientSecret,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),type:r?`text`:`password`,autoComplete:`off`,readOnly:k,value:k?`*`.repeat(Math.max(1,D.clientSecret.length)):D.clientSecret,onChange:e=>{k||s({clientSecret:e.target.value})},placeholder:`••••••••`}),D.clientSecret?(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void o(),children:[a?(0,I.jsx)(C,{className:`size-3.5`}):(0,I.jsx)(v,{className:`size-3.5`}),a?e.copied:e.copy]}):null,(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>i(e=>!e),children:[r?(0,I.jsx)(l,{className:`size-3.5`}):(0,I.jsx)(_,{className:`size-3.5`}),r?e.hide:e.show]})]}),(0,I.jsx)(q,{children:e.dingtalkClientSecretDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.dingtalkEndpoint}),(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),value:D.endpoint,onChange:e=>s({endpoint:e.target.value}),placeholder:`https://api.dingtalk.com`}),(0,I.jsx)(q,{children:e.dingtalkEndpointDesc})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.debug,onChange:e=>s({debug:e.target.checked})}),e.dingtalkDebug]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.dmPolicy}),(0,I.jsx)(`select`,{className:T(),value:D.dmPolicy,onChange:e=>s({dmPolicy:e.target.value}),children:h.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.groupPolicy}),(0,I.jsx)(`select`,{className:T(),value:D.groupPolicy,onChange:e=>s({groupPolicy:e.target.value}),children:g.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.requireMention,onChange:e=>s({requireMention:e.target.checked})}),e.requireMention]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.allowFromDm}),(0,I.jsx)(`textarea`,{className:d(T(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`userId1, userId2`,value:W(D.allowFrom),onChange:e=>s({allowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:e.allowFromDmDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.allowFromGroups}),(0,I.jsx)(`textarea`,{className:d(T(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`openConversationId1`,value:W(D.groupAllowFrom),onChange:e=>s({groupAllowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:e.allowFromGroupsDesc})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.historyLimit}),(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(D.historyLimit),onChange:e=>s({historyLimit:Number(e.target.value||`0`)||0})})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.textChunkLimit}),(0,I.jsx)(`input`,{className:d(T(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(D.textChunkLimit),onChange:e=>s({textChunkLimit:Number(e.target.value||`0`)||0})})]})]}),(0,I.jsx)(Y,{accountIds:pe(D),routes:t.channelAgentRoutes.dingtalk,defaultAgentId:t.defaultAgentId,agentItems:y?.items??[],disabled:b,onChange:(e,t)=>c(`dingtalk`,e,t),ch:e}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.multiAccountJson}),(0,I.jsx)(`textarea`,{className:d(T(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:u,onChange:e=>f(e.target.value),onBlur:m,placeholder:`{ "default": { "clientId": "...", "clientSecret": "...", "enabled": true } }`}),p?(0,I.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:p}):(0,I.jsx)(q,{children:e.multiAccountJsonDesc})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!x||b,onClick:w,children:e.discard}),(0,I.jsx)(E,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!x||b,onClick:async()=>{await S()},children:b?e.saving:e.save})]})]})]})}var X=e(t(),1),Z=e(ce(),1);function be(e){return{accountId:e,name:``,enabled:!0,botToken:``,allowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,apiRoot:``,proxy:``,historyLimit:50,textChunkLimit:4e3,streamMode:`partial`}}function xe(){return{bindingsFull:[],channelAgentRoutes:{telegram:{},weixin:{},feishu:{},dingtalk:{}},defaultAgentId:`main`,telegram:{enabled:!1,apiRoot:``,debug:!1,allowFrom:[],groupAllowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,proxy:``,accounts:{default:be(`default`)}},weixin:{enabled:!1,dmPolicy:`pairing`,allowFrom:[],debug:!1,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,routeTag:``,accounts:{}},feishu:{enabled:!1,defaultAccount:``,appId:``,appSecret:``,domain:`feishu`,connectionMode:`websocket`,verificationToken:``,encryptKey:``,webhookHost:`127.0.0.1`,webhookPort:3e3,webhookPath:`/feishu/events`,dmPolicy:`pairing`,groupPolicy:`allowlist`,allowFrom:[],groupAllowFrom:[],requireMention:!0,historyLimit:50,textChunkLimit:4e3,renderMode:`auto`,streaming:!1,reactionNotifications:`own`,tools:{doc:!0,wiki:!0,drive:!0,scopes:!0,bitable:!0,perm:!1},actions:{reactions:!0},accounts:{}},dingtalk:{enabled:!1,defaultAccount:``,clientId:``,clientSecret:``,dmPolicy:`pairing`,groupPolicy:`open`,allowFrom:[],groupAllowFrom:[],requireMention:!1,debug:!1,endpoint:`https://api.dingtalk.com`,historyLimit:50,textChunkLimit:4e3,accounts:{}}}}function Se(e){let t=e&&typeof e==`object`?e.channels:void 0,n=t&&typeof t==`object`?t:{},r=n.telegram,i=n.weixin,a=n.feishu,o=n.dingtalk,s=r?.accounts,c=s&&typeof s==`object`&&!Array.isArray(s)?{...s}:{},l=typeof r?.botToken==`string`?r.botToken.trim():``,u=c.default?.botToken?.trim()??``;l&&!u&&(c={...c,default:{...c.default??be(`default`),accountId:`default`,botToken:l}}),c.default||(c={...c,default:be(`default`)});let d=i?.accounts,f=d&&typeof d==`object`&&!Array.isArray(d)?d:{},p=(()=>{let t=(e&&typeof e==`object`?e:{}).bindings;return Array.isArray(t)?t:[]})(),m=(()=>{let t=(e&&typeof e==`object`?e:{}).agents;return t&&typeof t==`object`?t:{}})(),h=typeof m.defaultId==`string`&&m.defaultId.trim()?m.defaultId.trim().toLowerCase():`main`,g={telegram:{enabled:!!r?.enabled,apiRoot:typeof r?.apiRoot==`string`?r.apiRoot:``,debug:!!r?.debug,allowFrom:Array.isArray(r?.allowFrom)?[...r.allowFrom]:[],groupAllowFrom:Array.isArray(r?.groupAllowFrom)?[...r.groupAllowFrom]:[],dmPolicy:r?.dmPolicy||`pairing`,groupPolicy:r?.groupPolicy||`open`,replyToMode:r?.replyToMode||`off`,streamMode:r?.streamMode??`partial`,historyLimit:typeof r?.historyLimit==`number`?r.historyLimit:50,textChunkLimit:typeof r?.textChunkLimit==`number`?r.textChunkLimit:4e3,proxy:typeof r?.proxy==`string`?r.proxy:``,accounts:{...c}},weixin:{enabled:!!i?.enabled,dmPolicy:i?.dmPolicy||`pairing`,allowFrom:Array.isArray(i?.allowFrom)?[...i.allowFrom]:[],debug:!!i?.debug,streamMode:i?.streamMode??`partial`,historyLimit:typeof i?.historyLimit==`number`?i.historyLimit:50,textChunkLimit:typeof i?.textChunkLimit==`number`?i.textChunkLimit:4e3,routeTag:i?.routeTag==null?``:String(i.routeTag),accounts:{...f}},feishu:{enabled:!!a?.enabled,defaultAccount:typeof a?.defaultAccount==`string`?a.defaultAccount:``,appId:typeof a?.appId==`string`?a.appId:``,appSecret:typeof a?.appSecret==`string`?a.appSecret:``,domain:typeof a?.domain==`string`&&a.domain||`feishu`,connectionMode:a?.connectionMode||`websocket`,verificationToken:typeof a?.verificationToken==`string`?a.verificationToken:``,encryptKey:typeof a?.encryptKey==`string`?a.encryptKey:``,webhookHost:typeof a?.webhookHost==`string`?a.webhookHost:`127.0.0.1`,webhookPort:typeof a?.webhookPort==`number`?a.webhookPort:3e3,webhookPath:typeof a?.webhookPath==`string`?a.webhookPath:`/feishu/events`,dmPolicy:a?.dmPolicy||`pairing`,groupPolicy:a?.groupPolicy||`allowlist`,allowFrom:Array.isArray(a?.allowFrom)?[...a.allowFrom]:[],groupAllowFrom:Array.isArray(a?.groupAllowFrom)?[...a.groupAllowFrom]:[],requireMention:a?.requireMention===void 0?!0:!!a.requireMention,historyLimit:typeof a?.historyLimit==`number`?a.historyLimit:50,textChunkLimit:typeof a?.textChunkLimit==`number`?a.textChunkLimit:4e3,renderMode:a?.renderMode||`auto`,streaming:a?.streaming===void 0?!1:!!a.streaming,reactionNotifications:a?.reactionNotifications||`own`,tools:a?.tools&&typeof a.tools==`object`&&!Array.isArray(a.tools)?{...a.tools}:void 0,actions:a?.actions&&typeof a.actions==`object`&&!Array.isArray(a.actions)?{...a.actions}:void 0,accounts:a?.accounts&&typeof a.accounts==`object`&&!Array.isArray(a.accounts)?{...a.accounts}:{}},dingtalk:{enabled:!!o?.enabled,defaultAccount:typeof o?.defaultAccount==`string`?o.defaultAccount:``,clientId:typeof o?.clientId==`string`?o.clientId:``,clientSecret:typeof o?.clientSecret==`string`?o.clientSecret:``,dmPolicy:o?.dmPolicy||`pairing`,groupPolicy:o?.groupPolicy||`open`,allowFrom:Array.isArray(o?.allowFrom)?[...o.allowFrom]:[],groupAllowFrom:Array.isArray(o?.groupAllowFrom)?[...o.groupAllowFrom]:[],requireMention:o?.requireMention===!0,debug:!!o?.debug,endpoint:typeof o?.endpoint==`string`&&o.endpoint.trim()?o.endpoint.trim():`https://api.dingtalk.com`,historyLimit:typeof o?.historyLimit==`number`?o.historyLimit:50,textChunkLimit:typeof o?.textChunkLimit==`number`?o.textChunkLimit:4e3,accounts:o?.accounts&&typeof o.accounts==`object`&&!Array.isArray(o.accounts)?{...o.accounts}:{}}},_=me(p,ue(g.telegram),de(g.weixin),fe(g.feishu),pe(g.dingtalk),h);return{...g,bindingsFull:p.map(e=>({...e})),channelAgentRoutes:_,defaultAgentId:h}}async function Q(e){return(await k(S(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Ce(e){return(await k(S(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function we(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=e.dingtalk,a=B(e.bindingsFull,e.channelAgentRoutes,ue(t),de(n),fe(r),pe(i),e.defaultAgentId),o=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),s=(await k(S(`/api/config`),{method:`PATCH`,body:JSON.stringify({bindings:a,channels:{telegram:{enabled:t.enabled,apiRoot:t.apiRoot||void 0,debug:t.debug,allowFrom:t.allowFrom,groupAllowFrom:t.groupAllowFrom.length?t.groupAllowFrom:void 0,dmPolicy:t.dmPolicy,groupPolicy:t.groupPolicy,replyToMode:t.replyToMode,streamMode:t.streamMode,historyLimit:t.historyLimit,textChunkLimit:t.textChunkLimit,proxy:t.proxy||void 0,accounts:t.accounts},weixin:{enabled:n.enabled,dmPolicy:n.dmPolicy,allowFrom:n.allowFrom,debug:n.debug,streamMode:n.streamMode,historyLimit:n.historyLimit,textChunkLimit:n.textChunkLimit,routeTag:o,accounts:n.accounts},feishu:{enabled:r.enabled,defaultAccount:r.defaultAccount||void 0,appId:r.appId,appSecret:r.appSecret||void 0,domain:r.domain||void 0,connectionMode:r.connectionMode,verificationToken:r.verificationToken?.trim()?r.verificationToken:void 0,encryptKey:r.encryptKey?.trim()?r.encryptKey:void 0,webhookHost:r.webhookHost?.trim()?r.webhookHost:void 0,webhookPort:typeof r.webhookPort==`number`?r.webhookPort:void 0,webhookPath:r.webhookPath?.trim()?r.webhookPath:void 0,dmPolicy:r.dmPolicy,groupPolicy:r.groupPolicy,allowFrom:r.allowFrom,groupAllowFrom:r.groupAllowFrom.length?r.groupAllowFrom:void 0,requireMention:r.requireMention,historyLimit:r.historyLimit,textChunkLimit:r.textChunkLimit,renderMode:r.renderMode,streaming:r.streaming,reactionNotifications:r.reactionNotifications,tools:r.tools,actions:r.actions,accounts:r.accounts},dingtalk:{enabled:i.enabled,defaultAccount:i.defaultAccount||void 0,clientId:i.clientId,clientSecret:i.clientSecret||void 0,dmPolicy:i.dmPolicy,groupPolicy:i.groupPolicy,allowFrom:i.allowFrom,groupAllowFrom:i.groupAllowFrom.length?i.groupAllowFrom:void 0,requireMention:i.requireMention,debug:i.debug,endpoint:i.endpoint?.trim()?i.endpoint:void 0,historyLimit:i.historyLimit,textChunkLimit:i.textChunkLimit,accounts:i.accounts}}})})).payload?.config;return N(),s?Se(s):{...e,bindingsFull:a}}async function Te(e){return(await k(S(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Ee(e){return(await k(S(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}async function $(){return(await k(S(`/api/channels/dingtalk/setup/start`),{method:`POST`,body:JSON.stringify({})})).payload}async function De(e){return(await k(S(`/api/channels/dingtalk/setup/${encodeURIComponent(e)}`))).payload.status}function Oe({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:a}){let[s,l]=(0,X.useState)(!1),[f,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(!1),T=(0,X.useCallback)(async()=>{b(null),g(null),v(null),l(!0);try{let e=await $();v(e.qrUrl),g(e.sessionKey)}catch(e){b(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,X.useEffect)(()=>{if(!e){g(null),v(null),b(null),S(null),w(!1),l(!1);return}T()},[e,T]),(0,X.useEffect)(()=>{if(!f)return;let e=!1,n,i=async()=>{try{let i=await De(f);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),g(null),i.ok?(v(null),t(!1),r({clientId:i.clientId})):(b(i.message),v(null));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),b(i.message),g(null),v(null))}catch(t){e||(n!==void 0&&window.clearInterval(n),b(t instanceof Error?t.message:`Request failed`),g(null),v(null))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[f,t,r]),(0,X.useEffect)(()=>{if(!_){S(null),w(!1);return}let e=!1;return w(!1),Z.toDataURL(_,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||S(t)}).catch(()=>{e||(w(!0),S(null))}),()=>{e=!0}},[_]);let O=!!(_&&f),k=e&&!y&&!O;return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.dingtalkQrCloseAria,children:(0,I.jsx)(m,{className:`size-4`})})}),(0,I.jsx)(i,{className:`sr-only`,children:n.dingtalkQrModalTitle}),(0,I.jsx)(c,{className:`sr-only`,children:n.dingtalkQrModalSubtitle}),(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.dingtalkQrModalTitle}),(0,I.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.dingtalkQrModalSubtitle})]}),(0,I.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[y?(0,I.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:y}):null,!y&&(O||k)?(0,I.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg-muted`,children:k?n.dingtalkQrStarting:n.dingtalkQrScanHint}),(0,I.jsxs)(`div`,{className:d(`relative flex h-52 w-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,k&&`bg-surface-muted/40 dark:bg-surface-base`),children:[k?(0,I.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,O&&_&&!y&&x&&!C?(0,I.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,O&&_&&!y&&!x&&!C&&!k?(0,I.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.dingtalkQrEncoding}):null,O&&_&&!y&&C?(0,I.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,I.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.dingtalkQrImageError}),(0,I.jsxs)(`a`,{href:_,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,I.jsx)(u,{className:`size-3 shrink-0`}),n.dingtalkQrOpenLink]})]}):null]})]}):null]}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:s,onClick:()=>void T(),children:s?n.dingtalkQrStarting:n.dingtalkQrRegenerate})}),a?(0,I.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:a}):null]})]})})}function ke({ch:e,form:t,baseline:n,showFeishuSecret:r,setShowFeishuSecret:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuCopied:s,feishuWebhookCopied:c,copyFeishuSecret:u,copyFeishuWebhookConfig:f,updateFeishu:p,updateChannelAgentRoute:m,feishuAccountsDraft:h,setFeishuAccountsDraft:g,feishuAccountsError:y,onFeishuAccountsBlur:b,dmOpts:x,groupOpts:S,chatAgents:w,saving:T,dirty:D,save:O,discard:k}){let A=V,j=t.feishu,ee=n?.feishu?.appSecret??``,N=!r&&!!String(ee).trim()&&j.appSecret===ee;return(0,I.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,I.jsx)(M,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.feishuAdvancedHint}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:j.enabled,onChange:e=>p({enabled:e.target.checked})}),(0,I.jsx)(`span`,{children:e.enableFeishuAria})]}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[e.feishuAppId,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.appId,onChange:e=>p({appId:e.target.value}),placeholder:`cli_xxx`}),(0,I.jsx)(q,{children:e.feishuAppIdDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[e.feishuAppSecret,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:r?`text`:`password`,autoComplete:`off`,readOnly:N,value:N?`*`.repeat(Math.max(1,j.appSecret.length)):j.appSecret,onChange:e=>{N||p({appSecret:e.target.value})},placeholder:`••••••••`}),j.appSecret?(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void u(),children:[s?(0,I.jsx)(C,{className:`size-3.5`}):(0,I.jsx)(v,{className:`size-3.5`}),s?e.copied:e.copy]}):null,(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>i(e=>!e),children:[r?(0,I.jsx)(l,{className:`size-3.5`}):(0,I.jsx)(_,{className:`size-3.5`}),r?e.hide:e.show]})]}),(0,I.jsx)(q,{children:e.feishuAppSecretDesc})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.feishuDomain}),(0,I.jsxs)(`select`,{className:A(),value:String(j.domain||`feishu`),onChange:e=>p({domain:e.target.value}),children:[(0,I.jsx)(`option`,{value:`feishu`,children:`feishu`}),(0,I.jsx)(`option`,{value:`lark`,children:`lark`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.connectionMode}),(0,I.jsxs)(`select`,{className:A(),value:j.connectionMode,onChange:e=>p({connectionMode:e.target.value}),children:[(0,I.jsx)(`option`,{value:`websocket`,children:`websocket`}),(0,I.jsx)(`option`,{value:`webhook`,children:`webhook`})]}),(0,I.jsx)(q,{children:e.connectionModeDesc})]})]}),j.connectionMode===`webhook`?(0,I.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.webhookTitle}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>o(e=>!e),children:[a?(0,I.jsx)(l,{className:`size-3.5`}):(0,I.jsx)(_,{className:`size-3.5`}),a?e.hide:e.show]}),(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void f(),children:[c?(0,I.jsx)(C,{className:`size-3.5`}):(0,I.jsx)(v,{className:`size-3.5`}),c?e.copied:e.copy]})]})]}),(0,I.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.verificationToken}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:j.verificationToken??``,onChange:e=>p({verificationToken:e.target.value})}),(0,I.jsx)(q,{children:e.verificationTokenDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.encryptKey}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:j.encryptKey??``,onChange:e=>p({encryptKey:e.target.value})}),(0,I.jsx)(q,{children:e.encryptKeyDesc})]})]}),(0,I.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,I.jsx)(K,{children:e.webhookHost}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.webhookHost??``,onChange:e=>p({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.webhookPort}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(j.webhookPort??``),onChange:e=>p({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,I.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.webhookPath}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.webhookPath??``,onChange:e=>p({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,I.jsx)(q,{children:e.webhookPathDesc})]})]}):null,(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.renderMode}),(0,I.jsxs)(`select`,{className:A(),value:j.renderMode,onChange:e=>p({renderMode:e.target.value}),children:[(0,I.jsx)(`option`,{value:`auto`,children:`auto`}),(0,I.jsx)(`option`,{value:`raw`,children:`raw`}),(0,I.jsx)(`option`,{value:`card`,children:`card`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.reactionNotifications}),(0,I.jsxs)(`select`,{className:A(),value:j.reactionNotifications,onChange:e=>p({reactionNotifications:e.target.value}),children:[(0,I.jsx)(`option`,{value:`off`,children:`off`}),(0,I.jsx)(`option`,{value:`own`,children:`own`}),(0,I.jsx)(`option`,{value:`all`,children:`all`})]})]})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:j.streaming,onChange:e=>p({streaming:e.target.checked})}),e.enableStreaming]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.dmPolicy}),(0,I.jsx)(`select`,{className:A(),value:j.dmPolicy,onChange:e=>p({dmPolicy:e.target.value}),children:x.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.groupPolicy}),(0,I.jsx)(`select`,{className:A(),value:j.groupPolicy,onChange:e=>p({groupPolicy:e.target.value}),children:S.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:j.requireMention,onChange:e=>p({requireMention:e.target.checked})}),e.requireMention]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.allowFromDm}),(0,I.jsx)(`textarea`,{className:d(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`ou_xxx, on_xxx`,value:W(j.allowFrom),onChange:e=>p({allowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:e.allowFromDmDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.allowFromGroups}),(0,I.jsx)(`textarea`,{className:d(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`oc_xxx, oc_yyy`,value:W(j.groupAllowFrom),onChange:e=>p({groupAllowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:e.allowFromGroupsDesc})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.historyLimit}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(j.historyLimit),onChange:e=>p({historyLimit:Number(e.target.value||`0`)||0})})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.textChunkLimit}),(0,I.jsx)(`input`,{className:d(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(j.textChunkLimit),onChange:e=>p({textChunkLimit:Number(e.target.value||`0`)||0})})]})]}),(0,I.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feishuToolsTitle}),(0,I.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[`doc`,e.feishuToolDoc],[`wiki`,e.feishuToolWiki],[`drive`,e.feishuToolDrive],[`perm`,e.feishuToolPerm],[`bitable`,e.feishuToolBitable],[`scopes`,e.feishuToolScopes]].map(([e,t])=>(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!j.tools?.[e],onChange:t=>p({tools:{...j.tools,[e]:t.target.checked}})}),t]},e))}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(q,{children:e.feishuToolsDesc})})]}),(0,I.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feishuActionsTitle}),(0,I.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!j.actions?.reactions,onChange:e=>p({actions:{...j.actions,reactions:e.target.checked}})}),e.feishuActionReactions]})]}),(0,I.jsx)(Y,{accountIds:fe(j),routes:t.channelAgentRoutes.feishu,defaultAgentId:t.defaultAgentId,agentItems:w?.items??[],disabled:T,onChange:(e,t)=>m(`feishu`,e,t),ch:e}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:e.multiAccountJson}),(0,I.jsx)(`textarea`,{className:d(A(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:h,onChange:e=>g(e.target.value),onBlur:b,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),y?(0,I.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:y}):(0,I.jsx)(q,{children:e.multiAccountJsonDesc})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!D||T,onClick:k,children:e.discard}),(0,I.jsx)(E,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!D||T,onClick:async()=>{await O()},children:T?e.saving:e.save})]})]})]})}function Ae({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:a}){let[s,l]=(0,X.useState)(!1),[f,g]=(0,X.useState)(`feishu`),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),[T,O]=(0,X.useState)(!1),k=(0,X.useCallback)(async e=>{g(e),S(null),v(null),b(null),l(!0);try{let t=await Te({domain:e});b(t.qrUrl),v(t.sessionKey)}catch(e){S(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,X.useEffect)(()=>{if(!e){v(null),b(null),S(null),w(null),O(!1),g(`feishu`),l(!1);return}k(`feishu`)},[e,k]),(0,X.useEffect)(()=>{if(!_)return;let e=!1,n,i=async()=>{try{let i=await Ee(_);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),v(null),i.ok?(b(null),t(!1),r({appId:i.appId,domain:i.domain,openId:i.openId})):(S(i.message),b(null));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),S(i.message),v(null),b(null))}catch(t){e||(n!==void 0&&window.clearInterval(n),S(t instanceof Error?t.message:`Request failed`),v(null),b(null))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[_,t,r]),(0,X.useEffect)(()=>{if(!y){w(null),O(!1);return}let e=!1;return O(!1),Z.toDataURL(y,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||w(t)}).catch(()=>{e||(O(!0),w(null))}),()=>{e=!0}},[y]);let A=!!(y&&_),j=e,M=e&&!x&&!A;return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.feishuQrCloseAria,children:(0,I.jsx)(m,{className:`size-4`})})}),(0,I.jsx)(i,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,I.jsx)(c,{className:`sr-only`,children:n.feishuQrModalSubtitle}),(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.feishuQrModalTitle}),(0,I.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.feishuQrModalSubtitle})]}),(0,I.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[x?(0,I.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:x}):null,!x&&(A||M)?(0,I.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg-muted`,children:M?n.feishuQrStarting:n.feishuQrScanHint}),(0,I.jsxs)(`div`,{className:d(`relative flex h-52 w-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,M&&`bg-surface-muted/40 dark:bg-surface-base`),children:[M?(0,I.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,A&&y&&!x&&C&&!T?(0,I.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,A&&y&&!x&&!C&&!T&&!M?(0,I.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,A&&y&&!x&&T?(0,I.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,I.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.feishuQrImageError}),(0,I.jsxs)(`a`,{href:y,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,I.jsx)(u,{className:`size-3 shrink-0`}),n.feishuQrOpenLink]})]}):null]})]}):null]}),j?(0,I.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[20rem] justify-center px-1`,role:`group`,"aria-label":n.feishuRegionSwitchAria,children:(0,I.jsxs)(`div`,{className:`inline-flex w-full rounded-full border border-edge bg-surface-muted/60 p-1 dark:border-edge dark:bg-surface-base`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:s,className:d(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,f===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void k(`feishu`),children:n.feishuRegionChina}),(0,I.jsx)(`button`,{type:`button`,disabled:s,className:d(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,f===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void k(`lark`),children:n.feishuRegionInternational})]})}):null,(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:s,onClick:()=>void k(f),children:s?n.feishuQrStarting:n.feishuQrRegenerate})}),a?(0,I.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:a}):null]})]})})}function je({tg:e,updateTelegram:t,ch:n,dmOpts:r,groupOpts:i,replyOpts:a,streamOpts:o,tgAccountsDraft:s,setTgAccountsDraft:c,tgAccountsError:l,onTgAccountsBlur:u}){let f=V;return(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.apiRoot}),(0,I.jsx)(`input`,{className:f(),value:e.apiRoot,onChange:e=>t({apiRoot:e.target.value}),placeholder:`https://api.telegram.org`})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.proxy}),(0,I.jsx)(`input`,{className:f(),value:e.proxy,onChange:e=>t({proxy:e.target.value}),placeholder:`http://proxy.example.com:8080`})]}),(0,I.jsx)(J,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,I.jsx)(J,{label:n.groupPolicy,value:e.groupPolicy,onChange:e=>t({groupPolicy:e}),options:i}),(0,I.jsx)(J,{label:n.replyToMode,value:e.replyToMode,onChange:e=>t({replyToMode:e}),options:a}),(0,I.jsx)(J,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:o}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.allowFromGroups}),(0,I.jsx)(`textarea`,{className:d(f(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`-1001234567890`,value:W(e.groupAllowFrom),onChange:e=>t({groupAllowFrom:U(e.target.value)})})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.historyLimit}),(0,I.jsx)(`input`,{type:`number`,min:10,max:200,className:f(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.textChunkLimit}),(0,I.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:f(),value:e.textChunkLimit,onChange:e=>t({textChunkLimit:parseInt(e.target.value,10)||4e3})})]})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.telegramDebug]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.multiAccountJson}),(0,I.jsx)(`textarea`,{className:d(f(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:s,onChange:e=>c(e.target.value),onBlur:u,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),l?(0,I.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):(0,I.jsx)(q,{children:n.multiAccountJsonDesc})]})]})}function Me({open:e,onOpenChange:t,ch:n,form:r,baseline:a,tgAdvanced:s,setTgAdvanced:u,showToken:f,setShowToken:g,copied:y,copyToken:b,updateTelegram:x,updateChannelAgentRoute:S,tgAccountsDraft:w,setTgAccountsDraft:T,tgAccountsError:O,onTgAccountsBlur:k,dmOpts:A,groupOpts:j,replyOpts:ee,streamOpts:N,chatAgents:te,saving:P,dirty:re,save:ie,discard:ae}){let oe=V,F=r.telegram,se=a?he(a.telegram):``,ce=he(F),L=!f&&!!String(se).trim()&&ce===se;return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(i,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.telegramTitle}),(0,I.jsx)(c,{className:`mt-1 text-sm text-fg-muted`,children:n.telegramSubtitle})]}),(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.modalCancel,children:(0,I.jsx)(m,{className:`size-4`})})})]}),(0,I.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:F.enabled,onChange:e=>x({enabled:e.target.checked})}),(0,I.jsx)(`span`,{children:n.enableTelegramAria})]}),(0,I.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(K,{children:[n.telegramToken,(0,I.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(`input`,{className:d(oe(),`min-w-0 flex-1 font-mono text-xs`),type:f?`text`:`password`,autoComplete:`off`,readOnly:L,value:L?`*`.repeat(Math.max(1,se.length)):ce,onChange:e=>{if(L)return;let t=F.accounts?.default??be(`default`);x({accounts:{...F.accounts,default:{...t,accountId:`default`,botToken:e.target.value}}})},placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`}),ce?(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void b(),children:[y?(0,I.jsx)(C,{className:`size-3.5`}):(0,I.jsx)(v,{className:`size-3.5`}),y?n.copied:n.copy]}):null,(0,I.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>g(e=>!e),children:[f?(0,I.jsx)(l,{className:`size-3.5`}):(0,I.jsx)(_,{className:`size-3.5`}),f?n.hide:n.show]})]}),(0,I.jsx)(q,{children:n.telegramTokenDesc})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.allowFromDm}),(0,I.jsx)(`textarea`,{className:d(oe(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`123456789, 987654321`,value:W(F.allowFrom),onChange:e=>x({allowFrom:U(e.target.value)})}),(0,I.jsx)(q,{children:n.allowFromDmDesc})]}),(0,I.jsx)(Y,{accountIds:ue(F),routes:r.channelAgentRoutes.telegram,defaultAgentId:r.defaultAgentId,agentItems:te?.items??[],disabled:P,onChange:(e,t)=>S(`telegram`,e,t),ch:n}),(0,I.jsxs)(E,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:()=>u(e=>!e),children:[(0,I.jsx)(M,{className:d(`mr-1 size-4 transition-transform`,s&&`rotate-180`)}),s?n.advancedHide:n.advancedShow]}),s?(0,I.jsx)(je,{tg:F,updateTelegram:x,ch:n,dmOpts:A,groupOpts:j,replyOpts:ee,streamOpts:N,tgAccountsDraft:w,setTgAccountsDraft:T,tgAccountsError:O,onTgAccountsBlur:k}):null]}),(0,I.jsxs)(`div`,{className:`mt-8 flex flex-wrap justify-end gap-2 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>t(!1),children:n.modalCancel}),(0,I.jsx)(E,{type:`button`,variant:`secondary`,disabled:!re||P,onClick:ae,children:n.discard}),(0,I.jsx)(E,{type:`button`,variant:`primary`,disabled:!re||P,onClick:async()=>{await ie()&&t(!1)},children:P?n.saving:n.save})]})]})]})})}function Ne(){let e=b(e=>e.language),t=f(e),n=t.channelsSettings,i=!!T(e=>e.token),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[v,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(!1),[w,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),[ee,N]=(0,X.useState)(null),[te,ne]=(0,X.useState)(!1),[P,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!1),[F,se]=(0,X.useState)(!1),[ce,I]=(0,X.useState)(!1),[L,le]=(0,X.useState)(!1),[R,z]=(0,X.useState)(!1),[ue,de]=(0,X.useState)(!1),[fe,pe]=(0,X.useState)(!1),[me,B]=(0,X.useState)(``),[V,H]=(0,X.useState)(``),[U,W]=(0,X.useState)(``),[ge,G]=(0,X.useState)(``),[_e,ve]=(0,X.useState)(``),[K,q]=(0,X.useState)(``),[J,Y]=(0,X.useState)(``),[ye,Z]=(0,X.useState)(``),{data:be}=r(i?`gateway-chat-agents-ch`:null,y,{revalidateOnFocus:!1}),{data:Q,error:Ce,isLoading:Te,mutate:Ee}=re(i),$=(0,X.useMemo)(()=>Q?.payload?.config===void 0?null:Se(Q.payload.config),[Q]),De=(0,X.useMemo)(()=>!a||!s?!1:JSON.stringify(a)!==JSON.stringify(s),[a,s]);(0,X.useEffect)(()=>{if(!i){o(null),c(null);return}$!==null&&(De||(o($),c(structuredClone($)),B(JSON.stringify($.telegram.accounts??{},null,2)),H(``),W(JSON.stringify($.weixin.accounts??{},null,2)),G(``),ve(JSON.stringify($.feishu?.accounts??{},null,2)),q(``),Y(JSON.stringify($.dingtalk?.accounts??{},null,2)),Z(``),h(!1)))},[i,$,De]);let Oe=!!(i&&Te&&Q===void 0&&!Ce),ke=Ce instanceof Error?Ce.message:Ce?String(Ce):null,Ae=(0,X.useCallback)((e,t,n)=>{o(r=>{if(!r)return null;let i=e===`telegram`?`telegram`:e===`weixin`?`weixin`:e===`feishu`?`feishu`:`dingtalk`;return{...r,channelAgentRoutes:{...r.channelAgentRoutes,[i]:{...r.channelAgentRoutes[i],[t]:n.trim().toLowerCase()}}}})},[]),je=(0,X.useCallback)(e=>{o(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),Me=(0,X.useCallback)(e=>{o(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),Ne=(0,X.useCallback)(e=>{o(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]),Pe=(0,X.useCallback)(e=>{o(t=>t?{...t,dingtalk:{...t.dingtalk,...e}}:null)},[]),Fe=(0,X.useCallback)(async()=>{if(!a||l)return!1;u(!0),p(null),h(!1);try{let e=await we(a);o(e);let t=structuredClone(e);return c(t),B(JSON.stringify(t.telegram.accounts??{},null,2)),H(``),W(JSON.stringify(t.weixin.accounts??{},null,2)),G(``),ve(JSON.stringify(t.feishu?.accounts??{},null,2)),q(``),Y(JSON.stringify(t.dingtalk?.accounts??{},null,2)),Z(``),h(!0),window.setTimeout(()=>h(!1),2500),!0}catch(e){return p(e instanceof Error?e.message:n.saveError),!1}finally{u(!1)}},[a,l,n.saveError]),Ie=(0,X.useCallback)(()=>{if(!s)return;let e=structuredClone(s);o(e),B(JSON.stringify(e.telegram.accounts??{},null,2)),H(``),W(JSON.stringify(e.weixin.accounts??{},null,2)),G(``),ve(JSON.stringify(e.feishu?.accounts??{},null,2)),q(``),Y(JSON.stringify(e.dingtalk?.accounts??{},null,2)),Z(``),p(null),h(!1)},[s]),Le=(0,X.useCallback)(async(e,t)=>{if(!a||l)return;let r=a,i=e===`weixin`?{...a,weixin:{...a.weixin,enabled:t}}:e===`telegram`?{...a,telegram:{...a.telegram,enabled:t}}:e===`feishu`?{...a,feishu:{...a.feishu,enabled:t}}:{...a,dingtalk:{...a.dingtalk,enabled:t}};o(i),u(!0),p(null);try{let e=await we(i);o(e);let t=structuredClone(e);c(t),B(JSON.stringify(t.telegram.accounts??{},null,2)),W(JSON.stringify(t.weixin.accounts??{},null,2)),ve(JSON.stringify(t.feishu?.accounts??{},null,2)),Y(JSON.stringify(t.dingtalk?.accounts??{},null,2))}catch(e){p(e instanceof Error?e.message:n.saveError),o(r)}finally{u(!1)}},[a,l,n.saveError]),Re=(0,X.useCallback)(async()=>{if(!a||!D||l)return;let e=xe(),t=D===`weixin`?{...a,weixin:e.weixin}:D===`telegram`?{...a,telegram:e.telegram}:D===`feishu`?{...a,feishu:e.feishu}:{...a,dingtalk:e.dingtalk};u(!0),p(null);try{let e=await we(t);o(e);let n=structuredClone(e);c(n),B(JSON.stringify(n.telegram.accounts??{},null,2)),W(JSON.stringify(n.weixin.accounts??{},null,2)),H(``),G(``),ve(JSON.stringify(n.feishu?.accounts??{},null,2)),q(``),Y(JSON.stringify(n.dingtalk?.accounts??{},null,2)),Z(``),O(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:n.saveError)}finally{u(!1)}},[a,D,l,n.saveError]),ze=(0,X.useCallback)(async()=>{let e=a?he(a.telegram):``;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),le(!0),window.setTimeout(()=>le(!1),2e3))},[a]),Be=(0,X.useCallback)(e=>{Ne({appId:e.appId,domain:e.domain,enabled:!0}),Ee(),M(n.feishuQrSetupSuccess),window.setTimeout(()=>M(null),4e3)},[Ne,Ee,n.feishuQrSetupSuccess]),Ve=(0,X.useCallback)(e=>{Pe({clientId:e.clientId,enabled:!0}),Ee(),N(n.dingtalkQrSetupSuccess),window.setTimeout(()=>N(null),4e3)},[Pe,Ee,n.dingtalkQrSetupSuccess]),He=(0,X.useCallback)(async()=>{let e=a?.dingtalk?.clientSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),de(!0),window.setTimeout(()=>de(!1),2e3))},[a]);return{language:e,m:t,ch:n,hasToken:i,loading:Oe,fetchError:ke,mutate:Ee,form:a,baseline:s,dirty:De,saving:l,error:d,saveOk:m,weixinModalOpen:g,setWeixinModalOpen:_,telegramModalOpen:v,setTelegramModalOpen:x,feishuModalOpen:S,setFeishuModalOpen:C,dingtalkModalOpen:w,setDingtalkModalOpen:E,removeTarget:D,setRemoveTarget:O,weixinSuccessBanner:k,setWeixinSuccessBanner:A,feishuSetupSuccessBanner:j,dingtalkSetupSuccessBanner:ee,tgAdvanced:te,setTgAdvanced:ne,showToken:P,setShowToken:ie,showFeishuSecret:ae,setShowFeishuSecret:oe,showFeishuWebhookSecrets:F,setShowFeishuWebhookSecrets:se,showDingtalkSecret:ce,setShowDingtalkSecret:I,copied:L,feishuCopied:R,dingtalkCopied:ue,feishuWebhookCopied:fe,tgAccountsDraft:me,setTgAccountsDraft:B,tgAccountsError:V,wxAccountsDraft:U,setWxAccountsDraft:W,wxAccountsError:ge,feishuAccountsDraft:_e,setFeishuAccountsDraft:ve,feishuAccountsError:K,dingtalkAccountsDraft:J,setDingtalkAccountsDraft:Y,dingtalkAccountsError:ye,chatAgents:be,updateChannelAgentRoute:Ae,updateTelegram:je,updateWeixin:Me,updateFeishu:Ne,updateDingtalk:Pe,save:Fe,discard:Ie,toggleChannelEnabled:Le,removeChannel:Re,copyToken:ze,handleFeishuQrSetupSuccess:Be,handleDingtalkQrSetupSuccess:Ve,copyFeishuSecret:(0,X.useCallback)(async()=>{let e=a?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),z(!0),window.setTimeout(()=>z(!1),2e3))},[a]),copyDingtalkSecret:He,copyFeishuWebhookConfig:(0,X.useCallback)(async()=>{let e=a?.feishu;if(!e)return;let t={connectionMode:e.connectionMode,verificationToken:e.verificationToken||``,encryptKey:e.encryptKey||``,webhookHost:e.webhookHost||``,webhookPort:e.webhookPort||0,webhookPath:e.webhookPath||``};await navigator.clipboard.writeText(JSON.stringify(t,null,2)).catch(()=>{}),pe(!0),window.setTimeout(()=>pe(!1),2e3)},[a]),onTgAccountsBlur:(0,X.useCallback)(()=>{if(!a)return;let e=me.trim();if(!e){je({accounts:{}}),H(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);je({accounts:t}),H(``)}catch(e){H(e instanceof Error?e.message:n.jsonInvalid)}},[a,me,je,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,X.useCallback)(()=>{if(!a)return;let e=U.trim();if(!e){Me({accounts:{}}),G(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);Me({accounts:t}),G(``)}catch(e){G(e instanceof Error?e.message:n.jsonInvalid)}},[a,U,Me,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,X.useCallback)(()=>{if(!a)return;let e=_e.trim();if(!e){Ne({accounts:{}}),q(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);Ne({accounts:t}),q(``)}catch(e){q(e instanceof Error?e.message:n.jsonInvalid)}},[a,_e,Ne,n.jsonObjectAccounts,n.jsonInvalid]),onDingtalkAccountsBlur:(0,X.useCallback)(()=>{if(!a)return;let e=J.trim();if(!e){Pe({accounts:{}}),Z(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);Pe({accounts:t}),Z(``)}catch(e){Z(e instanceof Error?e.message:n.jsonInvalid)}},[a,J,Pe,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,X.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,X.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,X.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,X.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}function Pe({open:e,onOpenChange:t,ch:n,onLoginSuccess:r,moreSettings:a}){let[s,l]=(0,X.useState)(!1),[f,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),[T,O]=(0,X.useState)(!1),k=(0,X.useCallback)(async()=>{b(null),S(null),g(null),l(!0);try{let e=await Q();v(e.qrcodeUrl),g(e.sessionKey)}catch(e){b(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,X.useEffect)(()=>{if(!e){g(null),v(null),b(null),w(null),O(!1),S(null);return}k()},[e,k]),(0,X.useEffect)(()=>{if(!f)return;let e=!1,i,a=async()=>{try{let a=await Ce(f);if(e)return;if(a.phase===`polling`){v(a.qrcodeUrl),a.qrStatus===`scaned`?S(n.weixinQrLoginScanned):S(null);return}if(a.phase===`done`){i!==void 0&&(window.clearInterval(i),i=void 0),g(null),a.ok?(v(null),t(!1),await r()):(b(a.message),v(null));return}a.phase===`unknown`&&S(null)}catch(t){e||(i!==void 0&&window.clearInterval(i),b(t instanceof Error?t.message:`Request failed`),g(null),v(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[f,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,X.useEffect)(()=>{if(!_){w(null),O(!1);return}let e=!1;return O(!1),Z.toDataURL(_,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||w(t)}).catch(()=>{e||(O(!0),w(null))}),()=>{e=!0}},[_]);let A=!!(_&&f),j=e&&!y&&!A;return(0,I.jsx)(D,{open:e,onOpenChange:t,children:(0,I.jsxs)(p,{children:[(0,I.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,I.jsxs)(h,{className:d(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsx)(ne,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.weixinQrModalCloseAria,children:(0,I.jsx)(m,{className:`size-4`})})}),(0,I.jsx)(i,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,I.jsx)(c,{className:`sr-only`,children:n.weixinQrModalSubtitle}),(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.weixinQrModalTitle}),(0,I.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.weixinQrModalSubtitle})]}),(0,I.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[y?(0,I.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:y}):null,!y&&(A||j)?(0,I.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,I.jsx)(`p`,{className:d(`min-h-[1.25rem] text-center text-sm`,x&&!j?`text-accent`:`text-fg-muted`),children:j?n.weixinQrLoginBusy:x??`\xA0`}),(0,I.jsxs)(`div`,{className:d(`relative flex h-52 w-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,j&&`bg-surface-muted/40 dark:bg-surface-base`),children:[j?(0,I.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,A&&_&&!y&&C&&!T?(0,I.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,A&&_&&!y&&!C&&!T&&!j?(0,I.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,A&&_&&!y&&T?(0,I.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,I.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.weixinQrImageError}),(0,I.jsxs)(`a`,{href:_,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,I.jsx)(u,{className:`size-3 shrink-0`}),n.weixinQrOpenLink]})]}):null]})]}):null]}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:s,onClick:()=>void k(),children:s?n.weixinQrLoginBusy:n.weixinQrRegenerate})}),a?(0,I.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:a}):null]})]})})}function Fe({wx:e,updateWeixin:t,ch:n,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,channelAgentRoutesWx:l,defaultAgentId:u,agentItems:f,onAgentRouteChange:p,routingDisabled:m}){let h=V;return(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.weixinAllowFrom}),(0,I.jsx)(`textarea`,{className:d(h(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`wxid_..., openid_...`,value:e.allowFrom.join(`, `),onChange:e=>t({allowFrom:e.target.value.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)})}),(0,I.jsx)(q,{children:n.weixinAllowFromDesc})]}),(0,I.jsx)(J,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,I.jsx)(J,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:i}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.historyLimit}),(0,I.jsx)(`input`,{type:`number`,min:10,max:200,className:h(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.textChunkLimit}),(0,I.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:h(),value:e.textChunkLimit,onChange:e=>t({textChunkLimit:parseInt(e.target.value,10)||4e3})})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.weixinRouteTag}),(0,I.jsx)(`input`,{className:h(),value:e.routeTag,onChange:e=>t({routeTag:e.target.value}),placeholder:n.routeTagPlaceholder}),(0,I.jsx)(q,{children:n.weixinRouteTagDesc})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.weixinDebug]}),(0,I.jsx)(q,{children:n.weixinDebugDesc}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(K,{children:n.weixinAccountsJson}),(0,I.jsx)(`textarea`,{className:d(h(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:a,onChange:e=>o(e.target.value),onBlur:c,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),s?(0,I.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:s}):(0,I.jsx)(q,{children:n.weixinAccountsJsonDesc})]}),(0,I.jsx)(Y,{accountIds:de(e),routes:l,defaultAgentId:u,agentItems:f,disabled:m,onChange:p,ch:n})]})}function Ie({ch:e,wx:t,updateWeixin:n,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,form:l,chatAgents:u,onAgentRouteChange:d,saving:f,dirty:p,save:m,discard:h}){return(0,I.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,I.jsx)(M,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,I.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.weixinAdvancedHint}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:t.enabled,onChange:e=>n({enabled:e.target.checked})}),(0,I.jsx)(`span`,{children:e.enableWeixinAria})]}),(0,I.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,I.jsx)(Fe,{wx:t,updateWeixin:n,ch:e,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,channelAgentRoutesWx:l.channelAgentRoutes.weixin,defaultAgentId:l.defaultAgentId,agentItems:u?.items??[],onAgentRouteChange:d,routingDisabled:f})}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,I.jsx)(E,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!p||f,onClick:h,children:e.discard}),(0,I.jsx)(E,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!p||f,onClick:async()=>{await m()},children:f?e.saving:e.save})]})]})]})}function Le(){let{language:e,m:t,ch:n,hasToken:r,loading:i,fetchError:a,mutate:o,form:s,baseline:c,dirty:l,saving:d,error:f,saveOk:p,weixinModalOpen:m,setWeixinModalOpen:h,telegramModalOpen:g,setTelegramModalOpen:_,feishuModalOpen:v,setFeishuModalOpen:y,removeTarget:b,setRemoveTarget:S,weixinSuccessBanner:C,setWeixinSuccessBanner:T,dingtalkModalOpen:D,setDingtalkModalOpen:O,feishuSetupSuccessBanner:k,dingtalkSetupSuccessBanner:A,tgAdvanced:M,setTgAdvanced:N,showToken:te,setShowToken:ne,showFeishuSecret:P,setShowFeishuSecret:re,showFeishuWebhookSecrets:ie,setShowFeishuWebhookSecrets:ae,showDingtalkSecret:oe,setShowDingtalkSecret:F,copied:se,feishuCopied:ce,dingtalkCopied:R,feishuWebhookCopied:z,tgAccountsDraft:ue,setTgAccountsDraft:de,tgAccountsError:fe,wxAccountsDraft:pe,setWxAccountsDraft:me,wxAccountsError:B,feishuAccountsDraft:V,setFeishuAccountsDraft:H,feishuAccountsError:U,dingtalkAccountsDraft:W,setDingtalkAccountsDraft:he,dingtalkAccountsError:K,chatAgents:q,updateChannelAgentRoute:J,updateTelegram:Y,updateWeixin:X,updateFeishu:Z,updateDingtalk:be,save:xe,discard:Se,toggleChannelEnabled:Q,removeChannel:Ce,copyToken:we,handleFeishuQrSetupSuccess:Te,handleDingtalkQrSetupSuccess:Ee,copyFeishuSecret:$,copyDingtalkSecret:De,copyFeishuWebhookConfig:je,onTgAccountsBlur:Fe,onWxAccountsBlur:Le,onFeishuAccountsBlur:Re,onDingtalkAccountsBlur:ze,dmOpts:Be,groupOpts:Ve,replyOpts:He,streamOpts:Ue}=Ne();if(!r)return(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,I.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.channels}),(0,I.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]});if(i)return(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,I.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,I.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,I.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:n.loading})]});if(!s)return(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f??a??n.loadError}),(0,I.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>void o(),children:n.retry})]});let We=s.weixin,Ge=s.telegram,Ke=s.feishu,qe=s.dingtalk,Je=G(We),Ye=ge(Ge),Xe=_e(Ke),Ze=ve(qe),Qe=(0,I.jsx)(ke,{ch:n,form:s,baseline:c,showFeishuSecret:P,setShowFeishuSecret:re,showFeishuWebhookSecrets:ie,setShowFeishuWebhookSecrets:ae,feishuCopied:ce,feishuWebhookCopied:z,copyFeishuSecret:$,copyFeishuWebhookConfig:je,updateFeishu:Z,updateChannelAgentRoute:J,feishuAccountsDraft:V,setFeishuAccountsDraft:H,feishuAccountsError:U,onFeishuAccountsBlur:Re,dmOpts:Be,groupOpts:Ve,chatAgents:q,saving:d,dirty:l,save:xe,discard:Se}),$e=(0,I.jsx)(ye,{ch:n,form:s,baseline:c,showDingtalkSecret:oe,setShowDingtalkSecret:F,dingtalkCopied:R,copyDingtalkSecret:De,updateDingtalk:be,updateChannelAgentRoute:J,dingtalkAccountsDraft:W,setDingtalkAccountsDraft:he,dingtalkAccountsError:K,onDingtalkAccountsBlur:ze,dmOpts:Be,groupOpts:Ve,chatAgents:q,saving:d,dirty:l,save:xe,discard:Se}),et=(0,I.jsx)(Ie,{ch:n,wx:We,updateWeixin:X,dmOpts:Be,streamOpts:Ue,wxAccountsDraft:pe,setWxAccountsDraft:me,wxAccountsError:B,onWxAccountsBlur:Le,form:s,chatAgents:q,onAgentRouteChange:(e,t)=>J(`weixin`,e,t),saving:d,dirty:l,save:xe,discard:Se});return(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,I.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.channels}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,I.jsxs)(`a`,{href:w(e,`channels`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,I.jsx)(u,{className:`size-3.5`})]})]}),l?(0,I.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,p?(0,I.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.saved}):null,f?(0,I.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}):null,C?(0,I.jsx)(`p`,{className:`text-xs text-accent`,children:C}):null,k?(0,I.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:k}):null,A?(0,I.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:A}):null,(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsx)(L,{icon:(0,I.jsx)(ee,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.weixinTitle,subtitle:n.weixinSubtitle,configured:Je,enabled:We.enabled,toggleDisabled:d,onToggle:e=>void Q(`weixin`,e),onConfigure:()=>h(!0),onEdit:()=>h(!0),onRemove:()=>S(`weixin`),ch:n}),(0,I.jsx)(L,{icon:(0,I.jsx)(j,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.telegramTitle,subtitle:n.telegramSubtitle,configured:Ye,enabled:Ge.enabled,toggleDisabled:d,onToggle:e=>void Q(`telegram`,e),onConfigure:()=>_(!0),onEdit:()=>_(!0),onRemove:()=>S(`telegram`),ch:n}),(0,I.jsx)(L,{icon:(0,I.jsx)(ee,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.feishuTitle,subtitle:n.feishuSubtitle,configured:Xe,enabled:Ke.enabled,toggleDisabled:d,onToggle:e=>void Q(`feishu`,e),onConfigure:()=>y(!0),onEdit:()=>y(!0),onRemove:()=>S(`feishu`),ch:n}),(0,I.jsx)(L,{icon:(0,I.jsx)(x,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.dingtalkTitle,subtitle:n.dingtalkSubtitle,configured:Ze,enabled:qe.enabled,toggleDisabled:d,onToggle:e=>void Q(`dingtalk`,e),onConfigure:()=>O(!0),onEdit:()=>O(!0),onRemove:()=>S(`dingtalk`),ch:n})]}),(0,I.jsx)(Pe,{open:m,onOpenChange:h,ch:n,onLoginSuccess:async()=>{await o(),T(n.weixinQrLoginSuccess),window.setTimeout(()=>T(null),4e3)},moreSettings:et}),(0,I.jsx)(Me,{open:g,onOpenChange:_,ch:n,form:s,baseline:c,tgAdvanced:M,setTgAdvanced:N,showToken:te,setShowToken:ne,copied:se,copyToken:we,updateTelegram:Y,updateChannelAgentRoute:J,tgAccountsDraft:ue,setTgAccountsDraft:de,tgAccountsError:fe,onTgAccountsBlur:Fe,dmOpts:Be,groupOpts:Ve,replyOpts:He,streamOpts:Ue,chatAgents:q,saving:d,dirty:l,save:xe,discard:Se}),(0,I.jsx)(Ae,{open:v,onOpenChange:y,ch:n,onSetupSuccess:Te,moreSettings:Qe}),(0,I.jsx)(Oe,{open:D,onOpenChange:O,ch:n,onSetupSuccess:Ee,moreSettings:$e}),(0,I.jsx)(le,{open:b!==null,onOpenChange:e=>{e||S(null)},ch:n,removeTarget:b,onCancel:()=>S(null),saving:d,onConfirmRemove:()=>void Ce()})]})}export{Le as ChannelsSettingsPanel};
|
|
2
|
+
//# sourceMappingURL=channels-settings-CaxrdDzq.js.map
|