@xopcai/xopc 0.0.55 → 0.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agents-74EbWFJ1.js → agents-D6Suddtr.js} +2 -2
- package/dist/gateway/static/root/assets/{agents-74EbWFJ1.js.map → agents-D6Suddtr.js.map} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Drte0W-4.js → apps-page-Th-Hiuo-.js} +2 -2
- package/dist/gateway/static/root/assets/{apps-page-Drte0W-4.js.map → apps-page-Th-Hiuo-.js.map} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-JfEF7kEH.js → channels-settings-D1xRSJDZ.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-settings-JfEF7kEH.js.map → channels-settings-D1xRSJDZ.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-dreaming-jobs-BhOeOExN.js → cron-dreaming-jobs-3lVHkALf.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-dreaming-jobs-BhOeOExN.js.map → cron-dreaming-jobs-3lVHkALf.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-Cj2srMp3.js → cron-page-D7ngje2B.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-page-Cj2srMp3.js.map → cron-page-D7ngje2B.js.map} +1 -1
- package/dist/gateway/static/root/assets/{dist-DSj9MpxJ.js → dist-zjjnuQDo.js} +2 -2
- package/dist/gateway/static/root/assets/{dist-DSj9MpxJ.js.map → dist-zjjnuQDo.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-B9dAkTLR.js → extension-debug-page-D1j5i5LL.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-debug-page-B9dAkTLR.js.map → extension-debug-page-D1j5i5LL.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CosLqD45.js → extension-page-DFlhHkSt.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-page-CosLqD45.js.map → extension-page-DFlhHkSt.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BnJUuHga.js → extension-settings-page-BCa14gKB.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-settings-page-BnJUuHga.js.map → extension-settings-page-BCa14gKB.js.map} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-DKiU0FSn.js → heartbeat-config-api-D_OCqL2O.js} +2 -2
- package/dist/gateway/static/root/assets/{heartbeat-config-api-DKiU0FSn.js.map → heartbeat-config-api-D_OCqL2O.js.map} +1 -1
- package/dist/gateway/static/root/assets/{index-B-L6DMBk.js → index-DzugsTKg.js} +4 -4
- package/dist/gateway/static/root/assets/{index-B-L6DMBk.js.map → index-DzugsTKg.js.map} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BVDgS2FD.js → logs-page-DlOnVTqZ.js} +2 -2
- package/dist/gateway/static/root/assets/{logs-page-BVDgS2FD.js.map → logs-page-DlOnVTqZ.js.map} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-C-OAYLwZ.js → sessions-page-CdvV35AY.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-C-OAYLwZ.js.map → sessions-page-CdvV35AY.js.map} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-PgUZ4C2F.js → settings-page-DKWTjEWN.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-PgUZ4C2F.js.map → settings-page-DKWTjEWN.js.map} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-BJ4k9_us.js → skills-page-xq8DLd0E.js} +2 -2
- package/dist/gateway/static/root/assets/{skills-page-BJ4k9_us.js.map → skills-page-xq8DLd0E.js.map} +1 -1
- package/dist/gateway/static/root/assets/{use-image-provider-credentials-OhVruFpB.js → use-image-provider-credentials-DEpLWx8J.js} +2 -2
- package/dist/gateway/static/root/assets/{use-image-provider-credentials-OhVruFpB.js.map → use-image-provider-credentials-DEpLWx8J.js.map} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/service.js.map +1 -1
- 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{An as i,At as a,Dt as o,En as s,In as c,Kn as l,Mt as u,Nt as d,On as f,Ot as p,Qr as m,Rn as h,Sn as g,St as _,Xr as v,Yr as y,Zr as b,_n as x,br as S,c as C,gi as w,hi as T,hn as E,jn as D,jt as O,kn as k,kt as A,ni as j,o as M,or as N,s as P,un as F,vn as ee,w as te,wr as ne,xt as re,yt as ie}from"./index-B-L6DMBk.js";import{a as ae,i as oe,n as se,r as I,t as ce}from"./dist-DSj9MpxJ.js";import{t as L}from"./browser-DNXWYwzc.js";var R=n();function le({icon:e,title:t,subtitle:n,configured:r,enabled:i,onToggle:a,toggleDisabled:o,onConfigure:s,onEdit:u,onRemove:d,ch:f}){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:f.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)(oe,{children:[(0,R.jsx)(ae,{asChild:!0,children:(0,R.jsx)(D,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":f.menuMoreAria,children:(0,R.jsx)(m,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,R.jsx)(I,{children:(0,R.jsxs)(ce,{className:c(`min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,C),sideOffset:6,align:`end`,children:[(0,R.jsx)(se,{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:()=>u(),children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(S,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),f.menuEditConfig]})}),(0,R.jsx)(se,{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:()=>d(),children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(l,{className:`size-4 shrink-0`,strokeWidth:1.75}),f.menuRemoveConfig]})})]})})]}),(0,R.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} — ${f.enableChannelAria}`,disabled:o,className:c(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,i?`justify-end bg-accent`:`justify-start bg-surface-hover`,o&&`cursor-not-allowed opacity-50`),onClick:()=>void a(!i),children:(0,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:s,children:f.hubConfigureButton})})]})}function z({open:e,onOpenChange:t,ch:n,removeTarget:r,onCancel:i,saving:o,onConfirmRemove:s}){return(0,R.jsx)(u,{open:e,onOpenChange:t,children:(0,R.jsxs)(O,{children:[(0,R.jsx)(a,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,P)}),(0,R.jsxs)(p,{className:c(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,M,`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)(d,{className:`text-base font-semibold text-fg`,children:n.removeChannelTitle}),(0,R.jsx)(A,{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:o,onClick:s,children:o?n.saving:n.removeChannelAction})]})]})]})})}function B(e){return(e??``).trim().toLowerCase()}function V(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 H(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=>B(e.match?.channel)===`telegram`&&B(e.match?.accountId)===B(n)&&V(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>B(e.match?.channel)===`weixin`&&B(e.match?.accountId)===B(t)&&V(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>B(e.match?.channel)===`feishu`&&B(e.match?.accountId)===B(t)&&V(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(B)),s=new Set(r.map(B)),c=new Set(i.map(B)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!V(e))return!0;let t=B(e.match.channel),n=B(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[B(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[B(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[B(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 c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k,`dark:border-edge`)}function fe(){return c(f,s)}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:a,onChange:o,ch:l}){let u=i(g(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:l.agentRoutingTitle}),(0,R.jsx)(X,{children:l.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:l.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:l.agentRoutingAgentLabel}),(0,R.jsx)(`select`,{id:`agent-route-${e}`,className:c(G(),s),disabled:a,value:(t[e]??n).toLowerCase(),onChange:t=>o(e,t.target.value),children:d.map(e=>(0,R.jsx)(`option`,{value:e.id,children:`${te(e,u)} (${e.id})`},e.id))})]})]},e))})]})}function _e({ch:e,form:t,baseline:n,showFeishuSecret:r,setShowFeishuSecret:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuCopied:s,feishuWebhookCopied:l,copyFeishuSecret:u,copyFeishuWebhookConfig:d,updateFeishu:f,updateChannelAgentRoute:p,feishuAccountsDraft:m,setFeishuAccountsDraft:h,feishuAccountsError:g,onFeishuAccountsBlur:_,dmOpts:b,groupOpts:x,chatAgents:S,saving:C,dirty:E,save:O,discard:k}){let A=G,M=t.feishu,N=n?.feishu?.appSecret??``,P=!r&&!!String(N).trim()&&M.appSecret===N;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)(T,{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:M.enabled,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),value:M.appId,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:r?`text`:`password`,autoComplete:`off`,readOnly:P,value:P?`*`.repeat(Math.max(1,M.appSecret.length)):M.appSecret,onChange:e=>{P||f({appSecret:e.target.value})},placeholder:`••••••••`}),M.appSecret?(0,R.jsxs)(D,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void u(),children:[s?(0,R.jsx)(w,{className:`size-3.5`}):(0,R.jsx)(j,{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)(v,{className:`size-3.5`}):(0,R.jsx)(y,{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(M.domain||`feishu`),onChange:e=>f({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:M.connectionMode,onChange:e=>f({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})]})]}),M.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)(v,{className:`size-3.5`}):(0,R.jsx)(y,{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 d(),children:[l?(0,R.jsx)(w,{className:`size-3.5`}):(0,R.jsx)(j,{className:`size-3.5`}),l?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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:M.verificationToken??``,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:M.encryptKey??``,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),value:M.webhookHost??``,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(M.webhookPort??``),onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),value:M.webhookPath??``,onChange:e=>f({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:M.renderMode,onChange:e=>f({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:M.reactionNotifications,onChange:e=>f({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:M.streaming,onChange:e=>f({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:M.dmPolicy,onChange:e=>f({dmPolicy:e.target.value}),children:b.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:M.groupPolicy,onChange:e=>f({groupPolicy:e.target.value}),children:x.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:M.requireMention,onChange:e=>f({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:c(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`ou_xxx, on_xxx`,value:q(M.allowFrom),onChange:e=>f({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:c(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`oc_xxx, oc_yyy`,value:q(M.groupAllowFrom),onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(M.historyLimit),onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(M.textChunkLimit),onChange:e=>f({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:!!M.tools?.[e],onChange:t=>f({tools:{...M.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:!!M.actions?.reactions,onChange:e=>f({actions:{...M.actions,reactions:e.target.checked}})}),e.feishuActionReactions]})]}),(0,R.jsx)(ge,{accountIds:ue(M),routes:t.channelAgentRoutes.feishu,defaultAgentId:t.defaultAgentId,agentItems:S?.items??[],disabled:C,onChange:(e,t)=>p(`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:c(A(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:m,onChange:e=>h(e.target.value),onBlur:_,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),g?(0,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:g}):(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:!E||C,onClick:k,children:e.discard}),(0,R.jsx)(D,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!E||C,onClick:async()=>{await O()},children:C?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,H(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 E(F(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Se(e){return(await E(F(`/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,H(t),U(n),ue(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await E(F(`/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 re(),o?be(o):{...e,bindingsFull:i}}async function we(e){return(await E(F(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Te(e){return(await E(F(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function Ee({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:i}){let[s,l]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(`feishu`),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),k=(0,Q.useCallback)(async e=>{m(e),S(null),_(null),y(null),l(!0);try{let t=await we({domain:e});y(t.qrUrl),_(t.sessionKey)}catch(e){S(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,Q.useEffect)(()=>{if(!e){_(null),y(null),S(null),w(null),E(!1),m(`feishu`),l(!1);return}k(`feishu`)},[e,k]),(0,Q.useEffect)(()=>{if(!g)return;let e=!1,n,i=async()=>{try{let i=await Te(g);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),_(null),i.ok?(y(null),t(!1),r({appId:i.appId,domain:i.domain,openId:i.openId})):(S(i.message),y(null));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),S(i.message),_(null),y(null))}catch(t){e||(n!==void 0&&window.clearInterval(n),S(t instanceof Error?t.message:`Request failed`),_(null),y(null))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[g,t,r]),(0,Q.useEffect)(()=>{if(!v){w(null),E(!1);return}let e=!1;return E(!1),ve.toDataURL(v,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||w(t)}).catch(()=>{e||(E(!0),w(null))}),()=>{e=!0}},[v]);let j=!!(v&&g),N=e,F=e&&!x&&!j;return(0,R.jsx)(u,{open:e,onOpenChange:t,children:(0,R.jsxs)(O,{children:[(0,R.jsx)(a,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,P)}),(0,R.jsxs)(p,{className:c(`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`,M,`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)(o,{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)(h,{className:`size-4`})})}),(0,R.jsx)(d,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,R.jsx)(A,{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&&(j||F)?(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:F?n.feishuQrStarting:n.feishuQrScanHint}),(0,R.jsxs)(`div`,{className:c(`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`,F&&`bg-surface-muted/40 dark:bg-surface-base`),children:[F?(0,R.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,j&&v&&!x&&C&&!T?(0,R.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,j&&v&&!x&&!C&&!T&&!F?(0,R.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,j&&v&&!x&&T?(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:v,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,R.jsx)(b,{className:`size-3 shrink-0`}),n.feishuQrOpenLink]})]}):null]})]}):null]}),N?(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:s,className:c(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,f===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void k(`feishu`),children:n.feishuRegionChina}),(0,R.jsx)(`button`,{type:`button`,disabled:s,className:c(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,f===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void k(`lark`),children:n.feishuRegionInternational})]})}):null,(0,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:s,onClick:()=>void k(f),children:s?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:l,tgAccountsError:u,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:c(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:c(f(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:s,onChange:e=>l(e.target.value),onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),u?(0,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,R.jsx)(X,{children:n.multiAccountJsonDesc})]})]})}function Oe({open:e,onOpenChange:t,ch:n,form:r,baseline:i,tgAdvanced:s,setTgAdvanced:l,showToken:f,setShowToken:m,copied:g,copyToken:_,updateTelegram:b,updateChannelAgentRoute:x,tgAccountsDraft:S,setTgAccountsDraft:C,tgAccountsError:E,onTgAccountsBlur:k,dmOpts:N,groupOpts:F,replyOpts:ee,streamOpts:te,chatAgents:ne,saving:re,dirty:ie,save:ae,discard:oe}){let se=G,I=r.telegram,ce=i?pe(i.telegram):``,L=pe(I),le=!f&&!!String(ce).trim()&&L===ce;return(0,R.jsx)(u,{open:e,onOpenChange:t,children:(0,R.jsxs)(O,{children:[(0,R.jsx)(a,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,P)}),(0,R.jsxs)(p,{className:c(`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`,M,`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)(d,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.telegramTitle}),(0,R.jsx)(A,{className:`mt-1 text-sm text-fg-muted`,children:n.telegramSubtitle})]}),(0,R.jsx)(o,{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)(h,{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:I.enabled,onChange:e=>b({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:c(se(),`min-w-0 flex-1 font-mono text-xs`),type:f?`text`:`password`,autoComplete:`off`,readOnly:le,value:le?`*`.repeat(Math.max(1,ce.length)):L,onChange:e=>{if(le)return;let t=I.accounts?.default??$(`default`);b({accounts:{...I.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)(w,{className:`size-3.5`}):(0,R.jsx)(j,{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:()=>m(e=>!e),children:[f?(0,R.jsx)(v,{className:`size-3.5`}):(0,R.jsx)(y,{className:`size-3.5`}),f?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:c(se(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`123456789, 987654321`,value:q(I.allowFrom),onChange:e=>b({allowFrom:K(e.target.value)})}),(0,R.jsx)(X,{children:n.allowFromDmDesc})]}),(0,R.jsx)(ge,{accountIds:H(I),routes:r.channelAgentRoutes.telegram,defaultAgentId:r.defaultAgentId,agentItems:ne?.items??[],disabled:re,onChange:(e,t)=>x(`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:()=>l(e=>!e),children:[(0,R.jsx)(T,{className:c(`mr-1 size-4 transition-transform`,s&&`rotate-180`)}),s?n.advancedHide:n.advancedShow]}),s?(0,R.jsx)(De,{tg:I,updateTelegram:b,ch:n,dmOpts:N,groupOpts:F,replyOpts:ee,streamOpts:te,tgAccountsDraft:S,setTgAccountsDraft:C,tgAccountsError:E,onTgAccountsBlur:k}):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:oe,children:n.discard}),(0,R.jsx)(D,{type:`button`,variant:`primary`,disabled:!ie||re,onClick:async()=>{await ae()&&t(!1)},children:re?n.saving:n.save})]})]})]})})}function ke(){let e=g(e=>e.language),t=i(e),n=t.channelsSettings,a=!!x(e=>e.token),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,ee]=(0,Q.useState)(!1),[te,ne]=(0,Q.useState)(!1),[re,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),[I,ce]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(``),[le,z]=(0,Q.useState)(``),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(``),[ue,W]=(0,Q.useState)(``),[de,G]=(0,Q.useState)(``),{data:fe}=r(a?`gateway-chat-agents-ch`:null,ie,{revalidateOnFocus:!1}),{data:K,error:q,isLoading:me,mutate:he}=_(a),J=(0,Q.useMemo)(()=>K?.payload?.config===void 0?null:be(K.payload.config),[K]),Y=(0,Q.useMemo)(()=>!o||!c?!1:JSON.stringify(o)!==JSON.stringify(c),[o,c]);(0,Q.useEffect)(()=>{if(!a){s(null),l(null);return}J!==null&&(Y||(s(J),l(structuredClone(J)),R(JSON.stringify(J.telegram.accounts??{},null,2)),z(``),V(JSON.stringify(J.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(J.feishu?.accounts??{},null,2)),G(``),h(!1)))},[a,J,Y]);let X=!!(a&&me&&K===void 0&&!q),Z=q instanceof Error?q.message:q?String(q):null,ge=(0,Q.useCallback)((e,t,n)=>{s(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=>{s(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),ve=(0,Q.useCallback)(e=>{s(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),$=(0,Q.useCallback)(e=>{s(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]);return{language:e,m:t,ch:n,hasToken:a,loading:X,fetchError:Z,mutate:he,form:o,baseline:c,dirty:Y,saving:u,error:f,saveOk:m,weixinModalOpen:v,setWeixinModalOpen:y,telegramModalOpen:b,setTelegramModalOpen:S,feishuModalOpen:C,setFeishuModalOpen:w,removeTarget:T,setRemoveTarget:E,weixinSuccessBanner:D,setWeixinSuccessBanner:O,feishuSetupSuccessBanner:k,tgAdvanced:j,setTgAdvanced:M,showToken:N,setShowToken:P,showFeishuSecret:F,setShowFeishuSecret:ee,showFeishuWebhookSecrets:te,setShowFeishuWebhookSecrets:ne,copied:re,feishuCopied:oe,feishuWebhookCopied:I,tgAccountsDraft:L,setTgAccountsDraft:R,tgAccountsError:le,wxAccountsDraft:B,setWxAccountsDraft:V,wxAccountsError:H,feishuAccountsDraft:ue,setFeishuAccountsDraft:W,feishuAccountsError:de,chatAgents:fe,updateChannelAgentRoute:ge,updateTelegram:_e,updateWeixin:ve,updateFeishu:$,save:(0,Q.useCallback)(async()=>{if(!o||u)return!1;d(!0),p(null),h(!1);try{let e=await Ce(o);s(e);let t=structuredClone(e);return l(t),R(JSON.stringify(t.telegram.accounts??{},null,2)),z(``),V(JSON.stringify(t.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(t.feishu?.accounts??{},null,2)),G(``),h(!0),window.setTimeout(()=>h(!1),2500),!0}catch(e){return p(e instanceof Error?e.message:n.saveError),!1}finally{d(!1)}},[o,u,n.saveError]),discard:(0,Q.useCallback)(()=>{if(!c)return;let e=structuredClone(c);s(e),R(JSON.stringify(e.telegram.accounts??{},null,2)),z(``),V(JSON.stringify(e.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(e.feishu?.accounts??{},null,2)),G(``),p(null),h(!1)},[c]),toggleChannelEnabled:(0,Q.useCallback)(async(e,t)=>{if(!o||u)return;let r=o,i=e===`weixin`?{...o,weixin:{...o.weixin,enabled:t}}:e===`telegram`?{...o,telegram:{...o.telegram,enabled:t}}:{...o,feishu:{...o.feishu,enabled:t}};s(i),d(!0),p(null);try{let e=await Ce(i);s(e);let t=structuredClone(e);l(t),R(JSON.stringify(t.telegram.accounts??{},null,2)),V(JSON.stringify(t.weixin.accounts??{},null,2)),W(JSON.stringify(t.feishu?.accounts??{},null,2))}catch(e){p(e instanceof Error?e.message:n.saveError),s(r)}finally{d(!1)}},[o,u,n.saveError]),removeChannel:(0,Q.useCallback)(async()=>{if(!o||!T||u)return;let e=ye(),t=T===`weixin`?{...o,weixin:e.weixin}:T===`telegram`?{...o,telegram:e.telegram}:{...o,feishu:e.feishu};d(!0),p(null);try{let e=await Ce(t);s(e);let n=structuredClone(e);l(n),R(JSON.stringify(n.telegram.accounts??{},null,2)),V(JSON.stringify(n.weixin.accounts??{},null,2)),z(``),U(``),W(JSON.stringify(n.feishu?.accounts??{},null,2)),G(``),E(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:n.saveError)}finally{d(!1)}},[o,T,u,n.saveError]),copyToken:(0,Q.useCallback)(async()=>{let e=o?pe(o.telegram):``;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),ae(!0),window.setTimeout(()=>ae(!1),2e3))},[o]),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=o?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),se(!0),window.setTimeout(()=>se(!1),2e3))},[o]),copyFeishuWebhookConfig:(0,Q.useCallback)(async()=>{let e=o?.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(()=>{}),ce(!0),window.setTimeout(()=>ce(!1),2e3)},[o]),onTgAccountsBlur:(0,Q.useCallback)(()=>{if(!o)return;let e=L.trim();if(!e){_e({accounts:{}}),z(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);_e({accounts:t}),z(``)}catch(e){z(e instanceof Error?e.message:n.jsonInvalid)}},[o,L,_e,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,Q.useCallback)(()=>{if(!o)return;let e=B.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)}},[o,B,ve,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,Q.useCallback)(()=>{if(!o)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)}},[o,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[s,l]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),k=(0,Q.useCallback)(async()=>{y(null),S(null),m(null),l(!0);try{let e=await xe();_(e.qrcodeUrl),m(e.sessionKey)}catch(e){y(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,Q.useEffect)(()=>{if(!e){m(null),_(null),y(null),w(null),E(!1),S(null);return}k()},[e,k]),(0,Q.useEffect)(()=>{if(!f)return;let e=!1,i,a=async()=>{try{let a=await Se(f);if(e)return;if(a.phase===`polling`){_(a.qrcodeUrl),a.qrStatus===`scaned`?S(n.weixinQrLoginScanned):S(null);return}if(a.phase===`done`){i!==void 0&&(window.clearInterval(i),i=void 0),m(null),a.ok?(_(null),t(!1),await r()):(y(a.message),_(null));return}a.phase===`unknown`&&S(null)}catch(t){e||(i!==void 0&&window.clearInterval(i),y(t instanceof Error?t.message:`Request failed`),m(null),_(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[f,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,Q.useEffect)(()=>{if(!g){w(null),E(!1);return}let e=!1;return E(!1),ve.toDataURL(g,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||w(t)}).catch(()=>{e||(E(!0),w(null))}),()=>{e=!0}},[g]);let j=!!(g&&f),N=e&&!v&&!j;return(0,R.jsx)(u,{open:e,onOpenChange:t,children:(0,R.jsxs)(O,{children:[(0,R.jsx)(a,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,P)}),(0,R.jsxs)(p,{className:c(`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`,M,`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)(o,{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)(h,{className:`size-4`})})}),(0,R.jsx)(d,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,R.jsx)(A,{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:[v?(0,R.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(j||N)?(0,R.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,R.jsx)(`p`,{className:c(`min-h-[1.25rem] text-center text-sm`,x&&!N?`text-accent`:`text-fg-muted`),children:N?n.weixinQrLoginBusy:x??`\xA0`}),(0,R.jsxs)(`div`,{className:c(`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`,N&&`bg-surface-muted/40 dark:bg-surface-base`),children:[N?(0,R.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,j&&g&&!v&&C&&!T?(0,R.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,j&&g&&!v&&!C&&!T&&!N?(0,R.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,j&&g&&!v&&T?(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:g,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,R.jsx)(b,{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:s,onClick:()=>void k(),children:s?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:l,channelAgentRoutesWx:u,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:c(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:c(h(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:a,onChange:e=>o(e.target.value),onBlur:l,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:u,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:d,saving:f,dirty:p,save:m,discard:h}){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)(T,{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:d,routingDisabled:f})}),(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:!p||f,onClick:h,children:e.discard}),(0,R.jsx)(D,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!p||f,onClick:async()=>{await m()},children:f?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:d,saveOk:f,weixinModalOpen:p,setWeixinModalOpen:m,telegramModalOpen:h,setTelegramModalOpen:g,feishuModalOpen:_,setFeishuModalOpen:v,removeTarget:y,setRemoveTarget:x,weixinSuccessBanner:S,setWeixinSuccessBanner:C,feishuSetupSuccessBanner:w,tgAdvanced:T,setTgAdvanced:E,showToken:O,setShowToken:k,showFeishuSecret:A,setShowFeishuSecret:j,showFeishuWebhookSecrets:M,setShowFeishuWebhookSecrets:P,copied:F,feishuCopied:te,feishuWebhookCopied:re,tgAccountsDraft:ie,setTgAccountsDraft:ae,tgAccountsError:oe,wxAccountsDraft:se,setWxAccountsDraft:I,wxAccountsError:ce,feishuAccountsDraft:L,setFeishuAccountsDraft:B,feishuAccountsError:V,chatAgents:H,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:d??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:A,setShowFeishuSecret:j,showFeishuWebhookSecrets:M,setShowFeishuWebhookSecrets:P,feishuCopied:te,feishuWebhookCopied:re,copyFeishuSecret:X,copyFeishuWebhookConfig:Z,updateFeishu:de,updateChannelAgentRoute:U,feishuAccountsDraft:L,setFeishuAccountsDraft:B,feishuAccountsError:V,onFeishuAccountsBlur:ve,dmOpts:$,groupOpts:ye,chatAgents:H,saving:u,dirty:l,save:G,discard:fe}),Pe=(0,R.jsx)(Me,{ch:n,wx:Se,updateWeixin:W,dmOpts:$,streamOpts:xe,wxAccountsDraft:se,setWxAccountsDraft:I,wxAccountsError:ce,onWxAccountsBlur:Q,form:s,chatAgents:H,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:ee(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)(b,{className:`size-3.5`})]})]}),l?(0,R.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,f?(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.saved}):null,d?(0,R.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,S?(0,R.jsx)(`p`,{className:`text-xs text-accent`,children:S}):null,w?(0,R.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:w}):null,(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(le,{icon:(0,R.jsx)(ne,{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:()=>m(!0),onEdit:()=>m(!0),onRemove:()=>x(`weixin`),ch:n}),(0,R.jsx)(le,{icon:(0,R.jsx)(N,{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:()=>g(!0),onEdit:()=>g(!0),onRemove:()=>x(`telegram`),ch:n}),(0,R.jsx)(le,{icon:(0,R.jsx)(ne,{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:()=>v(!0),onEdit:()=>v(!0),onRemove:()=>x(`feishu`),ch:n})]}),(0,R.jsx)(Ae,{open:p,onOpenChange:m,ch:n,onLoginSuccess:async()=>{await o(),C(n.weixinQrLoginSuccess),window.setTimeout(()=>C(null),4e3)},moreSettings:Pe}),(0,R.jsx)(Oe,{open:h,onOpenChange:g,ch:n,form:s,baseline:c,tgAdvanced:T,setTgAdvanced:E,showToken:O,setShowToken:k,copied:F,copyToken:pe,updateTelegram:ue,updateChannelAgentRoute:U,tgAccountsDraft:ie,setTgAccountsDraft:ae,tgAccountsError:oe,onTgAccountsBlur:ge,dmOpts:$,groupOpts:ye,replyOpts:be,streamOpts:xe,chatAgents:H,saving:u,dirty:l,save:G,discard:fe}),(0,R.jsx)(Ee,{open:_,onOpenChange:v,ch:n,onSetupSuccess:Y,moreSettings:Ne}),(0,R.jsx)(z,{open:y!==null,onOpenChange:e=>{e||x(null)},ch:n,removeTarget:y,onCancel:()=>x(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{An as i,At as a,Dt as o,En as s,In as c,Kn as l,Mt as u,Nt as d,On as f,Ot as p,Qr as m,Rn as h,Sn as g,St as _,Xr as v,Yr as y,Zr as b,_n as x,br as S,c as C,gi as w,hi as T,hn as E,jn as D,jt as O,kn as k,kt as A,ni as j,o as M,or as N,s as P,un as F,vn as ee,w as te,wr as ne,xt as re,yt as ie}from"./index-DzugsTKg.js";import{a as ae,i as oe,n as se,r as I,t as ce}from"./dist-zjjnuQDo.js";import{t as L}from"./browser-DNXWYwzc.js";var R=n();function le({icon:e,title:t,subtitle:n,configured:r,enabled:i,onToggle:a,toggleDisabled:o,onConfigure:s,onEdit:u,onRemove:d,ch:f}){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:f.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)(oe,{children:[(0,R.jsx)(ae,{asChild:!0,children:(0,R.jsx)(D,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":f.menuMoreAria,children:(0,R.jsx)(m,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,R.jsx)(I,{children:(0,R.jsxs)(ce,{className:c(`min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,C),sideOffset:6,align:`end`,children:[(0,R.jsx)(se,{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:()=>u(),children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(S,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),f.menuEditConfig]})}),(0,R.jsx)(se,{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:()=>d(),children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(l,{className:`size-4 shrink-0`,strokeWidth:1.75}),f.menuRemoveConfig]})})]})})]}),(0,R.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} — ${f.enableChannelAria}`,disabled:o,className:c(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,i?`justify-end bg-accent`:`justify-start bg-surface-hover`,o&&`cursor-not-allowed opacity-50`),onClick:()=>void a(!i),children:(0,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:s,children:f.hubConfigureButton})})]})}function z({open:e,onOpenChange:t,ch:n,removeTarget:r,onCancel:i,saving:o,onConfirmRemove:s}){return(0,R.jsx)(u,{open:e,onOpenChange:t,children:(0,R.jsxs)(O,{children:[(0,R.jsx)(a,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,P)}),(0,R.jsxs)(p,{className:c(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,M,`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)(d,{className:`text-base font-semibold text-fg`,children:n.removeChannelTitle}),(0,R.jsx)(A,{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:o,onClick:s,children:o?n.saving:n.removeChannelAction})]})]})]})})}function B(e){return(e??``).trim().toLowerCase()}function V(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 H(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=>B(e.match?.channel)===`telegram`&&B(e.match?.accountId)===B(n)&&V(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>B(e.match?.channel)===`weixin`&&B(e.match?.accountId)===B(t)&&V(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>B(e.match?.channel)===`feishu`&&B(e.match?.accountId)===B(t)&&V(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(B)),s=new Set(r.map(B)),c=new Set(i.map(B)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!V(e))return!0;let t=B(e.match.channel),n=B(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[B(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[B(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[B(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 c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k,`dark:border-edge`)}function fe(){return c(f,s)}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:a,onChange:o,ch:l}){let u=i(g(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:l.agentRoutingTitle}),(0,R.jsx)(X,{children:l.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:l.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:l.agentRoutingAgentLabel}),(0,R.jsx)(`select`,{id:`agent-route-${e}`,className:c(G(),s),disabled:a,value:(t[e]??n).toLowerCase(),onChange:t=>o(e,t.target.value),children:d.map(e=>(0,R.jsx)(`option`,{value:e.id,children:`${te(e,u)} (${e.id})`},e.id))})]})]},e))})]})}function _e({ch:e,form:t,baseline:n,showFeishuSecret:r,setShowFeishuSecret:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuCopied:s,feishuWebhookCopied:l,copyFeishuSecret:u,copyFeishuWebhookConfig:d,updateFeishu:f,updateChannelAgentRoute:p,feishuAccountsDraft:m,setFeishuAccountsDraft:h,feishuAccountsError:g,onFeishuAccountsBlur:_,dmOpts:b,groupOpts:x,chatAgents:S,saving:C,dirty:E,save:O,discard:k}){let A=G,M=t.feishu,N=n?.feishu?.appSecret??``,P=!r&&!!String(N).trim()&&M.appSecret===N;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)(T,{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:M.enabled,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),value:M.appId,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:r?`text`:`password`,autoComplete:`off`,readOnly:P,value:P?`*`.repeat(Math.max(1,M.appSecret.length)):M.appSecret,onChange:e=>{P||f({appSecret:e.target.value})},placeholder:`••••••••`}),M.appSecret?(0,R.jsxs)(D,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void u(),children:[s?(0,R.jsx)(w,{className:`size-3.5`}):(0,R.jsx)(j,{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)(v,{className:`size-3.5`}):(0,R.jsx)(y,{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(M.domain||`feishu`),onChange:e=>f({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:M.connectionMode,onChange:e=>f({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})]})]}),M.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)(v,{className:`size-3.5`}):(0,R.jsx)(y,{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 d(),children:[l?(0,R.jsx)(w,{className:`size-3.5`}):(0,R.jsx)(j,{className:`size-3.5`}),l?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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:M.verificationToken??``,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:M.encryptKey??``,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),value:M.webhookHost??``,onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(M.webhookPort??``),onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),value:M.webhookPath??``,onChange:e=>f({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:M.renderMode,onChange:e=>f({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:M.reactionNotifications,onChange:e=>f({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:M.streaming,onChange:e=>f({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:M.dmPolicy,onChange:e=>f({dmPolicy:e.target.value}),children:b.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:M.groupPolicy,onChange:e=>f({groupPolicy:e.target.value}),children:x.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:M.requireMention,onChange:e=>f({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:c(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`ou_xxx, on_xxx`,value:q(M.allowFrom),onChange:e=>f({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:c(A(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`oc_xxx, oc_yyy`,value:q(M.groupAllowFrom),onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(M.historyLimit),onChange:e=>f({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:c(A(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(M.textChunkLimit),onChange:e=>f({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:!!M.tools?.[e],onChange:t=>f({tools:{...M.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:!!M.actions?.reactions,onChange:e=>f({actions:{...M.actions,reactions:e.target.checked}})}),e.feishuActionReactions]})]}),(0,R.jsx)(ge,{accountIds:ue(M),routes:t.channelAgentRoutes.feishu,defaultAgentId:t.defaultAgentId,agentItems:S?.items??[],disabled:C,onChange:(e,t)=>p(`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:c(A(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:m,onChange:e=>h(e.target.value),onBlur:_,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),g?(0,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:g}):(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:!E||C,onClick:k,children:e.discard}),(0,R.jsx)(D,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!E||C,onClick:async()=>{await O()},children:C?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,H(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 E(F(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Se(e){return(await E(F(`/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,H(t),U(n),ue(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await E(F(`/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 re(),o?be(o):{...e,bindingsFull:i}}async function we(e){return(await E(F(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Te(e){return(await E(F(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function Ee({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:i}){let[s,l]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(`feishu`),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),k=(0,Q.useCallback)(async e=>{m(e),S(null),_(null),y(null),l(!0);try{let t=await we({domain:e});y(t.qrUrl),_(t.sessionKey)}catch(e){S(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,Q.useEffect)(()=>{if(!e){_(null),y(null),S(null),w(null),E(!1),m(`feishu`),l(!1);return}k(`feishu`)},[e,k]),(0,Q.useEffect)(()=>{if(!g)return;let e=!1,n,i=async()=>{try{let i=await Te(g);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),_(null),i.ok?(y(null),t(!1),r({appId:i.appId,domain:i.domain,openId:i.openId})):(S(i.message),y(null));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),S(i.message),_(null),y(null))}catch(t){e||(n!==void 0&&window.clearInterval(n),S(t instanceof Error?t.message:`Request failed`),_(null),y(null))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[g,t,r]),(0,Q.useEffect)(()=>{if(!v){w(null),E(!1);return}let e=!1;return E(!1),ve.toDataURL(v,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||w(t)}).catch(()=>{e||(E(!0),w(null))}),()=>{e=!0}},[v]);let j=!!(v&&g),N=e,F=e&&!x&&!j;return(0,R.jsx)(u,{open:e,onOpenChange:t,children:(0,R.jsxs)(O,{children:[(0,R.jsx)(a,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,P)}),(0,R.jsxs)(p,{className:c(`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`,M,`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)(o,{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)(h,{className:`size-4`})})}),(0,R.jsx)(d,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,R.jsx)(A,{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&&(j||F)?(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:F?n.feishuQrStarting:n.feishuQrScanHint}),(0,R.jsxs)(`div`,{className:c(`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`,F&&`bg-surface-muted/40 dark:bg-surface-base`),children:[F?(0,R.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,j&&v&&!x&&C&&!T?(0,R.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,j&&v&&!x&&!C&&!T&&!F?(0,R.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,j&&v&&!x&&T?(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:v,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,R.jsx)(b,{className:`size-3 shrink-0`}),n.feishuQrOpenLink]})]}):null]})]}):null]}),N?(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:s,className:c(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,f===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void k(`feishu`),children:n.feishuRegionChina}),(0,R.jsx)(`button`,{type:`button`,disabled:s,className:c(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,f===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void k(`lark`),children:n.feishuRegionInternational})]})}):null,(0,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:s,onClick:()=>void k(f),children:s?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:l,tgAccountsError:u,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:c(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:c(f(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:s,onChange:e=>l(e.target.value),onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),u?(0,R.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,R.jsx)(X,{children:n.multiAccountJsonDesc})]})]})}function Oe({open:e,onOpenChange:t,ch:n,form:r,baseline:i,tgAdvanced:s,setTgAdvanced:l,showToken:f,setShowToken:m,copied:g,copyToken:_,updateTelegram:b,updateChannelAgentRoute:x,tgAccountsDraft:S,setTgAccountsDraft:C,tgAccountsError:E,onTgAccountsBlur:k,dmOpts:N,groupOpts:F,replyOpts:ee,streamOpts:te,chatAgents:ne,saving:re,dirty:ie,save:ae,discard:oe}){let se=G,I=r.telegram,ce=i?pe(i.telegram):``,L=pe(I),le=!f&&!!String(ce).trim()&&L===ce;return(0,R.jsx)(u,{open:e,onOpenChange:t,children:(0,R.jsxs)(O,{children:[(0,R.jsx)(a,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,P)}),(0,R.jsxs)(p,{className:c(`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`,M,`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)(d,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.telegramTitle}),(0,R.jsx)(A,{className:`mt-1 text-sm text-fg-muted`,children:n.telegramSubtitle})]}),(0,R.jsx)(o,{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)(h,{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:I.enabled,onChange:e=>b({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:c(se(),`min-w-0 flex-1 font-mono text-xs`),type:f?`text`:`password`,autoComplete:`off`,readOnly:le,value:le?`*`.repeat(Math.max(1,ce.length)):L,onChange:e=>{if(le)return;let t=I.accounts?.default??$(`default`);b({accounts:{...I.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)(w,{className:`size-3.5`}):(0,R.jsx)(j,{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:()=>m(e=>!e),children:[f?(0,R.jsx)(v,{className:`size-3.5`}):(0,R.jsx)(y,{className:`size-3.5`}),f?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:c(se(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`123456789, 987654321`,value:q(I.allowFrom),onChange:e=>b({allowFrom:K(e.target.value)})}),(0,R.jsx)(X,{children:n.allowFromDmDesc})]}),(0,R.jsx)(ge,{accountIds:H(I),routes:r.channelAgentRoutes.telegram,defaultAgentId:r.defaultAgentId,agentItems:ne?.items??[],disabled:re,onChange:(e,t)=>x(`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:()=>l(e=>!e),children:[(0,R.jsx)(T,{className:c(`mr-1 size-4 transition-transform`,s&&`rotate-180`)}),s?n.advancedHide:n.advancedShow]}),s?(0,R.jsx)(De,{tg:I,updateTelegram:b,ch:n,dmOpts:N,groupOpts:F,replyOpts:ee,streamOpts:te,tgAccountsDraft:S,setTgAccountsDraft:C,tgAccountsError:E,onTgAccountsBlur:k}):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:oe,children:n.discard}),(0,R.jsx)(D,{type:`button`,variant:`primary`,disabled:!ie||re,onClick:async()=>{await ae()&&t(!1)},children:re?n.saving:n.save})]})]})]})})}function ke(){let e=g(e=>e.language),t=i(e),n=t.channelsSettings,a=!!x(e=>e.token),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,ee]=(0,Q.useState)(!1),[te,ne]=(0,Q.useState)(!1),[re,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),[I,ce]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(``),[le,z]=(0,Q.useState)(``),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(``),[ue,W]=(0,Q.useState)(``),[de,G]=(0,Q.useState)(``),{data:fe}=r(a?`gateway-chat-agents-ch`:null,ie,{revalidateOnFocus:!1}),{data:K,error:q,isLoading:me,mutate:he}=_(a),J=(0,Q.useMemo)(()=>K?.payload?.config===void 0?null:be(K.payload.config),[K]),Y=(0,Q.useMemo)(()=>!o||!c?!1:JSON.stringify(o)!==JSON.stringify(c),[o,c]);(0,Q.useEffect)(()=>{if(!a){s(null),l(null);return}J!==null&&(Y||(s(J),l(structuredClone(J)),R(JSON.stringify(J.telegram.accounts??{},null,2)),z(``),V(JSON.stringify(J.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(J.feishu?.accounts??{},null,2)),G(``),h(!1)))},[a,J,Y]);let X=!!(a&&me&&K===void 0&&!q),Z=q instanceof Error?q.message:q?String(q):null,ge=(0,Q.useCallback)((e,t,n)=>{s(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=>{s(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),ve=(0,Q.useCallback)(e=>{s(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),$=(0,Q.useCallback)(e=>{s(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]);return{language:e,m:t,ch:n,hasToken:a,loading:X,fetchError:Z,mutate:he,form:o,baseline:c,dirty:Y,saving:u,error:f,saveOk:m,weixinModalOpen:v,setWeixinModalOpen:y,telegramModalOpen:b,setTelegramModalOpen:S,feishuModalOpen:C,setFeishuModalOpen:w,removeTarget:T,setRemoveTarget:E,weixinSuccessBanner:D,setWeixinSuccessBanner:O,feishuSetupSuccessBanner:k,tgAdvanced:j,setTgAdvanced:M,showToken:N,setShowToken:P,showFeishuSecret:F,setShowFeishuSecret:ee,showFeishuWebhookSecrets:te,setShowFeishuWebhookSecrets:ne,copied:re,feishuCopied:oe,feishuWebhookCopied:I,tgAccountsDraft:L,setTgAccountsDraft:R,tgAccountsError:le,wxAccountsDraft:B,setWxAccountsDraft:V,wxAccountsError:H,feishuAccountsDraft:ue,setFeishuAccountsDraft:W,feishuAccountsError:de,chatAgents:fe,updateChannelAgentRoute:ge,updateTelegram:_e,updateWeixin:ve,updateFeishu:$,save:(0,Q.useCallback)(async()=>{if(!o||u)return!1;d(!0),p(null),h(!1);try{let e=await Ce(o);s(e);let t=structuredClone(e);return l(t),R(JSON.stringify(t.telegram.accounts??{},null,2)),z(``),V(JSON.stringify(t.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(t.feishu?.accounts??{},null,2)),G(``),h(!0),window.setTimeout(()=>h(!1),2500),!0}catch(e){return p(e instanceof Error?e.message:n.saveError),!1}finally{d(!1)}},[o,u,n.saveError]),discard:(0,Q.useCallback)(()=>{if(!c)return;let e=structuredClone(c);s(e),R(JSON.stringify(e.telegram.accounts??{},null,2)),z(``),V(JSON.stringify(e.weixin.accounts??{},null,2)),U(``),W(JSON.stringify(e.feishu?.accounts??{},null,2)),G(``),p(null),h(!1)},[c]),toggleChannelEnabled:(0,Q.useCallback)(async(e,t)=>{if(!o||u)return;let r=o,i=e===`weixin`?{...o,weixin:{...o.weixin,enabled:t}}:e===`telegram`?{...o,telegram:{...o.telegram,enabled:t}}:{...o,feishu:{...o.feishu,enabled:t}};s(i),d(!0),p(null);try{let e=await Ce(i);s(e);let t=structuredClone(e);l(t),R(JSON.stringify(t.telegram.accounts??{},null,2)),V(JSON.stringify(t.weixin.accounts??{},null,2)),W(JSON.stringify(t.feishu?.accounts??{},null,2))}catch(e){p(e instanceof Error?e.message:n.saveError),s(r)}finally{d(!1)}},[o,u,n.saveError]),removeChannel:(0,Q.useCallback)(async()=>{if(!o||!T||u)return;let e=ye(),t=T===`weixin`?{...o,weixin:e.weixin}:T===`telegram`?{...o,telegram:e.telegram}:{...o,feishu:e.feishu};d(!0),p(null);try{let e=await Ce(t);s(e);let n=structuredClone(e);l(n),R(JSON.stringify(n.telegram.accounts??{},null,2)),V(JSON.stringify(n.weixin.accounts??{},null,2)),z(``),U(``),W(JSON.stringify(n.feishu?.accounts??{},null,2)),G(``),E(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:n.saveError)}finally{d(!1)}},[o,T,u,n.saveError]),copyToken:(0,Q.useCallback)(async()=>{let e=o?pe(o.telegram):``;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),ae(!0),window.setTimeout(()=>ae(!1),2e3))},[o]),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=o?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),se(!0),window.setTimeout(()=>se(!1),2e3))},[o]),copyFeishuWebhookConfig:(0,Q.useCallback)(async()=>{let e=o?.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(()=>{}),ce(!0),window.setTimeout(()=>ce(!1),2e3)},[o]),onTgAccountsBlur:(0,Q.useCallback)(()=>{if(!o)return;let e=L.trim();if(!e){_e({accounts:{}}),z(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);_e({accounts:t}),z(``)}catch(e){z(e instanceof Error?e.message:n.jsonInvalid)}},[o,L,_e,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,Q.useCallback)(()=>{if(!o)return;let e=B.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)}},[o,B,ve,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,Q.useCallback)(()=>{if(!o)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)}},[o,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[s,l]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),k=(0,Q.useCallback)(async()=>{y(null),S(null),m(null),l(!0);try{let e=await xe();_(e.qrcodeUrl),m(e.sessionKey)}catch(e){y(e instanceof Error?e.message:`Start failed`)}finally{l(!1)}},[]);(0,Q.useEffect)(()=>{if(!e){m(null),_(null),y(null),w(null),E(!1),S(null);return}k()},[e,k]),(0,Q.useEffect)(()=>{if(!f)return;let e=!1,i,a=async()=>{try{let a=await Se(f);if(e)return;if(a.phase===`polling`){_(a.qrcodeUrl),a.qrStatus===`scaned`?S(n.weixinQrLoginScanned):S(null);return}if(a.phase===`done`){i!==void 0&&(window.clearInterval(i),i=void 0),m(null),a.ok?(_(null),t(!1),await r()):(y(a.message),_(null));return}a.phase===`unknown`&&S(null)}catch(t){e||(i!==void 0&&window.clearInterval(i),y(t instanceof Error?t.message:`Request failed`),m(null),_(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[f,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,Q.useEffect)(()=>{if(!g){w(null),E(!1);return}let e=!1;return E(!1),ve.toDataURL(g,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||w(t)}).catch(()=>{e||(E(!0),w(null))}),()=>{e=!0}},[g]);let j=!!(g&&f),N=e&&!v&&!j;return(0,R.jsx)(u,{open:e,onOpenChange:t,children:(0,R.jsxs)(O,{children:[(0,R.jsx)(a,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,P)}),(0,R.jsxs)(p,{className:c(`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`,M,`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)(o,{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)(h,{className:`size-4`})})}),(0,R.jsx)(d,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,R.jsx)(A,{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:[v?(0,R.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(j||N)?(0,R.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,R.jsx)(`p`,{className:c(`min-h-[1.25rem] text-center text-sm`,x&&!N?`text-accent`:`text-fg-muted`),children:N?n.weixinQrLoginBusy:x??`\xA0`}),(0,R.jsxs)(`div`,{className:c(`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`,N&&`bg-surface-muted/40 dark:bg-surface-base`),children:[N?(0,R.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,j&&g&&!v&&C&&!T?(0,R.jsx)(`img`,{src:C,alt:``,className:`relative z-[1] size-full object-contain`}):null,j&&g&&!v&&!C&&!T&&!N?(0,R.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,j&&g&&!v&&T?(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:g,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,R.jsx)(b,{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:s,onClick:()=>void k(),children:s?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:l,channelAgentRoutesWx:u,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:c(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:c(h(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:a,onChange:e=>o(e.target.value),onBlur:l,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:u,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:d,saving:f,dirty:p,save:m,discard:h}){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)(T,{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:d,routingDisabled:f})}),(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:!p||f,onClick:h,children:e.discard}),(0,R.jsx)(D,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:!p||f,onClick:async()=>{await m()},children:f?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:d,saveOk:f,weixinModalOpen:p,setWeixinModalOpen:m,telegramModalOpen:h,setTelegramModalOpen:g,feishuModalOpen:_,setFeishuModalOpen:v,removeTarget:y,setRemoveTarget:x,weixinSuccessBanner:S,setWeixinSuccessBanner:C,feishuSetupSuccessBanner:w,tgAdvanced:T,setTgAdvanced:E,showToken:O,setShowToken:k,showFeishuSecret:A,setShowFeishuSecret:j,showFeishuWebhookSecrets:M,setShowFeishuWebhookSecrets:P,copied:F,feishuCopied:te,feishuWebhookCopied:re,tgAccountsDraft:ie,setTgAccountsDraft:ae,tgAccountsError:oe,wxAccountsDraft:se,setWxAccountsDraft:I,wxAccountsError:ce,feishuAccountsDraft:L,setFeishuAccountsDraft:B,feishuAccountsError:V,chatAgents:H,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:d??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:A,setShowFeishuSecret:j,showFeishuWebhookSecrets:M,setShowFeishuWebhookSecrets:P,feishuCopied:te,feishuWebhookCopied:re,copyFeishuSecret:X,copyFeishuWebhookConfig:Z,updateFeishu:de,updateChannelAgentRoute:U,feishuAccountsDraft:L,setFeishuAccountsDraft:B,feishuAccountsError:V,onFeishuAccountsBlur:ve,dmOpts:$,groupOpts:ye,chatAgents:H,saving:u,dirty:l,save:G,discard:fe}),Pe=(0,R.jsx)(Me,{ch:n,wx:Se,updateWeixin:W,dmOpts:$,streamOpts:xe,wxAccountsDraft:se,setWxAccountsDraft:I,wxAccountsError:ce,onWxAccountsBlur:Q,form:s,chatAgents:H,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:ee(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)(b,{className:`size-3.5`})]})]}),l?(0,R.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,f?(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.saved}):null,d?(0,R.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,S?(0,R.jsx)(`p`,{className:`text-xs text-accent`,children:S}):null,w?(0,R.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:w}):null,(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(le,{icon:(0,R.jsx)(ne,{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:()=>m(!0),onEdit:()=>m(!0),onRemove:()=>x(`weixin`),ch:n}),(0,R.jsx)(le,{icon:(0,R.jsx)(N,{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:()=>g(!0),onEdit:()=>g(!0),onRemove:()=>x(`telegram`),ch:n}),(0,R.jsx)(le,{icon:(0,R.jsx)(ne,{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:()=>v(!0),onEdit:()=>v(!0),onRemove:()=>x(`feishu`),ch:n})]}),(0,R.jsx)(Ae,{open:p,onOpenChange:m,ch:n,onLoginSuccess:async()=>{await o(),C(n.weixinQrLoginSuccess),window.setTimeout(()=>C(null),4e3)},moreSettings:Pe}),(0,R.jsx)(Oe,{open:h,onOpenChange:g,ch:n,form:s,baseline:c,tgAdvanced:T,setTgAdvanced:E,showToken:O,setShowToken:k,copied:F,copyToken:pe,updateTelegram:ue,updateChannelAgentRoute:U,tgAccountsDraft:ie,setTgAccountsDraft:ae,tgAccountsError:oe,onTgAccountsBlur:ge,dmOpts:$,groupOpts:ye,replyOpts:be,streamOpts:xe,chatAgents:H,saving:u,dirty:l,save:G,discard:fe}),(0,R.jsx)(Ee,{open:_,onOpenChange:v,ch:n,onSetupSuccess:Y,moreSettings:Ne}),(0,R.jsx)(z,{open:y!==null,onOpenChange:e=>{e||x(null)},ch:n,removeTarget:y,onCancel:()=>x(null),saving:u,onConfirmRemove:()=>void q()})]})}export{Ne as ChannelsSettingsPanel};
|
|
2
|
+
//# sourceMappingURL=channels-settings-D1xRSJDZ.js.map
|