@xopcai/xopc 0.0.57 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/README.zh-CN.md +6 -0
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agents-DEL6G6-C.js → agents-BgeuYTaG.js} +2 -2
- package/dist/gateway/static/root/assets/{agents-DEL6G6-C.js.map → agents-BgeuYTaG.js.map} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DXlDJBf0.js → apps-page-DXOoxQ3t.js} +2 -2
- package/dist/gateway/static/root/assets/{apps-page-DXlDJBf0.js.map → apps-page-DXOoxQ3t.js.map} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-IWwRmmCH.js → channels-settings-BtblELP8.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-settings-IWwRmmCH.js.map → channels-settings-BtblELP8.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-dreaming-jobs-DIwTeQzu.js → cron-dreaming-jobs-D5kvbjSY.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-dreaming-jobs-DIwTeQzu.js.map → cron-dreaming-jobs-D5kvbjSY.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-CcRCqnzx.js → cron-page-4hk422N-.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-page-CcRCqnzx.js.map → cron-page-4hk422N-.js.map} +1 -1
- package/dist/gateway/static/root/assets/{dist-CgucsbDd.js → dist-CEmPWsYK.js} +2 -2
- package/dist/gateway/static/root/assets/{dist-CgucsbDd.js.map → dist-CEmPWsYK.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BX1pf7rr.js → extension-debug-page-z0vfOyIu.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-debug-page-BX1pf7rr.js.map → extension-debug-page-z0vfOyIu.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DPm5vzVN.js → extension-page-CFaT0yHk.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-page-DPm5vzVN.js.map → extension-page-CFaT0yHk.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DAly-C6g.js → extension-settings-page-7atlEJU0.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-settings-page-DAly-C6g.js.map → extension-settings-page-7atlEJU0.js.map} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-SijGy10-.js → heartbeat-config-api-DnmmSrTx.js} +2 -2
- package/dist/gateway/static/root/assets/{heartbeat-config-api-SijGy10-.js.map → heartbeat-config-api-DnmmSrTx.js.map} +1 -1
- package/dist/gateway/static/root/assets/{index-DHte7V8E.js → index-DvMI6Vqn.js} +4 -4
- package/dist/gateway/static/root/assets/{index-DHte7V8E.js.map → index-DvMI6Vqn.js.map} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DEnawdQ8.js → logs-page-XKXcjB3g.js} +2 -2
- package/dist/gateway/static/root/assets/{logs-page-DEnawdQ8.js.map → logs-page-XKXcjB3g.js.map} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-CGn5wKzh.js → sessions-page-1DyACBG7.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-CGn5wKzh.js.map → sessions-page-1DyACBG7.js.map} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BV20X-TN.js → settings-page-TrmEN1eQ.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-BV20X-TN.js.map → settings-page-TrmEN1eQ.js.map} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-C1Ns0BHu.js → skills-page-Dcvjtm-1.js} +2 -2
- package/dist/gateway/static/root/assets/{skills-page-C1Ns0BHu.js.map → skills-page-Dcvjtm-1.js.map} +1 -1
- package/dist/gateway/static/root/assets/{use-image-provider-credentials-BZqTDErY.js → use-image-provider-credentials-D6TXcMU2.js} +2 -2
- package/dist/gateway/static/root/assets/{use-image-provider-credentials-BZqTDErY.js.map → use-image-provider-credentials-D6TXcMU2.js.map} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/run-turn.js +6 -0
- package/dist/src/agent/embedded/run-turn.js.map +1 -1
- package/dist/src/agent/embedded/xopc-auth-storage.d.ts +20 -0
- package/dist/src/agent/embedded/xopc-auth-storage.js +38 -0
- package/dist/src/agent/embedded/xopc-auth-storage.js.map +1 -0
- package/dist/src/agent/embedded/xopc-stream-bridge.d.ts +11 -0
- package/dist/src/agent/embedded/xopc-stream-bridge.js +24 -0
- package/dist/src/agent/embedded/xopc-stream-bridge.js.map +1 -0
- package/package.json +1 -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{$r as i,An as a,At as o,Cn as s,Ct as c,Dn as l,Ln as u,Mn as d,Mt as f,Nt as p,Ot as m,Pt as h,Qr as g,St as _,T as v,Tr as y,Xr as b,Zr as x,_i as S,bt as C,c as w,dn as T,gi as E,gn as D,jn as O,jt as k,kn as A,kt as j,l as M,o as N,qn as P,ri as ee,sr as te,vn as ne,xr as re,yn as ie,zn as ae}from"./index-DHte7V8E.js";import{a as oe,i as se,n as ce,r as F,t as I}from"./dist-CgucsbDd.js";import{t as L}from"./browser-DNXWYwzc.js";var R=n();function z({icon:e,title:t,subtitle:n,configured:r,enabled:a,onToggle:o,toggleDisabled:s,onConfigure:c,onEdit:l,onRemove:f,ch:p}){return(0,R.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,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[(0,R.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:e}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),r?(0,R.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-xs font-medium text-success`,children:p.hubConnectedBadge}):null]}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n})]})]}),r?(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,R.jsxs)(se,{children:[(0,R.jsx)(oe,{asChild:!0,children:(0,R.jsx)(d,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.menuMoreAria,children:(0,R.jsx)(i,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,R.jsx)(F,{children:(0,R.jsxs)(I,{className:u(`min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,M),sideOffset:6,align:`end`,children:[(0,R.jsx)(ce,{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:()=>l(),children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(re,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),p.menuEditConfig]})}),(0,R.jsx)(ce,{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:()=>f(),children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(P,{className:`size-4 shrink-0`,strokeWidth:1.75}),p.menuRemoveConfig]})})]})})]}),(0,R.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":`${t} — ${p.enableChannelAria}`,disabled:s,className:u(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,a?`justify-end bg-accent`:`justify-start bg-surface-hover`,s&&`cursor-not-allowed opacity-50`),onClick:()=>void o(!a),children:(0,R.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,R.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,R.jsx)(d,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:c,children:p.hubConfigureButton})})]})}function B({open:e,onOpenChange:t,ch:n,removeTarget:r,onCancel:i,saving:a,onConfirmRemove:s}){return(0,R.jsx)(p,{open:e,onOpenChange:t,children:(0,R.jsxs)(f,{children:[(0,R.jsx)(k,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,R.jsxs)(j,{className:u(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,N,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsx)(h,{className:`text-base font-semibold text-fg`,children:n.removeChannelTitle}),(0,R.jsx)(o,{className:`mt-2 text-sm text-fg-muted`,children:r?n.removeChannelConfirm.replace(`{{name}}`,r===`weixin`?n.weixinTitle:r===`telegram`?n.telegramTitle:n.feishuTitle):`\xA0`}),(0,R.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,R.jsx)(d,{type:`button`,variant:`secondary`,onClick:i,children:n.modalCancel}),(0,R.jsx)(d,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:a,onClick:s,children:a?n.saving:n.removeChannelAction})]})]})]})})}function V(e){return(e??``).trim().toLowerCase()}function H(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 le(e){return Object.keys(e.accounts??{}).sort()}function U(e){return Object.keys(e.accounts??{}).sort()}function ue(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 W(e,t,n,r,i){let a={},o={},s={};for(let n of t)a[n]=(e.find(e=>V(e.match?.channel)===`telegram`&&V(e.match?.accountId)===V(n)&&H(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>V(e.match?.channel)===`weixin`&&V(e.match?.accountId)===V(t)&&H(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>V(e.match?.channel)===`feishu`&&V(e.match?.accountId)===V(t)&&H(e))?.agentId??i).trim().toLowerCase();return{telegram:a,weixin:o,feishu:s}}function de(e,t,n,r,i,a){let o=new Set(n.map(V)),s=new Set(r.map(V)),c=new Set(i.map(V)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!H(e))return!0;let t=V(e.match.channel),n=V(e.match.accountId);return!n||n===`*`?!0:!(t===`telegram`&&o.has(n)||t===`weixin`&&s.has(n)||t===`feishu`&&c.has(n))}),u=[];for(let e of n){let n=(t.telegram[e]??t.telegram[V(e)]??a).trim().toLowerCase();u.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[V(e)]??a).trim().toLowerCase();u.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[V(e)]??a).trim().toLowerCase();u.push({id:`ui:route:account:feishu:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`feishu`,accountId:e}})}return[...l,...u]}function G(){return u(`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 fe(){return u(A,l)}function K(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).map(e=>/^-?\d+$/.test(e)?Number(e):e)}function q(e){return e.map(String).join(`, `)}function pe(e){let t=e.accounts?.default?.botToken;return typeof t==`string`?t:``}function me(e){return Object.values(e.accounts??{}).some(e=>typeof e.botToken==`string`&&e.botToken.trim().length>0)}function he(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function J(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}function Y({children:e}){return(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e})}function X({children:e}){return(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:e})}function Z({label:e,value:t,onChange:n,options:r}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e}),(0,R.jsx)(`select`,{className:fe(),value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function ge({accountIds:e,routes:t,defaultAgentId:n,agentItems:r,disabled:i,onChange:a,ch:o}){let c=O(s(e=>e.language)).agentsSettings;if(e.length===0)return null;let d=r.length>0?r:[{id:n}];return(0,R.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Y,{children:o.agentRoutingTitle}),(0,R.jsx)(X,{children:o.agentRoutingHint})]}),(0,R.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,R.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,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:o.agentRoutingAccountLabel}),(0,R.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:e,children:e})]}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${e}`,children:o.agentRoutingAgentLabel}),(0,R.jsx)(`select`,{id:`agent-route-${e}`,className:u(G(),l),disabled:i,value:(t[e]??n).toLowerCase(),onChange:t=>a(e,t.target.value),children:d.map(e=>(0,R.jsx)(`option`,{value:e.id,children:`${v(e,c)} (${e.id})`},e.id))})]})]},e))})]})}function _e({ch:e,form:t,baseline:n,showFeishuSecret:r,setShowFeishuSecret:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuCopied:s,feishuWebhookCopied:c,copyFeishuSecret:l,copyFeishuWebhookConfig:f,updateFeishu:p,updateChannelAgentRoute:m,feishuAccountsDraft:h,setFeishuAccountsDraft:g,feishuAccountsError:_,onFeishuAccountsBlur:v,dmOpts:y,groupOpts:C,chatAgents:w,saving:T,dirty:D,save:O,discard:k}){let A=G,j=t.feishu,M=n?.feishu?.appSecret??``,N=!r&&!!String(M).trim()&&j.appSecret===M;return(0,R.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,R.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,R.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,R.jsx)(E,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,R.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.feishuAdvancedHint}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:j.enabled,onChange:e=>p({enabled:e.target.checked})}),(0,R.jsx)(`span`,{children:e.enableFeishuAria})]}),(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(Y,{children:[e.feishuAppId,(0,R.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,R.jsx)(`input`,{className:u(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.appId,onChange:e=>p({appId:e.target.value}),placeholder:`cli_xxx`}),(0,R.jsx)(X,{children:e.feishuAppIdDesc})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(Y,{children:[e.feishuAppSecret,(0,R.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(`input`,{className:u(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,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void l(),children:[s?(0,R.jsx)(S,{className:`size-3.5`}):(0,R.jsx)(ee,{className:`size-3.5`}),s?e.copied:e.copy]}):null,(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>i(e=>!e),children:[r?(0,R.jsx)(x,{className:`size-3.5`}):(0,R.jsx)(b,{className:`size-3.5`}),r?e.hide:e.show]})]}),(0,R.jsx)(X,{children:e.feishuAppSecretDesc})]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.feishuDomain}),(0,R.jsxs)(`select`,{className:A(),value:String(j.domain||`feishu`),onChange:e=>p({domain:e.target.value}),children:[(0,R.jsx)(`option`,{value:`feishu`,children:`feishu`}),(0,R.jsx)(`option`,{value:`lark`,children:`lark`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.connectionMode}),(0,R.jsxs)(`select`,{className:A(),value:j.connectionMode,onChange:e=>p({connectionMode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`websocket`,children:`websocket`}),(0,R.jsx)(`option`,{value:`webhook`,children:`webhook`})]}),(0,R.jsx)(X,{children:e.connectionModeDesc})]})]}),j.connectionMode===`webhook`?(0,R.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.webhookTitle}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>o(e=>!e),children:[a?(0,R.jsx)(x,{className:`size-3.5`}):(0,R.jsx)(b,{className:`size-3.5`}),a?e.hide:e.show]}),(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void f(),children:[c?(0,R.jsx)(S,{className:`size-3.5`}):(0,R.jsx)(ee,{className:`size-3.5`}),c?e.copied:e.copy]})]})]}),(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.verificationToken}),(0,R.jsx)(`input`,{className:u(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,R.jsx)(X,{children:e.verificationTokenDesc})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.encryptKey}),(0,R.jsx)(`input`,{className:u(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,R.jsx)(X,{children:e.encryptKeyDesc})]})]}),(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,R.jsx)(Y,{children:e.webhookHost}),(0,R.jsx)(`input`,{className:u(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,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.webhookPort}),(0,R.jsx)(`input`,{className:u(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,R.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.webhookPath}),(0,R.jsx)(`input`,{className:u(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.webhookPath??``,onChange:e=>p({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,R.jsx)(X,{children:e.webhookPathDesc})]})]}):null,(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.renderMode}),(0,R.jsxs)(`select`,{className:A(),value:j.renderMode,onChange:e=>p({renderMode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`auto`,children:`auto`}),(0,R.jsx)(`option`,{value:`raw`,children:`raw`}),(0,R.jsx)(`option`,{value:`card`,children:`card`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.reactionNotifications}),(0,R.jsxs)(`select`,{className:A(),value:j.reactionNotifications,onChange:e=>p({reactionNotifications:e.target.value}),children:[(0,R.jsx)(`option`,{value:`off`,children:`off`}),(0,R.jsx)(`option`,{value:`own`,children:`own`}),(0,R.jsx)(`option`,{value:`all`,children:`all`})]})]})]}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:j.streaming,onChange:e=>p({streaming:e.target.checked})}),e.enableStreaming]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.dmPolicy}),(0,R.jsx)(`select`,{className:A(),value:j.dmPolicy,onChange:e=>p({dmPolicy:e.target.value}),children:y.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.groupPolicy}),(0,R.jsx)(`select`,{className:A(),value:j.groupPolicy,onChange:e=>p({groupPolicy:e.target.value}),children:C.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:j.requireMention,onChange:e=>p({requireMention:e.target.checked})}),e.requireMention]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.allowFromDm}),(0,R.jsx)(`textarea`,{className:u(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`ou_xxx, on_xxx`,value:q(j.allowFrom),onChange:e=>p({allowFrom:K(e.target.value)})}),(0,R.jsx)(X,{children:e.allowFromDmDesc})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.allowFromGroups}),(0,R.jsx)(`textarea`,{className:u(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`oc_xxx, oc_yyy`,value:q(j.groupAllowFrom),onChange:e=>p({groupAllowFrom:K(e.target.value)})}),(0,R.jsx)(X,{children:e.allowFromGroupsDesc})]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.historyLimit}),(0,R.jsx)(`input`,{className:u(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,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.textChunkLimit}),(0,R.jsx)(`input`,{className:u(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,R.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feishuToolsTitle}),(0,R.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,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!j.tools?.[e],onChange:t=>p({tools:{...j.tools,[e]:t.target.checked}})}),t]},e))}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(X,{children:e.feishuToolsDesc})})]}),(0,R.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feishuActionsTitle}),(0,R.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!j.actions?.reactions,onChange:e=>p({actions:{...j.actions,reactions:e.target.checked}})}),e.feishuActionReactions]})]}),(0,R.jsx)(ge,{accountIds:ue(j),routes:t.channelAgentRoutes.feishu,defaultAgentId:t.defaultAgentId,agentItems:w?.items??[],disabled:T,onChange:(e,t)=>m(`feishu`,e,t),ch:e}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.multiAccountJson}),(0,R.jsx)(`textarea`,{className:u(A(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:h,onChange:e=>g(e.target.value),onBlur:v,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),_?(0,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:_}):(0,R.jsx)(X,{children:e.multiAccountJsonDesc})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,R.jsx)(d,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!D||T,onClick:k,children:e.discard}),(0,R.jsx)(d,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!D||T,onClick:async()=>{await O()},children:T?e.saving:e.save})]})]})]})}var Q=e(t(),1),ve=e(L(),1);function $(e){return{accountId:e,name:``,enabled:!0,botToken:``,allowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,apiRoot:``,proxy:``,historyLimit:50,textChunkLimit:4e3,streamMode:`partial`}}function ye(){return{bindingsFull:[],channelAgentRoutes:{telegram:{},weixin:{},feishu:{}},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:$(`default`)}},weixin:{enabled:!1,dmPolicy:`open`,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:`open`,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:{}}}}function be(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=r?.accounts,s=o&&typeof o==`object`&&!Array.isArray(o)?{...o}:{},c=typeof r?.botToken==`string`?r.botToken.trim():``,l=s.default?.botToken?.trim()??``;c&&!l&&(s={...s,default:{...s.default??$(`default`),accountId:`default`,botToken:c}}),s.default||(s={...s,default:$(`default`)});let u=i?.accounts,d=u&&typeof u==`object`&&!Array.isArray(u)?u:{},f=(()=>{let t=(e&&typeof e==`object`?e:{}).bindings;return Array.isArray(t)?t:[]})(),p=(()=>{let t=(e&&typeof e==`object`?e:{}).agents;return t&&typeof t==`object`?t:{}})(),m=typeof p.defaultId==`string`&&p.defaultId.trim()?p.defaultId.trim().toLowerCase():`main`,h={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:{...s}},weixin:{enabled:!!i?.enabled,dmPolicy:i?.dmPolicy||`open`,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:{...d}},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||`open`,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}:{}}},g=W(f,le(h.telegram),U(h.weixin),ue(h.feishu),m);return{...h,bindingsFull:f.map(e=>({...e})),channelAgentRoutes:g,defaultAgentId:m}}async function xe(e){return(await D(T(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Se(e){return(await D(T(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function Ce(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=de(e.bindingsFull,e.channelAgentRoutes,le(t),U(n),ue(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await D(T(`/api/config`),{method:`PATCH`,body:JSON.stringify({bindings:i,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:a,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}}})})).payload?.config;return _(),o?be(o):{...e,bindingsFull:i}}async function we(e){return(await D(T(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Te(e){return(await D(T(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function Ee({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:i}){let[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(`feishu`),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),O=(0,Q.useCallback)(async e=>{l(e),S(null),v(null),b(null),s(!0);try{let t=await we({domain:e});b(t.qrUrl),v(t.sessionKey)}catch(e){S(e instanceof Error?e.message:`Start failed`)}finally{s(!1)}},[]);(0,Q.useEffect)(()=>{if(!e){v(null),b(null),S(null),T(null),D(!1),l(`feishu`),s(!1);return}O(`feishu`)},[e,O]),(0,Q.useEffect)(()=>{if(!_)return;let e=!1,n,i=async()=>{try{let i=await Te(_);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,Q.useEffect)(()=>{if(!y){T(null),D(!1);return}let e=!1;return D(!1),ve.toDataURL(y,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||T(t)}).catch(()=>{e||(D(!0),T(null))}),()=>{e=!0}},[y]);let A=!!(y&&_),M=e,P=e&&!x&&!A;return(0,R.jsx)(p,{open:e,onOpenChange:t,children:(0,R.jsxs)(f,{children:[(0,R.jsx)(k,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,R.jsxs)(j,{className:u(`fixed left-1/2 top-1/2 max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,N,`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,R.jsx)(m,{asChild:!0,children:(0,R.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,R.jsx)(ae,{className:`size-4`})})}),(0,R.jsx)(h,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,R.jsx)(o,{className:`sr-only`,children:n.feishuQrModalSubtitle}),(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.feishuQrModalTitle}),(0,R.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.feishuQrModalSubtitle})]}),(0,R.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[x?(0,R.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:x}):null,!x&&(A||P)?(0,R.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:P?n.feishuQrStarting:n.feishuQrScanHint}),(0,R.jsxs)(`div`,{className:u(`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`,P&&`bg-surface-muted/40 dark:bg-surface-base`),children:[P?(0,R.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&&!E?(0,R.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,A&&y&&!x&&!C&&!E&&!P?(0,R.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,A&&y&&!x&&E?(0,R.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,R.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.feishuQrImageError}),(0,R.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,R.jsx)(g,{className:`size-3 shrink-0`}),n.feishuQrOpenLink]})]}):null]})]}):null]}),M?(0,R.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,R.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,R.jsx)(`button`,{type:`button`,disabled:a,className:u(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,c===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void O(`feishu`),children:n.feishuRegionChina}),(0,R.jsx)(`button`,{type:`button`,disabled:a,className:u(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,c===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void O(`lark`),children:n.feishuRegionInternational})]})}):null,(0,R.jsx)(`div`,{className:`mt-6`,children:(0,R.jsx)(d,{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:a,onClick:()=>void O(c),children:a?n.feishuQrStarting:n.feishuQrRegenerate})}),i?(0,R.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function De({tg:e,updateTelegram:t,ch:n,dmOpts:r,groupOpts:i,replyOpts:a,streamOpts:o,tgAccountsDraft:s,setTgAccountsDraft:c,tgAccountsError:l,onTgAccountsBlur:d}){let f=G;return(0,R.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.apiRoot}),(0,R.jsx)(`input`,{className:f(),value:e.apiRoot,onChange:e=>t({apiRoot:e.target.value}),placeholder:`https://api.telegram.org`})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.proxy}),(0,R.jsx)(`input`,{className:f(),value:e.proxy,onChange:e=>t({proxy:e.target.value}),placeholder:`http://proxy.example.com:8080`})]}),(0,R.jsx)(Z,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,R.jsx)(Z,{label:n.groupPolicy,value:e.groupPolicy,onChange:e=>t({groupPolicy:e}),options:i}),(0,R.jsx)(Z,{label:n.replyToMode,value:e.replyToMode,onChange:e=>t({replyToMode:e}),options:a}),(0,R.jsx)(Z,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:o}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.allowFromGroups}),(0,R.jsx)(`textarea`,{className:u(f(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`-1001234567890`,value:q(e.groupAllowFrom),onChange:e=>t({groupAllowFrom:K(e.target.value)})})]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.historyLimit}),(0,R.jsx)(`input`,{type:`number`,min:10,max:200,className:f(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.textChunkLimit}),(0,R.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,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.telegramDebug]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.multiAccountJson}),(0,R.jsx)(`textarea`,{className:u(f(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:s,onChange:e=>c(e.target.value),onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),l?(0,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):(0,R.jsx)(X,{children:n.multiAccountJsonDesc})]})]})}function Oe({open:e,onOpenChange:t,ch:n,form:r,baseline:i,tgAdvanced:a,setTgAdvanced:s,showToken:c,setShowToken:l,copied:g,copyToken:_,updateTelegram:v,updateChannelAgentRoute:y,tgAccountsDraft:C,setTgAccountsDraft:T,tgAccountsError:D,onTgAccountsBlur:O,dmOpts:A,groupOpts:M,replyOpts:P,streamOpts:te,chatAgents:ne,saving:re,dirty:ie,save:oe,discard:se}){let ce=G,F=r.telegram,I=i?pe(i.telegram):``,L=pe(F),z=!c&&!!String(I).trim()&&L===I;return(0,R.jsx)(p,{open:e,onOpenChange:t,children:(0,R.jsxs)(f,{children:[(0,R.jsx)(k,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,R.jsxs)(j,{className:u(`fixed left-1/2 top-1/2 max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,N,`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,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(h,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.telegramTitle}),(0,R.jsx)(o,{className:`mt-1 text-sm text-fg-muted`,children:n.telegramSubtitle})]}),(0,R.jsx)(m,{asChild:!0,children:(0,R.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,R.jsx)(ae,{className:`size-4`})})})]}),(0,R.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:F.enabled,onChange:e=>v({enabled:e.target.checked})}),(0,R.jsx)(`span`,{children:n.enableTelegramAria})]}),(0,R.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(Y,{children:[n.telegramToken,(0,R.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(`input`,{className:u(ce(),`min-w-0 flex-1 font-mono text-xs`),type:c?`text`:`password`,autoComplete:`off`,readOnly:z,value:z?`*`.repeat(Math.max(1,I.length)):L,onChange:e=>{if(z)return;let t=F.accounts?.default??$(`default`);v({accounts:{...F.accounts,default:{...t,accountId:`default`,botToken:e.target.value}}})},placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`}),L?(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void _(),children:[g?(0,R.jsx)(S,{className:`size-3.5`}):(0,R.jsx)(ee,{className:`size-3.5`}),g?n.copied:n.copy]}):null,(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>l(e=>!e),children:[c?(0,R.jsx)(x,{className:`size-3.5`}):(0,R.jsx)(b,{className:`size-3.5`}),c?n.hide:n.show]})]}),(0,R.jsx)(X,{children:n.telegramTokenDesc})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.allowFromDm}),(0,R.jsx)(`textarea`,{className:u(ce(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`123456789, 987654321`,value:q(F.allowFrom),onChange:e=>v({allowFrom:K(e.target.value)})}),(0,R.jsx)(X,{children:n.allowFromDmDesc})]}),(0,R.jsx)(ge,{accountIds:le(F),routes:r.channelAgentRoutes.telegram,defaultAgentId:r.defaultAgentId,agentItems:ne?.items??[],disabled:re,onChange:(e,t)=>y(`telegram`,e,t),ch:n}),(0,R.jsxs)(d,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:()=>s(e=>!e),children:[(0,R.jsx)(E,{className:u(`mr-1 size-4 transition-transform`,a&&`rotate-180`)}),a?n.advancedHide:n.advancedShow]}),a?(0,R.jsx)(De,{tg:F,updateTelegram:v,ch:n,dmOpts:A,groupOpts:M,replyOpts:P,streamOpts:te,tgAccountsDraft:C,setTgAccountsDraft:T,tgAccountsError:D,onTgAccountsBlur:O}):null]}),(0,R.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,R.jsx)(d,{type:`button`,variant:`secondary`,onClick:()=>t(!1),children:n.modalCancel}),(0,R.jsx)(d,{type:`button`,variant:`secondary`,disabled:!ie||re,onClick:se,children:n.discard}),(0,R.jsx)(d,{type:`button`,variant:`primary`,disabled:!ie||re,onClick:async()=>{await oe()&&t(!1)},children:re?n.saving:n.save})]})]})]})})}function ke(){let e=s(e=>e.language),t=O(e),n=t.channelsSettings,i=!!ne(e=>e.token),[a,o]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[ee,te]=(0,Q.useState)(!1),[re,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(``),[z,B]=(0,Q.useState)(``),[V,H]=(0,Q.useState)(``),[le,U]=(0,Q.useState)(``),[ue,W]=(0,Q.useState)(``),[de,G]=(0,Q.useState)(``),{data:fe}=r(i?`gateway-chat-agents-ch`:null,C,{revalidateOnFocus:!1}),{data:K,error:q,isLoading:me,mutate:he}=c(i),J=(0,Q.useMemo)(()=>K?.payload?.config===void 0?null:be(K.payload.config),[K]),Y=(0,Q.useMemo)(()=>!a||!l?!1:JSON.stringify(a)!==JSON.stringify(l),[a,l]);(0,Q.useEffect)(()=>{if(!i){o(null),u(null);return}J!==null&&(Y||(o(J),u(structuredClone(J)),R(JSON.stringify(J.telegram.accounts??{},null,2)),B(``),H(JSON.stringify(J.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(J.feishu?.accounts??{},null,2)),G(``),g(!1)))},[i,J,Y]);let X=!!(i&&me&&K===void 0&&!q),Z=q instanceof Error?q.message:q?String(q):null,ge=(0,Q.useCallback)((e,t,n)=>{o(r=>{if(!r)return null;let i=e===`telegram`?`telegram`:e===`weixin`?`weixin`:`feishu`;return{...r,channelAgentRoutes:{...r.channelAgentRoutes,[i]:{...r.channelAgentRoutes[i],[t]:n.trim().toLowerCase()}}}})},[]),_e=(0,Q.useCallback)(e=>{o(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),ve=(0,Q.useCallback)(e=>{o(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),$=(0,Q.useCallback)(e=>{o(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]);return{language:e,m:t,ch:n,hasToken:i,loading:X,fetchError:Z,mutate:he,form:a,baseline:l,dirty:Y,saving:d,error:p,saveOk:h,weixinModalOpen:_,setWeixinModalOpen:v,telegramModalOpen:y,setTelegramModalOpen:b,feishuModalOpen:x,setFeishuModalOpen:S,removeTarget:w,setRemoveTarget:T,weixinSuccessBanner:E,setWeixinSuccessBanner:D,feishuSetupSuccessBanner:k,tgAdvanced:j,setTgAdvanced:M,showToken:N,setShowToken:P,showFeishuSecret:ee,setShowFeishuSecret:te,showFeishuWebhookSecrets:re,setShowFeishuWebhookSecrets:ie,copied:ae,feishuCopied:se,feishuWebhookCopied:F,tgAccountsDraft:L,setTgAccountsDraft:R,tgAccountsError:z,wxAccountsDraft:V,setWxAccountsDraft:H,wxAccountsError:le,feishuAccountsDraft:ue,setFeishuAccountsDraft:W,feishuAccountsError:de,chatAgents:fe,updateChannelAgentRoute:ge,updateTelegram:_e,updateWeixin:ve,updateFeishu:$,save:(0,Q.useCallback)(async()=>{if(!a||d)return!1;f(!0),m(null),g(!1);try{let e=await Ce(a);o(e);let t=structuredClone(e);return u(t),R(JSON.stringify(t.telegram.accounts??{},null,2)),B(``),H(JSON.stringify(t.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(t.feishu?.accounts??{},null,2)),G(``),g(!0),window.setTimeout(()=>g(!1),2500),!0}catch(e){return m(e instanceof Error?e.message:n.saveError),!1}finally{f(!1)}},[a,d,n.saveError]),discard:(0,Q.useCallback)(()=>{if(!l)return;let e=structuredClone(l);o(e),R(JSON.stringify(e.telegram.accounts??{},null,2)),B(``),H(JSON.stringify(e.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(e.feishu?.accounts??{},null,2)),G(``),m(null),g(!1)},[l]),toggleChannelEnabled:(0,Q.useCallback)(async(e,t)=>{if(!a||d)return;let r=a,i=e===`weixin`?{...a,weixin:{...a.weixin,enabled:t}}:e===`telegram`?{...a,telegram:{...a.telegram,enabled:t}}:{...a,feishu:{...a.feishu,enabled:t}};o(i),f(!0),m(null);try{let e=await Ce(i);o(e);let t=structuredClone(e);u(t),R(JSON.stringify(t.telegram.accounts??{},null,2)),H(JSON.stringify(t.weixin.accounts??{},null,2)),W(JSON.stringify(t.feishu?.accounts??{},null,2))}catch(e){m(e instanceof Error?e.message:n.saveError),o(r)}finally{f(!1)}},[a,d,n.saveError]),removeChannel:(0,Q.useCallback)(async()=>{if(!a||!w||d)return;let e=ye(),t=w===`weixin`?{...a,weixin:e.weixin}:w===`telegram`?{...a,telegram:e.telegram}:{...a,feishu:e.feishu};f(!0),m(null);try{let e=await Ce(t);o(e);let n=structuredClone(e);u(n),R(JSON.stringify(n.telegram.accounts??{},null,2)),H(JSON.stringify(n.weixin.accounts??{},null,2)),B(``),U(``),W(JSON.stringify(n.feishu?.accounts??{},null,2)),G(``),T(null),g(!0),window.setTimeout(()=>g(!1),2500)}catch(e){m(e instanceof Error?e.message:n.saveError)}finally{f(!1)}},[a,w,d,n.saveError]),copyToken:(0,Q.useCallback)(async()=>{let e=a?pe(a.telegram):``;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),oe(!0),window.setTimeout(()=>oe(!1),2e3))},[a]),handleFeishuQrSetupSuccess:(0,Q.useCallback)(e=>{$({appId:e.appId,domain:e.domain,enabled:!0}),he(),A(n.feishuQrSetupSuccess),window.setTimeout(()=>A(null),4e3)},[$,he,n.feishuQrSetupSuccess]),copyFeishuSecret:(0,Q.useCallback)(async()=>{let e=a?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),ce(!0),window.setTimeout(()=>ce(!1),2e3))},[a]),copyFeishuWebhookConfig:(0,Q.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(()=>{}),I(!0),window.setTimeout(()=>I(!1),2e3)},[a]),onTgAccountsBlur:(0,Q.useCallback)(()=>{if(!a)return;let e=L.trim();if(!e){_e({accounts:{}}),B(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);_e({accounts:t}),B(``)}catch(e){B(e instanceof Error?e.message:n.jsonInvalid)}},[a,L,_e,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,Q.useCallback)(()=>{if(!a)return;let e=V.trim();if(!e){ve({accounts:{}}),U(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);ve({accounts:t}),U(``)}catch(e){U(e instanceof Error?e.message:n.jsonInvalid)}},[a,V,ve,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,Q.useCallback)(()=>{if(!a)return;let e=ue.trim();if(!e){$({accounts:{}}),G(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);$({accounts:t}),G(``)}catch(e){G(e instanceof Error?e.message:n.jsonInvalid)}},[a,ue,$,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,Q.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,Q.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,Q.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,Q.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}function Ae({open:e,onOpenChange:t,ch:n,onLoginSuccess:r,moreSettings:i}){let[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),O=(0,Q.useCallback)(async()=>{b(null),S(null),l(null),s(!0);try{let e=await xe();v(e.qrcodeUrl),l(e.sessionKey)}catch(e){b(e instanceof Error?e.message:`Start failed`)}finally{s(!1)}},[]);(0,Q.useEffect)(()=>{if(!e){l(null),v(null),b(null),T(null),D(!1),S(null);return}O()},[e,O]),(0,Q.useEffect)(()=>{if(!c)return;let e=!1,i,a=async()=>{try{let a=await Se(c);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),l(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`),l(null),v(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[c,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,Q.useEffect)(()=>{if(!_){T(null),D(!1);return}let e=!1;return D(!1),ve.toDataURL(_,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||T(t)}).catch(()=>{e||(D(!0),T(null))}),()=>{e=!0}},[_]);let A=!!(_&&c),M=e&&!y&&!A;return(0,R.jsx)(p,{open:e,onOpenChange:t,children:(0,R.jsxs)(f,{children:[(0,R.jsx)(k,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,R.jsxs)(j,{className:u(`fixed left-1/2 top-1/2 max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,N,`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,R.jsx)(m,{asChild:!0,children:(0,R.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,R.jsx)(ae,{className:`size-4`})})}),(0,R.jsx)(h,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,R.jsx)(o,{className:`sr-only`,children:n.weixinQrModalSubtitle}),(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.weixinQrModalTitle}),(0,R.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.weixinQrModalSubtitle})]}),(0,R.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[y?(0,R.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:y}):null,!y&&(A||M)?(0,R.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,R.jsx)(`p`,{className:u(`min-h-[1.25rem] text-center text-sm`,x&&!M?`text-accent`:`text-fg-muted`),children:M?n.weixinQrLoginBusy:x??`\xA0`}),(0,R.jsxs)(`div`,{className:u(`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,R.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,A&&_&&!y&&C&&!E?(0,R.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,A&&_&&!y&&!C&&!E&&!M?(0,R.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,A&&_&&!y&&E?(0,R.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,R.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.weixinQrImageError}),(0,R.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,R.jsx)(g,{className:`size-3 shrink-0`}),n.weixinQrOpenLink]})]}):null]})]}):null]}),(0,R.jsx)(`div`,{className:`mt-6`,children:(0,R.jsx)(d,{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:a,onClick:()=>void O(),children:a?n.weixinQrLoginBusy:n.weixinQrRegenerate})}),i?(0,R.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function je({wx:e,updateWeixin:t,ch:n,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,channelAgentRoutesWx:l,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}){let h=G;return(0,R.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.weixinAllowFrom}),(0,R.jsx)(`textarea`,{className:u(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,R.jsx)(X,{children:n.weixinAllowFromDesc})]}),(0,R.jsx)(Z,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,R.jsx)(Z,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:i}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.historyLimit}),(0,R.jsx)(`input`,{type:`number`,min:10,max:200,className:h(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.textChunkLimit}),(0,R.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,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.weixinRouteTag}),(0,R.jsx)(`input`,{className:h(),value:e.routeTag,onChange:e=>t({routeTag:e.target.value}),placeholder:n.routeTagPlaceholder}),(0,R.jsx)(X,{children:n.weixinRouteTagDesc})]}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.weixinDebug]}),(0,R.jsx)(X,{children:n.weixinDebugDesc}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.weixinAccountsJson}),(0,R.jsx)(`textarea`,{className:u(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,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:s}):(0,R.jsx)(X,{children:n.weixinAccountsJsonDesc})]}),(0,R.jsx)(ge,{accountIds:U(e),routes:l,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:n})]})}function Me({ch:e,wx:t,updateWeixin:n,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,form:l,chatAgents:u,onAgentRouteChange:f,saving:p,dirty:m,save:h,discard:g}){return(0,R.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,R.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,R.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,R.jsx)(E,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,R.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.weixinAdvancedHint}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:t.enabled,onChange:e=>n({enabled:e.target.checked})}),(0,R.jsx)(`span`,{children:e.enableWeixinAria})]}),(0,R.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,R.jsx)(je,{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:f,routingDisabled:p})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,R.jsx)(d,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!m||p,onClick:g,children:e.discard}),(0,R.jsx)(d,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!m||p,onClick:async()=>{await h()},children:p?e.saving:e.save})]})]})]})}function Ne(){let{language:e,m:t,ch:n,hasToken:r,loading:i,fetchError:a,mutate:o,form:s,baseline:c,dirty:l,saving:u,error:f,saveOk:p,weixinModalOpen:m,setWeixinModalOpen:h,telegramModalOpen:_,setTelegramModalOpen:v,feishuModalOpen:b,setFeishuModalOpen:x,removeTarget:S,setRemoveTarget:C,weixinSuccessBanner:w,setWeixinSuccessBanner:T,feishuSetupSuccessBanner:E,tgAdvanced:D,setTgAdvanced:O,showToken:k,setShowToken:A,showFeishuSecret:j,setShowFeishuSecret:M,showFeishuWebhookSecrets:N,setShowFeishuWebhookSecrets:P,copied:ee,feishuCopied:ne,feishuWebhookCopied:re,tgAccountsDraft:ae,setTgAccountsDraft:oe,tgAccountsError:se,wxAccountsDraft:ce,setWxAccountsDraft:F,wxAccountsError:I,feishuAccountsDraft:L,setFeishuAccountsDraft:V,feishuAccountsError:H,chatAgents:le,updateChannelAgentRoute:U,updateTelegram:ue,updateWeixin:W,updateFeishu:de,save:G,discard:fe,toggleChannelEnabled:K,removeChannel:q,copyToken:pe,handleFeishuQrSetupSuccess:Y,copyFeishuSecret:X,copyFeishuWebhookConfig:Z,onTgAccountsBlur:ge,onWxAccountsBlur:Q,onFeishuAccountsBlur:ve,dmOpts:$,groupOpts:ye,replyOpts:be,streamOpts:xe}=ke();if(!r)return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.channels}),(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]});if(i)return(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,R.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,R.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,R.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:n.loading})]});if(!s)return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f??a??n.loadError}),(0,R.jsx)(d,{type:`button`,variant:`secondary`,onClick:()=>void o(),children:n.retry})]});let Se=s.weixin,Ce=s.telegram,we=s.feishu,Te=he(Se),De=me(Ce),je=J(we),Ne=(0,R.jsx)(_e,{ch:n,form:s,baseline:c,showFeishuSecret:j,setShowFeishuSecret:M,showFeishuWebhookSecrets:N,setShowFeishuWebhookSecrets:P,feishuCopied:ne,feishuWebhookCopied:re,copyFeishuSecret:X,copyFeishuWebhookConfig:Z,updateFeishu:de,updateChannelAgentRoute:U,feishuAccountsDraft:L,setFeishuAccountsDraft:V,feishuAccountsError:H,onFeishuAccountsBlur:ve,dmOpts:$,groupOpts:ye,chatAgents:le,saving:u,dirty:l,save:G,discard:fe}),Pe=(0,R.jsx)(Me,{ch:n,wx:Se,updateWeixin:W,dmOpts:$,streamOpts:xe,wxAccountsDraft:ce,setWxAccountsDraft:F,wxAccountsError:I,onWxAccountsBlur:Q,form:s,chatAgents:le,onAgentRouteChange:(e,t)=>U(`weixin`,e,t),saving:u,dirty:l,save:G,discard:fe});return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.channels}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,R.jsxs)(`a`,{href:ie(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,R.jsx)(g,{className:`size-3.5`})]})]}),l?(0,R.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,p?(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.saved}):null,f?(0,R.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}):null,w?(0,R.jsx)(`p`,{className:`text-xs text-accent`,children:w}):null,E?(0,R.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:E}):null,(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(z,{icon:(0,R.jsx)(y,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.weixinTitle,subtitle:n.weixinSubtitle,configured:Te,enabled:Se.enabled,toggleDisabled:u,onToggle:e=>void K(`weixin`,e),onConfigure:()=>h(!0),onEdit:()=>h(!0),onRemove:()=>C(`weixin`),ch:n}),(0,R.jsx)(z,{icon:(0,R.jsx)(te,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.telegramTitle,subtitle:n.telegramSubtitle,configured:De,enabled:Ce.enabled,toggleDisabled:u,onToggle:e=>void K(`telegram`,e),onConfigure:()=>v(!0),onEdit:()=>v(!0),onRemove:()=>C(`telegram`),ch:n}),(0,R.jsx)(z,{icon:(0,R.jsx)(y,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.feishuTitle,subtitle:n.feishuSubtitle,configured:je,enabled:we.enabled,toggleDisabled:u,onToggle:e=>void K(`feishu`,e),onConfigure:()=>x(!0),onEdit:()=>x(!0),onRemove:()=>C(`feishu`),ch:n})]}),(0,R.jsx)(Ae,{open:m,onOpenChange:h,ch:n,onLoginSuccess:async()=>{await o(),T(n.weixinQrLoginSuccess),window.setTimeout(()=>T(null),4e3)},moreSettings:Pe}),(0,R.jsx)(Oe,{open:_,onOpenChange:v,ch:n,form:s,baseline:c,tgAdvanced:D,setTgAdvanced:O,showToken:k,setShowToken:A,copied:ee,copyToken:pe,updateTelegram:ue,updateChannelAgentRoute:U,tgAccountsDraft:ae,setTgAccountsDraft:oe,tgAccountsError:se,onTgAccountsBlur:ge,dmOpts:$,groupOpts:ye,replyOpts:be,streamOpts:xe,chatAgents:le,saving:u,dirty:l,save:G,discard:fe}),(0,R.jsx)(Ee,{open:b,onOpenChange:x,ch:n,onSetupSuccess:Y,moreSettings:Ne}),(0,R.jsx)(B,{open:S!==null,onOpenChange:e=>{e||C(null)},ch:n,removeTarget:S,onCancel:()=>C(null),saving:u,onConfirmRemove:()=>void q()})]})}export{Ne 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{$r as i,An as a,At as o,Cn as s,Ct as c,Dn as l,Ln as u,Mn as d,Mt as f,Nt as p,Ot as m,Pt as h,Qr as g,St as _,T as v,Tr as y,Xr as b,Zr as x,_i as S,bt as C,c as w,dn as T,gi as E,gn as D,jn as O,jt as k,kn as A,kt as j,l as M,o as N,qn as P,ri as ee,sr as te,vn as ne,xr as re,yn as ie,zn as ae}from"./index-DvMI6Vqn.js";import{a as oe,i as se,n as ce,r as F,t as I}from"./dist-CEmPWsYK.js";import{t as L}from"./browser-DNXWYwzc.js";var R=n();function z({icon:e,title:t,subtitle:n,configured:r,enabled:a,onToggle:o,toggleDisabled:s,onConfigure:c,onEdit:l,onRemove:f,ch:p}){return(0,R.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,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[(0,R.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:e}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),r?(0,R.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-xs font-medium text-success`,children:p.hubConnectedBadge}):null]}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n})]})]}),r?(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,R.jsxs)(se,{children:[(0,R.jsx)(oe,{asChild:!0,children:(0,R.jsx)(d,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.menuMoreAria,children:(0,R.jsx)(i,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,R.jsx)(F,{children:(0,R.jsxs)(I,{className:u(`min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,M),sideOffset:6,align:`end`,children:[(0,R.jsx)(ce,{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:()=>l(),children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(re,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),p.menuEditConfig]})}),(0,R.jsx)(ce,{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:()=>f(),children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(P,{className:`size-4 shrink-0`,strokeWidth:1.75}),p.menuRemoveConfig]})})]})})]}),(0,R.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":`${t} — ${p.enableChannelAria}`,disabled:s,className:u(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,a?`justify-end bg-accent`:`justify-start bg-surface-hover`,s&&`cursor-not-allowed opacity-50`),onClick:()=>void o(!a),children:(0,R.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,R.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,R.jsx)(d,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:c,children:p.hubConfigureButton})})]})}function B({open:e,onOpenChange:t,ch:n,removeTarget:r,onCancel:i,saving:a,onConfirmRemove:s}){return(0,R.jsx)(p,{open:e,onOpenChange:t,children:(0,R.jsxs)(f,{children:[(0,R.jsx)(k,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,R.jsxs)(j,{className:u(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,N,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsx)(h,{className:`text-base font-semibold text-fg`,children:n.removeChannelTitle}),(0,R.jsx)(o,{className:`mt-2 text-sm text-fg-muted`,children:r?n.removeChannelConfirm.replace(`{{name}}`,r===`weixin`?n.weixinTitle:r===`telegram`?n.telegramTitle:n.feishuTitle):`\xA0`}),(0,R.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,R.jsx)(d,{type:`button`,variant:`secondary`,onClick:i,children:n.modalCancel}),(0,R.jsx)(d,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:a,onClick:s,children:a?n.saving:n.removeChannelAction})]})]})]})})}function V(e){return(e??``).trim().toLowerCase()}function H(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 le(e){return Object.keys(e.accounts??{}).sort()}function U(e){return Object.keys(e.accounts??{}).sort()}function ue(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 W(e,t,n,r,i){let a={},o={},s={};for(let n of t)a[n]=(e.find(e=>V(e.match?.channel)===`telegram`&&V(e.match?.accountId)===V(n)&&H(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>V(e.match?.channel)===`weixin`&&V(e.match?.accountId)===V(t)&&H(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>V(e.match?.channel)===`feishu`&&V(e.match?.accountId)===V(t)&&H(e))?.agentId??i).trim().toLowerCase();return{telegram:a,weixin:o,feishu:s}}function de(e,t,n,r,i,a){let o=new Set(n.map(V)),s=new Set(r.map(V)),c=new Set(i.map(V)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!H(e))return!0;let t=V(e.match.channel),n=V(e.match.accountId);return!n||n===`*`?!0:!(t===`telegram`&&o.has(n)||t===`weixin`&&s.has(n)||t===`feishu`&&c.has(n))}),u=[];for(let e of n){let n=(t.telegram[e]??t.telegram[V(e)]??a).trim().toLowerCase();u.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[V(e)]??a).trim().toLowerCase();u.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[V(e)]??a).trim().toLowerCase();u.push({id:`ui:route:account:feishu:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`feishu`,accountId:e}})}return[...l,...u]}function G(){return u(`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 fe(){return u(A,l)}function K(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).map(e=>/^-?\d+$/.test(e)?Number(e):e)}function q(e){return e.map(String).join(`, `)}function pe(e){let t=e.accounts?.default?.botToken;return typeof t==`string`?t:``}function me(e){return Object.values(e.accounts??{}).some(e=>typeof e.botToken==`string`&&e.botToken.trim().length>0)}function he(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function J(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}function Y({children:e}){return(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e})}function X({children:e}){return(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:e})}function Z({label:e,value:t,onChange:n,options:r}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e}),(0,R.jsx)(`select`,{className:fe(),value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function ge({accountIds:e,routes:t,defaultAgentId:n,agentItems:r,disabled:i,onChange:a,ch:o}){let c=O(s(e=>e.language)).agentsSettings;if(e.length===0)return null;let d=r.length>0?r:[{id:n}];return(0,R.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(Y,{children:o.agentRoutingTitle}),(0,R.jsx)(X,{children:o.agentRoutingHint})]}),(0,R.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,R.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,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:o.agentRoutingAccountLabel}),(0,R.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:e,children:e})]}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${e}`,children:o.agentRoutingAgentLabel}),(0,R.jsx)(`select`,{id:`agent-route-${e}`,className:u(G(),l),disabled:i,value:(t[e]??n).toLowerCase(),onChange:t=>a(e,t.target.value),children:d.map(e=>(0,R.jsx)(`option`,{value:e.id,children:`${v(e,c)} (${e.id})`},e.id))})]})]},e))})]})}function _e({ch:e,form:t,baseline:n,showFeishuSecret:r,setShowFeishuSecret:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuCopied:s,feishuWebhookCopied:c,copyFeishuSecret:l,copyFeishuWebhookConfig:f,updateFeishu:p,updateChannelAgentRoute:m,feishuAccountsDraft:h,setFeishuAccountsDraft:g,feishuAccountsError:_,onFeishuAccountsBlur:v,dmOpts:y,groupOpts:C,chatAgents:w,saving:T,dirty:D,save:O,discard:k}){let A=G,j=t.feishu,M=n?.feishu?.appSecret??``,N=!r&&!!String(M).trim()&&j.appSecret===M;return(0,R.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,R.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,R.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,R.jsx)(E,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,R.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.feishuAdvancedHint}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:j.enabled,onChange:e=>p({enabled:e.target.checked})}),(0,R.jsx)(`span`,{children:e.enableFeishuAria})]}),(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(Y,{children:[e.feishuAppId,(0,R.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,R.jsx)(`input`,{className:u(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.appId,onChange:e=>p({appId:e.target.value}),placeholder:`cli_xxx`}),(0,R.jsx)(X,{children:e.feishuAppIdDesc})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(Y,{children:[e.feishuAppSecret,(0,R.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(`input`,{className:u(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,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void l(),children:[s?(0,R.jsx)(S,{className:`size-3.5`}):(0,R.jsx)(ee,{className:`size-3.5`}),s?e.copied:e.copy]}):null,(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>i(e=>!e),children:[r?(0,R.jsx)(x,{className:`size-3.5`}):(0,R.jsx)(b,{className:`size-3.5`}),r?e.hide:e.show]})]}),(0,R.jsx)(X,{children:e.feishuAppSecretDesc})]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.feishuDomain}),(0,R.jsxs)(`select`,{className:A(),value:String(j.domain||`feishu`),onChange:e=>p({domain:e.target.value}),children:[(0,R.jsx)(`option`,{value:`feishu`,children:`feishu`}),(0,R.jsx)(`option`,{value:`lark`,children:`lark`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.connectionMode}),(0,R.jsxs)(`select`,{className:A(),value:j.connectionMode,onChange:e=>p({connectionMode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`websocket`,children:`websocket`}),(0,R.jsx)(`option`,{value:`webhook`,children:`webhook`})]}),(0,R.jsx)(X,{children:e.connectionModeDesc})]})]}),j.connectionMode===`webhook`?(0,R.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.webhookTitle}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>o(e=>!e),children:[a?(0,R.jsx)(x,{className:`size-3.5`}):(0,R.jsx)(b,{className:`size-3.5`}),a?e.hide:e.show]}),(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void f(),children:[c?(0,R.jsx)(S,{className:`size-3.5`}):(0,R.jsx)(ee,{className:`size-3.5`}),c?e.copied:e.copy]})]})]}),(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.verificationToken}),(0,R.jsx)(`input`,{className:u(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,R.jsx)(X,{children:e.verificationTokenDesc})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.encryptKey}),(0,R.jsx)(`input`,{className:u(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,R.jsx)(X,{children:e.encryptKeyDesc})]})]}),(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,R.jsx)(Y,{children:e.webhookHost}),(0,R.jsx)(`input`,{className:u(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,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.webhookPort}),(0,R.jsx)(`input`,{className:u(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,R.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.webhookPath}),(0,R.jsx)(`input`,{className:u(A(),`min-w-0 flex-1 font-mono text-xs`),value:j.webhookPath??``,onChange:e=>p({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,R.jsx)(X,{children:e.webhookPathDesc})]})]}):null,(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.renderMode}),(0,R.jsxs)(`select`,{className:A(),value:j.renderMode,onChange:e=>p({renderMode:e.target.value}),children:[(0,R.jsx)(`option`,{value:`auto`,children:`auto`}),(0,R.jsx)(`option`,{value:`raw`,children:`raw`}),(0,R.jsx)(`option`,{value:`card`,children:`card`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.reactionNotifications}),(0,R.jsxs)(`select`,{className:A(),value:j.reactionNotifications,onChange:e=>p({reactionNotifications:e.target.value}),children:[(0,R.jsx)(`option`,{value:`off`,children:`off`}),(0,R.jsx)(`option`,{value:`own`,children:`own`}),(0,R.jsx)(`option`,{value:`all`,children:`all`})]})]})]}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:j.streaming,onChange:e=>p({streaming:e.target.checked})}),e.enableStreaming]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.dmPolicy}),(0,R.jsx)(`select`,{className:A(),value:j.dmPolicy,onChange:e=>p({dmPolicy:e.target.value}),children:y.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.groupPolicy}),(0,R.jsx)(`select`,{className:A(),value:j.groupPolicy,onChange:e=>p({groupPolicy:e.target.value}),children:C.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:j.requireMention,onChange:e=>p({requireMention:e.target.checked})}),e.requireMention]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.allowFromDm}),(0,R.jsx)(`textarea`,{className:u(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`ou_xxx, on_xxx`,value:q(j.allowFrom),onChange:e=>p({allowFrom:K(e.target.value)})}),(0,R.jsx)(X,{children:e.allowFromDmDesc})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.allowFromGroups}),(0,R.jsx)(`textarea`,{className:u(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`oc_xxx, oc_yyy`,value:q(j.groupAllowFrom),onChange:e=>p({groupAllowFrom:K(e.target.value)})}),(0,R.jsx)(X,{children:e.allowFromGroupsDesc})]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.historyLimit}),(0,R.jsx)(`input`,{className:u(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,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.textChunkLimit}),(0,R.jsx)(`input`,{className:u(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,R.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feishuToolsTitle}),(0,R.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,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!j.tools?.[e],onChange:t=>p({tools:{...j.tools,[e]:t.target.checked}})}),t]},e))}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(X,{children:e.feishuToolsDesc})})]}),(0,R.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feishuActionsTitle}),(0,R.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!j.actions?.reactions,onChange:e=>p({actions:{...j.actions,reactions:e.target.checked}})}),e.feishuActionReactions]})]}),(0,R.jsx)(ge,{accountIds:ue(j),routes:t.channelAgentRoutes.feishu,defaultAgentId:t.defaultAgentId,agentItems:w?.items??[],disabled:T,onChange:(e,t)=>m(`feishu`,e,t),ch:e}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:e.multiAccountJson}),(0,R.jsx)(`textarea`,{className:u(A(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:h,onChange:e=>g(e.target.value),onBlur:v,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),_?(0,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:_}):(0,R.jsx)(X,{children:e.multiAccountJsonDesc})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,R.jsx)(d,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!D||T,onClick:k,children:e.discard}),(0,R.jsx)(d,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!D||T,onClick:async()=>{await O()},children:T?e.saving:e.save})]})]})]})}var Q=e(t(),1),ve=e(L(),1);function $(e){return{accountId:e,name:``,enabled:!0,botToken:``,allowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,apiRoot:``,proxy:``,historyLimit:50,textChunkLimit:4e3,streamMode:`partial`}}function ye(){return{bindingsFull:[],channelAgentRoutes:{telegram:{},weixin:{},feishu:{}},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:$(`default`)}},weixin:{enabled:!1,dmPolicy:`open`,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:`open`,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:{}}}}function be(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=r?.accounts,s=o&&typeof o==`object`&&!Array.isArray(o)?{...o}:{},c=typeof r?.botToken==`string`?r.botToken.trim():``,l=s.default?.botToken?.trim()??``;c&&!l&&(s={...s,default:{...s.default??$(`default`),accountId:`default`,botToken:c}}),s.default||(s={...s,default:$(`default`)});let u=i?.accounts,d=u&&typeof u==`object`&&!Array.isArray(u)?u:{},f=(()=>{let t=(e&&typeof e==`object`?e:{}).bindings;return Array.isArray(t)?t:[]})(),p=(()=>{let t=(e&&typeof e==`object`?e:{}).agents;return t&&typeof t==`object`?t:{}})(),m=typeof p.defaultId==`string`&&p.defaultId.trim()?p.defaultId.trim().toLowerCase():`main`,h={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:{...s}},weixin:{enabled:!!i?.enabled,dmPolicy:i?.dmPolicy||`open`,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:{...d}},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||`open`,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}:{}}},g=W(f,le(h.telegram),U(h.weixin),ue(h.feishu),m);return{...h,bindingsFull:f.map(e=>({...e})),channelAgentRoutes:g,defaultAgentId:m}}async function xe(e){return(await D(T(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Se(e){return(await D(T(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function Ce(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=de(e.bindingsFull,e.channelAgentRoutes,le(t),U(n),ue(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await D(T(`/api/config`),{method:`PATCH`,body:JSON.stringify({bindings:i,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:a,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}}})})).payload?.config;return _(),o?be(o):{...e,bindingsFull:i}}async function we(e){return(await D(T(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Te(e){return(await D(T(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function Ee({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:i}){let[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(`feishu`),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),O=(0,Q.useCallback)(async e=>{l(e),S(null),v(null),b(null),s(!0);try{let t=await we({domain:e});b(t.qrUrl),v(t.sessionKey)}catch(e){S(e instanceof Error?e.message:`Start failed`)}finally{s(!1)}},[]);(0,Q.useEffect)(()=>{if(!e){v(null),b(null),S(null),T(null),D(!1),l(`feishu`),s(!1);return}O(`feishu`)},[e,O]),(0,Q.useEffect)(()=>{if(!_)return;let e=!1,n,i=async()=>{try{let i=await Te(_);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,Q.useEffect)(()=>{if(!y){T(null),D(!1);return}let e=!1;return D(!1),ve.toDataURL(y,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||T(t)}).catch(()=>{e||(D(!0),T(null))}),()=>{e=!0}},[y]);let A=!!(y&&_),M=e,P=e&&!x&&!A;return(0,R.jsx)(p,{open:e,onOpenChange:t,children:(0,R.jsxs)(f,{children:[(0,R.jsx)(k,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,R.jsxs)(j,{className:u(`fixed left-1/2 top-1/2 max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,N,`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,R.jsx)(m,{asChild:!0,children:(0,R.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,R.jsx)(ae,{className:`size-4`})})}),(0,R.jsx)(h,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,R.jsx)(o,{className:`sr-only`,children:n.feishuQrModalSubtitle}),(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.feishuQrModalTitle}),(0,R.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.feishuQrModalSubtitle})]}),(0,R.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[x?(0,R.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:x}):null,!x&&(A||P)?(0,R.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:P?n.feishuQrStarting:n.feishuQrScanHint}),(0,R.jsxs)(`div`,{className:u(`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`,P&&`bg-surface-muted/40 dark:bg-surface-base`),children:[P?(0,R.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&&!E?(0,R.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,A&&y&&!x&&!C&&!E&&!P?(0,R.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,A&&y&&!x&&E?(0,R.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,R.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.feishuQrImageError}),(0,R.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,R.jsx)(g,{className:`size-3 shrink-0`}),n.feishuQrOpenLink]})]}):null]})]}):null]}),M?(0,R.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,R.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,R.jsx)(`button`,{type:`button`,disabled:a,className:u(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,c===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void O(`feishu`),children:n.feishuRegionChina}),(0,R.jsx)(`button`,{type:`button`,disabled:a,className:u(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,c===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void O(`lark`),children:n.feishuRegionInternational})]})}):null,(0,R.jsx)(`div`,{className:`mt-6`,children:(0,R.jsx)(d,{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:a,onClick:()=>void O(c),children:a?n.feishuQrStarting:n.feishuQrRegenerate})}),i?(0,R.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function De({tg:e,updateTelegram:t,ch:n,dmOpts:r,groupOpts:i,replyOpts:a,streamOpts:o,tgAccountsDraft:s,setTgAccountsDraft:c,tgAccountsError:l,onTgAccountsBlur:d}){let f=G;return(0,R.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.apiRoot}),(0,R.jsx)(`input`,{className:f(),value:e.apiRoot,onChange:e=>t({apiRoot:e.target.value}),placeholder:`https://api.telegram.org`})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.proxy}),(0,R.jsx)(`input`,{className:f(),value:e.proxy,onChange:e=>t({proxy:e.target.value}),placeholder:`http://proxy.example.com:8080`})]}),(0,R.jsx)(Z,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,R.jsx)(Z,{label:n.groupPolicy,value:e.groupPolicy,onChange:e=>t({groupPolicy:e}),options:i}),(0,R.jsx)(Z,{label:n.replyToMode,value:e.replyToMode,onChange:e=>t({replyToMode:e}),options:a}),(0,R.jsx)(Z,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:o}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.allowFromGroups}),(0,R.jsx)(`textarea`,{className:u(f(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`-1001234567890`,value:q(e.groupAllowFrom),onChange:e=>t({groupAllowFrom:K(e.target.value)})})]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.historyLimit}),(0,R.jsx)(`input`,{type:`number`,min:10,max:200,className:f(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.textChunkLimit}),(0,R.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,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.telegramDebug]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.multiAccountJson}),(0,R.jsx)(`textarea`,{className:u(f(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:s,onChange:e=>c(e.target.value),onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),l?(0,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):(0,R.jsx)(X,{children:n.multiAccountJsonDesc})]})]})}function Oe({open:e,onOpenChange:t,ch:n,form:r,baseline:i,tgAdvanced:a,setTgAdvanced:s,showToken:c,setShowToken:l,copied:g,copyToken:_,updateTelegram:v,updateChannelAgentRoute:y,tgAccountsDraft:C,setTgAccountsDraft:T,tgAccountsError:D,onTgAccountsBlur:O,dmOpts:A,groupOpts:M,replyOpts:P,streamOpts:te,chatAgents:ne,saving:re,dirty:ie,save:oe,discard:se}){let ce=G,F=r.telegram,I=i?pe(i.telegram):``,L=pe(F),z=!c&&!!String(I).trim()&&L===I;return(0,R.jsx)(p,{open:e,onOpenChange:t,children:(0,R.jsxs)(f,{children:[(0,R.jsx)(k,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,R.jsxs)(j,{className:u(`fixed left-1/2 top-1/2 max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,N,`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,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(h,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.telegramTitle}),(0,R.jsx)(o,{className:`mt-1 text-sm text-fg-muted`,children:n.telegramSubtitle})]}),(0,R.jsx)(m,{asChild:!0,children:(0,R.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,R.jsx)(ae,{className:`size-4`})})})]}),(0,R.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:F.enabled,onChange:e=>v({enabled:e.target.checked})}),(0,R.jsx)(`span`,{children:n.enableTelegramAria})]}),(0,R.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(Y,{children:[n.telegramToken,(0,R.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(`input`,{className:u(ce(),`min-w-0 flex-1 font-mono text-xs`),type:c?`text`:`password`,autoComplete:`off`,readOnly:z,value:z?`*`.repeat(Math.max(1,I.length)):L,onChange:e=>{if(z)return;let t=F.accounts?.default??$(`default`);v({accounts:{...F.accounts,default:{...t,accountId:`default`,botToken:e.target.value}}})},placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`}),L?(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void _(),children:[g?(0,R.jsx)(S,{className:`size-3.5`}):(0,R.jsx)(ee,{className:`size-3.5`}),g?n.copied:n.copy]}):null,(0,R.jsxs)(d,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>l(e=>!e),children:[c?(0,R.jsx)(x,{className:`size-3.5`}):(0,R.jsx)(b,{className:`size-3.5`}),c?n.hide:n.show]})]}),(0,R.jsx)(X,{children:n.telegramTokenDesc})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.allowFromDm}),(0,R.jsx)(`textarea`,{className:u(ce(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`123456789, 987654321`,value:q(F.allowFrom),onChange:e=>v({allowFrom:K(e.target.value)})}),(0,R.jsx)(X,{children:n.allowFromDmDesc})]}),(0,R.jsx)(ge,{accountIds:le(F),routes:r.channelAgentRoutes.telegram,defaultAgentId:r.defaultAgentId,agentItems:ne?.items??[],disabled:re,onChange:(e,t)=>y(`telegram`,e,t),ch:n}),(0,R.jsxs)(d,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:()=>s(e=>!e),children:[(0,R.jsx)(E,{className:u(`mr-1 size-4 transition-transform`,a&&`rotate-180`)}),a?n.advancedHide:n.advancedShow]}),a?(0,R.jsx)(De,{tg:F,updateTelegram:v,ch:n,dmOpts:A,groupOpts:M,replyOpts:P,streamOpts:te,tgAccountsDraft:C,setTgAccountsDraft:T,tgAccountsError:D,onTgAccountsBlur:O}):null]}),(0,R.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,R.jsx)(d,{type:`button`,variant:`secondary`,onClick:()=>t(!1),children:n.modalCancel}),(0,R.jsx)(d,{type:`button`,variant:`secondary`,disabled:!ie||re,onClick:se,children:n.discard}),(0,R.jsx)(d,{type:`button`,variant:`primary`,disabled:!ie||re,onClick:async()=>{await oe()&&t(!1)},children:re?n.saving:n.save})]})]})]})})}function ke(){let e=s(e=>e.language),t=O(e),n=t.channelsSettings,i=!!ne(e=>e.token),[a,o]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[ee,te]=(0,Q.useState)(!1),[re,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(``),[z,B]=(0,Q.useState)(``),[V,H]=(0,Q.useState)(``),[le,U]=(0,Q.useState)(``),[ue,W]=(0,Q.useState)(``),[de,G]=(0,Q.useState)(``),{data:fe}=r(i?`gateway-chat-agents-ch`:null,C,{revalidateOnFocus:!1}),{data:K,error:q,isLoading:me,mutate:he}=c(i),J=(0,Q.useMemo)(()=>K?.payload?.config===void 0?null:be(K.payload.config),[K]),Y=(0,Q.useMemo)(()=>!a||!l?!1:JSON.stringify(a)!==JSON.stringify(l),[a,l]);(0,Q.useEffect)(()=>{if(!i){o(null),u(null);return}J!==null&&(Y||(o(J),u(structuredClone(J)),R(JSON.stringify(J.telegram.accounts??{},null,2)),B(``),H(JSON.stringify(J.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(J.feishu?.accounts??{},null,2)),G(``),g(!1)))},[i,J,Y]);let X=!!(i&&me&&K===void 0&&!q),Z=q instanceof Error?q.message:q?String(q):null,ge=(0,Q.useCallback)((e,t,n)=>{o(r=>{if(!r)return null;let i=e===`telegram`?`telegram`:e===`weixin`?`weixin`:`feishu`;return{...r,channelAgentRoutes:{...r.channelAgentRoutes,[i]:{...r.channelAgentRoutes[i],[t]:n.trim().toLowerCase()}}}})},[]),_e=(0,Q.useCallback)(e=>{o(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),ve=(0,Q.useCallback)(e=>{o(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),$=(0,Q.useCallback)(e=>{o(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]);return{language:e,m:t,ch:n,hasToken:i,loading:X,fetchError:Z,mutate:he,form:a,baseline:l,dirty:Y,saving:d,error:p,saveOk:h,weixinModalOpen:_,setWeixinModalOpen:v,telegramModalOpen:y,setTelegramModalOpen:b,feishuModalOpen:x,setFeishuModalOpen:S,removeTarget:w,setRemoveTarget:T,weixinSuccessBanner:E,setWeixinSuccessBanner:D,feishuSetupSuccessBanner:k,tgAdvanced:j,setTgAdvanced:M,showToken:N,setShowToken:P,showFeishuSecret:ee,setShowFeishuSecret:te,showFeishuWebhookSecrets:re,setShowFeishuWebhookSecrets:ie,copied:ae,feishuCopied:se,feishuWebhookCopied:F,tgAccountsDraft:L,setTgAccountsDraft:R,tgAccountsError:z,wxAccountsDraft:V,setWxAccountsDraft:H,wxAccountsError:le,feishuAccountsDraft:ue,setFeishuAccountsDraft:W,feishuAccountsError:de,chatAgents:fe,updateChannelAgentRoute:ge,updateTelegram:_e,updateWeixin:ve,updateFeishu:$,save:(0,Q.useCallback)(async()=>{if(!a||d)return!1;f(!0),m(null),g(!1);try{let e=await Ce(a);o(e);let t=structuredClone(e);return u(t),R(JSON.stringify(t.telegram.accounts??{},null,2)),B(``),H(JSON.stringify(t.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(t.feishu?.accounts??{},null,2)),G(``),g(!0),window.setTimeout(()=>g(!1),2500),!0}catch(e){return m(e instanceof Error?e.message:n.saveError),!1}finally{f(!1)}},[a,d,n.saveError]),discard:(0,Q.useCallback)(()=>{if(!l)return;let e=structuredClone(l);o(e),R(JSON.stringify(e.telegram.accounts??{},null,2)),B(``),H(JSON.stringify(e.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(e.feishu?.accounts??{},null,2)),G(``),m(null),g(!1)},[l]),toggleChannelEnabled:(0,Q.useCallback)(async(e,t)=>{if(!a||d)return;let r=a,i=e===`weixin`?{...a,weixin:{...a.weixin,enabled:t}}:e===`telegram`?{...a,telegram:{...a.telegram,enabled:t}}:{...a,feishu:{...a.feishu,enabled:t}};o(i),f(!0),m(null);try{let e=await Ce(i);o(e);let t=structuredClone(e);u(t),R(JSON.stringify(t.telegram.accounts??{},null,2)),H(JSON.stringify(t.weixin.accounts??{},null,2)),W(JSON.stringify(t.feishu?.accounts??{},null,2))}catch(e){m(e instanceof Error?e.message:n.saveError),o(r)}finally{f(!1)}},[a,d,n.saveError]),removeChannel:(0,Q.useCallback)(async()=>{if(!a||!w||d)return;let e=ye(),t=w===`weixin`?{...a,weixin:e.weixin}:w===`telegram`?{...a,telegram:e.telegram}:{...a,feishu:e.feishu};f(!0),m(null);try{let e=await Ce(t);o(e);let n=structuredClone(e);u(n),R(JSON.stringify(n.telegram.accounts??{},null,2)),H(JSON.stringify(n.weixin.accounts??{},null,2)),B(``),U(``),W(JSON.stringify(n.feishu?.accounts??{},null,2)),G(``),T(null),g(!0),window.setTimeout(()=>g(!1),2500)}catch(e){m(e instanceof Error?e.message:n.saveError)}finally{f(!1)}},[a,w,d,n.saveError]),copyToken:(0,Q.useCallback)(async()=>{let e=a?pe(a.telegram):``;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),oe(!0),window.setTimeout(()=>oe(!1),2e3))},[a]),handleFeishuQrSetupSuccess:(0,Q.useCallback)(e=>{$({appId:e.appId,domain:e.domain,enabled:!0}),he(),A(n.feishuQrSetupSuccess),window.setTimeout(()=>A(null),4e3)},[$,he,n.feishuQrSetupSuccess]),copyFeishuSecret:(0,Q.useCallback)(async()=>{let e=a?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),ce(!0),window.setTimeout(()=>ce(!1),2e3))},[a]),copyFeishuWebhookConfig:(0,Q.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(()=>{}),I(!0),window.setTimeout(()=>I(!1),2e3)},[a]),onTgAccountsBlur:(0,Q.useCallback)(()=>{if(!a)return;let e=L.trim();if(!e){_e({accounts:{}}),B(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);_e({accounts:t}),B(``)}catch(e){B(e instanceof Error?e.message:n.jsonInvalid)}},[a,L,_e,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,Q.useCallback)(()=>{if(!a)return;let e=V.trim();if(!e){ve({accounts:{}}),U(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);ve({accounts:t}),U(``)}catch(e){U(e instanceof Error?e.message:n.jsonInvalid)}},[a,V,ve,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,Q.useCallback)(()=>{if(!a)return;let e=ue.trim();if(!e){$({accounts:{}}),G(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);$({accounts:t}),G(``)}catch(e){G(e instanceof Error?e.message:n.jsonInvalid)}},[a,ue,$,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,Q.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,Q.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,Q.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,Q.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}function Ae({open:e,onOpenChange:t,ch:n,onLoginSuccess:r,moreSettings:i}){let[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),O=(0,Q.useCallback)(async()=>{b(null),S(null),l(null),s(!0);try{let e=await xe();v(e.qrcodeUrl),l(e.sessionKey)}catch(e){b(e instanceof Error?e.message:`Start failed`)}finally{s(!1)}},[]);(0,Q.useEffect)(()=>{if(!e){l(null),v(null),b(null),T(null),D(!1),S(null);return}O()},[e,O]),(0,Q.useEffect)(()=>{if(!c)return;let e=!1,i,a=async()=>{try{let a=await Se(c);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),l(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`),l(null),v(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[c,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,Q.useEffect)(()=>{if(!_){T(null),D(!1);return}let e=!1;return D(!1),ve.toDataURL(_,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||T(t)}).catch(()=>{e||(D(!0),T(null))}),()=>{e=!0}},[_]);let A=!!(_&&c),M=e&&!y&&!A;return(0,R.jsx)(p,{open:e,onOpenChange:t,children:(0,R.jsxs)(f,{children:[(0,R.jsx)(k,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,R.jsxs)(j,{className:u(`fixed left-1/2 top-1/2 max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,N,`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,R.jsx)(m,{asChild:!0,children:(0,R.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,R.jsx)(ae,{className:`size-4`})})}),(0,R.jsx)(h,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,R.jsx)(o,{className:`sr-only`,children:n.weixinQrModalSubtitle}),(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.weixinQrModalTitle}),(0,R.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.weixinQrModalSubtitle})]}),(0,R.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[y?(0,R.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:y}):null,!y&&(A||M)?(0,R.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,R.jsx)(`p`,{className:u(`min-h-[1.25rem] text-center text-sm`,x&&!M?`text-accent`:`text-fg-muted`),children:M?n.weixinQrLoginBusy:x??`\xA0`}),(0,R.jsxs)(`div`,{className:u(`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,R.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,A&&_&&!y&&C&&!E?(0,R.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,A&&_&&!y&&!C&&!E&&!M?(0,R.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,A&&_&&!y&&E?(0,R.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,R.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.weixinQrImageError}),(0,R.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,R.jsx)(g,{className:`size-3 shrink-0`}),n.weixinQrOpenLink]})]}):null]})]}):null]}),(0,R.jsx)(`div`,{className:`mt-6`,children:(0,R.jsx)(d,{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:a,onClick:()=>void O(),children:a?n.weixinQrLoginBusy:n.weixinQrRegenerate})}),i?(0,R.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function je({wx:e,updateWeixin:t,ch:n,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,channelAgentRoutesWx:l,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}){let h=G;return(0,R.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.weixinAllowFrom}),(0,R.jsx)(`textarea`,{className:u(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,R.jsx)(X,{children:n.weixinAllowFromDesc})]}),(0,R.jsx)(Z,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,R.jsx)(Z,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:i}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.historyLimit}),(0,R.jsx)(`input`,{type:`number`,min:10,max:200,className:h(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.textChunkLimit}),(0,R.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,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.weixinRouteTag}),(0,R.jsx)(`input`,{className:h(),value:e.routeTag,onChange:e=>t({routeTag:e.target.value}),placeholder:n.routeTagPlaceholder}),(0,R.jsx)(X,{children:n.weixinRouteTagDesc})]}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.weixinDebug]}),(0,R.jsx)(X,{children:n.weixinDebugDesc}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(Y,{children:n.weixinAccountsJson}),(0,R.jsx)(`textarea`,{className:u(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,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:s}):(0,R.jsx)(X,{children:n.weixinAccountsJsonDesc})]}),(0,R.jsx)(ge,{accountIds:U(e),routes:l,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:n})]})}function Me({ch:e,wx:t,updateWeixin:n,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,form:l,chatAgents:u,onAgentRouteChange:f,saving:p,dirty:m,save:h,discard:g}){return(0,R.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,R.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,R.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,R.jsx)(E,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),e.advancedShow]})}),(0,R.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.weixinAdvancedHint}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:t.enabled,onChange:e=>n({enabled:e.target.checked})}),(0,R.jsx)(`span`,{children:e.enableWeixinAria})]}),(0,R.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,R.jsx)(je,{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:f,routingDisabled:p})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[(0,R.jsx)(d,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:!m||p,onClick:g,children:e.discard}),(0,R.jsx)(d,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!m||p,onClick:async()=>{await h()},children:p?e.saving:e.save})]})]})]})}function Ne(){let{language:e,m:t,ch:n,hasToken:r,loading:i,fetchError:a,mutate:o,form:s,baseline:c,dirty:l,saving:u,error:f,saveOk:p,weixinModalOpen:m,setWeixinModalOpen:h,telegramModalOpen:_,setTelegramModalOpen:v,feishuModalOpen:b,setFeishuModalOpen:x,removeTarget:S,setRemoveTarget:C,weixinSuccessBanner:w,setWeixinSuccessBanner:T,feishuSetupSuccessBanner:E,tgAdvanced:D,setTgAdvanced:O,showToken:k,setShowToken:A,showFeishuSecret:j,setShowFeishuSecret:M,showFeishuWebhookSecrets:N,setShowFeishuWebhookSecrets:P,copied:ee,feishuCopied:ne,feishuWebhookCopied:re,tgAccountsDraft:ae,setTgAccountsDraft:oe,tgAccountsError:se,wxAccountsDraft:ce,setWxAccountsDraft:F,wxAccountsError:I,feishuAccountsDraft:L,setFeishuAccountsDraft:V,feishuAccountsError:H,chatAgents:le,updateChannelAgentRoute:U,updateTelegram:ue,updateWeixin:W,updateFeishu:de,save:G,discard:fe,toggleChannelEnabled:K,removeChannel:q,copyToken:pe,handleFeishuQrSetupSuccess:Y,copyFeishuSecret:X,copyFeishuWebhookConfig:Z,onTgAccountsBlur:ge,onWxAccountsBlur:Q,onFeishuAccountsBlur:ve,dmOpts:$,groupOpts:ye,replyOpts:be,streamOpts:xe}=ke();if(!r)return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.channels}),(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]});if(i)return(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,R.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,R.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,R.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:n.loading})]});if(!s)return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f??a??n.loadError}),(0,R.jsx)(d,{type:`button`,variant:`secondary`,onClick:()=>void o(),children:n.retry})]});let Se=s.weixin,Ce=s.telegram,we=s.feishu,Te=he(Se),De=me(Ce),je=J(we),Ne=(0,R.jsx)(_e,{ch:n,form:s,baseline:c,showFeishuSecret:j,setShowFeishuSecret:M,showFeishuWebhookSecrets:N,setShowFeishuWebhookSecrets:P,feishuCopied:ne,feishuWebhookCopied:re,copyFeishuSecret:X,copyFeishuWebhookConfig:Z,updateFeishu:de,updateChannelAgentRoute:U,feishuAccountsDraft:L,setFeishuAccountsDraft:V,feishuAccountsError:H,onFeishuAccountsBlur:ve,dmOpts:$,groupOpts:ye,chatAgents:le,saving:u,dirty:l,save:G,discard:fe}),Pe=(0,R.jsx)(Me,{ch:n,wx:Se,updateWeixin:W,dmOpts:$,streamOpts:xe,wxAccountsDraft:ce,setWxAccountsDraft:F,wxAccountsError:I,onWxAccountsBlur:Q,form:s,chatAgents:le,onAgentRouteChange:(e,t)=>U(`weixin`,e,t),saving:u,dirty:l,save:G,discard:fe});return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.channels}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,R.jsxs)(`a`,{href:ie(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,R.jsx)(g,{className:`size-3.5`})]})]}),l?(0,R.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,p?(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.saved}):null,f?(0,R.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}):null,w?(0,R.jsx)(`p`,{className:`text-xs text-accent`,children:w}):null,E?(0,R.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:E}):null,(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(z,{icon:(0,R.jsx)(y,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.weixinTitle,subtitle:n.weixinSubtitle,configured:Te,enabled:Se.enabled,toggleDisabled:u,onToggle:e=>void K(`weixin`,e),onConfigure:()=>h(!0),onEdit:()=>h(!0),onRemove:()=>C(`weixin`),ch:n}),(0,R.jsx)(z,{icon:(0,R.jsx)(te,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.telegramTitle,subtitle:n.telegramSubtitle,configured:De,enabled:Ce.enabled,toggleDisabled:u,onToggle:e=>void K(`telegram`,e),onConfigure:()=>v(!0),onEdit:()=>v(!0),onRemove:()=>C(`telegram`),ch:n}),(0,R.jsx)(z,{icon:(0,R.jsx)(y,{className:`size-6 text-accent`,strokeWidth:1.75}),title:n.feishuTitle,subtitle:n.feishuSubtitle,configured:je,enabled:we.enabled,toggleDisabled:u,onToggle:e=>void K(`feishu`,e),onConfigure:()=>x(!0),onEdit:()=>x(!0),onRemove:()=>C(`feishu`),ch:n})]}),(0,R.jsx)(Ae,{open:m,onOpenChange:h,ch:n,onLoginSuccess:async()=>{await o(),T(n.weixinQrLoginSuccess),window.setTimeout(()=>T(null),4e3)},moreSettings:Pe}),(0,R.jsx)(Oe,{open:_,onOpenChange:v,ch:n,form:s,baseline:c,tgAdvanced:D,setTgAdvanced:O,showToken:k,setShowToken:A,copied:ee,copyToken:pe,updateTelegram:ue,updateChannelAgentRoute:U,tgAccountsDraft:ae,setTgAccountsDraft:oe,tgAccountsError:se,onTgAccountsBlur:ge,dmOpts:$,groupOpts:ye,replyOpts:be,streamOpts:xe,chatAgents:le,saving:u,dirty:l,save:G,discard:fe}),(0,R.jsx)(Ee,{open:b,onOpenChange:x,ch:n,onSetupSuccess:Y,moreSettings:Ne}),(0,R.jsx)(B,{open:S!==null,onOpenChange:e=>{e||C(null)},ch:n,removeTarget:S,onCancel:()=>C(null),saving:u,onConfirmRemove:()=>void q()})]})}export{Ne as ChannelsSettingsPanel};
|
|
2
|
+
//# sourceMappingURL=channels-settings-BtblELP8.js.map
|