@xopcai/xopc 0.0.26 → 0.0.28
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/extensions/weixin/src/adapters/onboard-cli.d.ts +7 -0
- package/dist/extensions/weixin/src/adapters/onboard-cli.js +61 -0
- package/dist/extensions/weixin/src/adapters/onboard-cli.js.map +1 -0
- package/dist/extensions/weixin/src/cli/qr-login.d.ts +5 -0
- package/dist/extensions/weixin/src/cli/qr-login.js +1 -1
- package/dist/extensions/weixin/src/cli/qr-login.js.map +1 -1
- package/dist/extensions/weixin/src/index.js +1 -1
- package/dist/extensions/weixin/src/plugin.d.ts +1 -0
- package/dist/extensions/weixin/src/plugin.js +2 -0
- package/dist/extensions/weixin/src/plugin.js.map +1 -1
- package/dist/gateway/static/root/assets/{agents-Clv9i1Kb.js → agents-DplaQYS2.js} +2 -2
- package/dist/gateway/static/root/assets/{agents-Clv9i1Kb.js.map → agents-DplaQYS2.js.map} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DqclV-PP.js → apps-page-Co95hLOJ.js} +2 -2
- package/dist/gateway/static/root/assets/{apps-page-DqclV-PP.js.map → apps-page-Co95hLOJ.js.map} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-CLyTYjrz.js → channels-settings-CkfSST0k.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-settings-CLyTYjrz.js.map → channels-settings-CkfSST0k.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-CU8lutMt.js → cron-page-D9q6KqL8.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-page-CU8lutMt.js.map → cron-page-D9q6KqL8.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-utils-_UjiWax6.js → cron-utils-BmzF4m1y.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-utils-_UjiWax6.js.map → cron-utils-BmzF4m1y.js.map} +1 -1
- package/dist/gateway/static/root/assets/{dist-Xqb4IGWC.js → dist-Dn-ufXyc.js} +2 -2
- package/dist/gateway/static/root/assets/{dist-Xqb4IGWC.js.map → dist-Dn-ufXyc.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CtTUkAmw.js → extension-debug-page-BZ8xQ74_.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-debug-page-CtTUkAmw.js.map → extension-debug-page-BZ8xQ74_.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C-aQU8qR.js → extension-page-BlNgKxwW.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-page-C-aQU8qR.js.map → extension-page-BlNgKxwW.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-b0y9aY-q.js → extension-settings-page-CWTdW_oY.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-settings-page-b0y9aY-q.js.map → extension-settings-page-CWTdW_oY.js.map} +1 -1
- package/dist/gateway/static/root/assets/index-OT4cGzon.css +1 -0
- package/dist/gateway/static/root/assets/{index-Gr2HWo-G.js → index-lV8FGWlt.js} +94 -94
- package/dist/gateway/static/root/assets/{index-Gr2HWo-G.js.map → index-lV8FGWlt.js.map} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DG31RpvG.js +2 -0
- package/dist/gateway/static/root/assets/logs-page-DG31RpvG.js.map +1 -0
- package/dist/gateway/static/root/assets/sessions-page-CdmjxDEM.js +2 -0
- package/dist/gateway/static/root/assets/{sessions-page-Cryg-36Z.js.map → sessions-page-CdmjxDEM.js.map} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DFNKT9yg.js → settings-page-DU2XLf5s.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-DFNKT9yg.js.map → settings-page-DU2XLf5s.js.map} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-D4gfh0Ih.js → skills-page-lb7vYtlP.js} +2 -2
- package/dist/gateway/static/root/assets/{skills-page-D4gfh0Ih.js.map → skills-page-lb7vYtlP.js.map} +1 -1
- package/dist/gateway/static/root/index.html +2 -2
- package/dist/package.js +1 -1
- package/dist/src/channels/index.js +2 -2
- package/dist/src/channels/manager.js +2 -2
- package/dist/src/channels/weixin/index.js +1 -1
- package/dist/src/cli/agent-chat-log-level-preset.d.ts +7 -0
- package/dist/src/cli/agent-chat-log-level-preset.js +22 -0
- package/dist/src/cli/agent-chat-log-level-preset.js.map +1 -0
- package/dist/src/cli/commands/agent/interactive.js +4 -2
- package/dist/src/cli/commands/agent/interactive.js.map +1 -1
- package/dist/src/cli/commands/agent/stream-renderer.d.ts +14 -0
- package/dist/src/cli/commands/agent/stream-renderer.js +99 -0
- package/dist/src/cli/commands/agent/stream-renderer.js.map +1 -0
- package/dist/src/cli/commands/agent.js +2 -2
- package/dist/src/cli/commands/agent.js.map +1 -1
- package/dist/src/cli/commands/onboard.js +77 -93
- package/dist/src/cli/commands/onboard.js.map +1 -1
- package/dist/src/cli/commands/tui.d.ts +1 -0
- package/dist/src/cli/commands/tui.js +40 -0
- package/dist/src/cli/commands/tui.js.map +1 -0
- package/dist/src/cli/index.d.ts +2 -0
- package/dist/src/cli/index.js +3 -0
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/config/schema.d.ts +6 -0
- package/dist/src/config/schema.js +6 -1
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/gateway/auth.d.ts +17 -3
- package/dist/src/gateway/auth.js +35 -16
- package/dist/src/gateway/auth.js.map +1 -1
- package/dist/src/gateway/hono/app.js +30 -1
- package/dist/src/gateway/hono/app.js.map +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
- package/dist/src/gateway/hono/middleware/auth.js +4 -3
- package/dist/src/gateway/hono/middleware/auth.js.map +1 -1
- package/dist/src/gateway/hono/middleware/scopes.d.ts +15 -0
- package/dist/src/gateway/hono/middleware/scopes.js +41 -0
- package/dist/src/gateway/hono/middleware/scopes.js.map +1 -0
- package/dist/src/gateway/security/audit.d.ts +18 -0
- package/dist/src/gateway/security/audit.js +68 -0
- package/dist/src/gateway/security/audit.js.map +1 -0
- package/dist/src/gateway/security/csp.d.ts +19 -0
- package/dist/src/gateway/security/csp.js +52 -0
- package/dist/src/gateway/security/csp.js.map +1 -0
- package/dist/src/gateway/security/dangerous-tools.d.ts +20 -0
- package/dist/src/gateway/security/dangerous-tools.js +46 -0
- package/dist/src/gateway/security/dangerous-tools.js.map +1 -0
- package/dist/src/gateway/security/flood-guard.d.ts +28 -0
- package/dist/src/gateway/security/flood-guard.js +42 -0
- package/dist/src/gateway/security/flood-guard.js.map +1 -0
- package/dist/src/gateway/security/index.d.ts +9 -0
- package/dist/src/gateway/security/index.js +10 -0
- package/dist/src/gateway/security/known-weak-secrets.d.ts +10 -0
- package/dist/src/gateway/security/known-weak-secrets.js +36 -0
- package/dist/src/gateway/security/known-weak-secrets.js.map +1 -0
- package/dist/src/gateway/security/operator-scopes.d.ts +37 -0
- package/dist/src/gateway/security/operator-scopes.js +137 -0
- package/dist/src/gateway/security/operator-scopes.js.map +1 -0
- package/dist/src/gateway/security/origin-check.d.ts +21 -0
- package/dist/src/gateway/security/origin-check.js +56 -0
- package/dist/src/gateway/security/origin-check.js.map +1 -0
- package/dist/src/gateway/security/preauth-connection-budget.d.ts +17 -0
- package/dist/src/gateway/security/preauth-connection-budget.js +49 -0
- package/dist/src/gateway/security/preauth-connection-budget.js.map +1 -0
- package/dist/src/gateway/security/secret-equal.d.ts +8 -0
- package/dist/src/gateway/security/secret-equal.js +30 -0
- package/dist/src/gateway/security/secret-equal.js.map +1 -0
- package/dist/src/gateway/service.d.ts +1 -1
- package/dist/src/gateway/service.js +11 -2
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/tui/backends/embedded-backend.d.ts +42 -0
- package/dist/src/tui/backends/embedded-backend.js +160 -0
- package/dist/src/tui/backends/embedded-backend.js.map +1 -0
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +49 -0
- package/dist/src/tui/backends/gateway-sse-backend.js +226 -0
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -0
- package/dist/src/tui/components/assistant-message.d.ts +6 -0
- package/dist/src/tui/components/assistant-message.js +19 -0
- package/dist/src/tui/components/assistant-message.js.map +1 -0
- package/dist/src/tui/components/chat-log.d.ts +19 -0
- package/dist/src/tui/components/chat-log.js +99 -0
- package/dist/src/tui/components/chat-log.js.map +1 -0
- package/dist/src/tui/components/custom-editor.d.ts +13 -0
- package/dist/src/tui/components/custom-editor.js +44 -0
- package/dist/src/tui/components/custom-editor.js.map +1 -0
- package/dist/src/tui/components/tool-execution.d.ts +16 -0
- package/dist/src/tui/components/tool-execution.js +76 -0
- package/dist/src/tui/components/tool-execution.js.map +1 -0
- package/dist/src/tui/components/user-message.d.ts +6 -0
- package/dist/src/tui/components/user-message.js +22 -0
- package/dist/src/tui/components/user-message.js.map +1 -0
- package/dist/src/tui/sse-consumer.d.ts +15 -0
- package/dist/src/tui/sse-consumer.js +75 -0
- package/dist/src/tui/sse-consumer.js.map +1 -0
- package/dist/src/tui/stream-assembler.d.ts +22 -0
- package/dist/src/tui/stream-assembler.js +63 -0
- package/dist/src/tui/stream-assembler.js.map +1 -0
- package/dist/src/tui/theme.d.ts +71 -0
- package/dist/src/tui/theme.js +151 -0
- package/dist/src/tui/theme.js.map +1 -0
- package/dist/src/tui/tui-backend.d.ts +84 -0
- package/dist/src/tui/tui-backend.js +1 -0
- package/dist/src/tui/tui-types.d.ts +85 -0
- package/dist/src/tui/tui-types.js +21 -0
- package/dist/src/tui/tui-types.js.map +1 -0
- package/dist/src/tui/tui.d.ts +3 -0
- package/dist/src/tui/tui.js +526 -0
- package/dist/src/tui/tui.js.map +1 -0
- package/package.json +9 -3
- package/dist/gateway/static/root/assets/index-DhSFfSNN.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-DRI33XK4.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DRI33XK4.js.map +0 -1
- package/dist/gateway/static/root/assets/sessions-page-Cryg-36Z.js +0 -2
|
@@ -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{a as r,i}from"./vendor-swr-B5fPo7KK.js";import{t as a}from"./cn-BMCV0OMB.js";import{$t as o,Bt as s,Ht as c,Jr as l,Jt as u,Kt as d,Ln as f,Mr as p,On as m,Rr as h,Un as g,Ur as _,Vt as v,Wt as y,Zn as b,ct as x,dt as S,fn as C,ft as w,jn as T,lt as E,qt as D,sn as O,st as k,ut as A,yr as j,zt as M}from"./index-Gr2HWo-G.js";var N=e(t(),1),P=n();function F({className:e}){let t=u(e=>!!e.token),[n,r]=(0,N.useState)(``),[o,s]=(0,N.useState)(``),c=t?`marketplace-${o}`:null;(0,N.useEffect)(()=>{let e=window.setTimeout(()=>s(n.trim()),300);return()=>window.clearTimeout(e)},[n]);let{data:l,isLoading:f,error:m}=i(c,async()=>d(o.length>0?y(`/api/marketplace?q=${encodeURIComponent(o)}`):y(`/api/marketplace`)),{revalidateOnFocus:!1}),h=l?.extensions??[];return(0,P.jsxs)(`div`,{className:a(`flex flex-col gap-4`,e),children:[(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(T,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,P.jsx)(`input`,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:`Search extensions…`,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),m?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m instanceof Error?m.message:`Failed to load marketplace`}):null,f&&!l?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading…`}):(0,P.jsx)(`ul`,{className:`flex flex-col gap-3`,children:h.length===0?(0,P.jsx)(`li`,{className:`text-sm text-fg-muted`,children:`No extensions in registry.`}):h.map(e=>(0,P.jsxs)(`li`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,P.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,P.jsx)(p,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,P.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.description}):null,(0,P.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,P.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,P.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,P.jsx)(g,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,P.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]}),e.homepage?(0,P.jsxs)(`a`,{href:e.homepage,target:`_blank`,rel:`noreferrer`,className:`mt-2 inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[(0,P.jsx)(j,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),`Homepage`]}):null]})}),(0,P.jsxs)(`p`,{className:`mt-3 text-[11px] text-fg-muted`,children:[`npm package:`,` `,(0,P.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]},e.id))})]})}function I(){let e=o(e=>e.language),t=O(e),n=D(e=>e.setPageHeader),i=D(e=>e.clearPageHeader),a=v(),s=c(),{mutate:l}=r(),[u,d]=(0,N.useState)(`all`),[f,p]=(0,N.useState)(``),[m,h]=(0,N.useState)(null),g=(0,N.useMemo)(()=>{let t=a;u===`ui`&&(t=t.filter(e=>e.hasUi)),u===`backend`&&(t=t.filter(e=>!e.hasUi));let n=f.trim().toLowerCase();return n&&(t=t.filter(e=>(e.name??``).toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||(e.description??``).toLowerCase().includes(n))),[...t].sort((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[a,u,f,e]);return(0,N.useEffect)(()=>{h(e=>{if(!e)return e;let t=a.find(t=>t.id===e.id);return t?R(e)===R(t)&&e.active===t.active?e:t:null})},[a]),(0,N.useLayoutEffect)(()=>(n({startExtra:null,main:(0,P.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,P.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>i()),[i,t.appsPage.title,n]),s&&u!==`marketplace`?(0,P.jsx)(W,{}):(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:[(0,P.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,P.jsxs)(`header`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:t.appsPage.title}),(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.appsPage.subtitle})]}),(0,P.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(L,{active:u===`all`,onClick:()=>d(`all`),label:t.appsPage.tabAll}),(0,P.jsx)(L,{active:u===`ui`,onClick:()=>d(`ui`),label:t.appsPage.tabWithUi}),(0,P.jsx)(L,{active:u===`backend`,onClick:()=>d(`backend`),label:t.appsPage.tabBackend}),(0,P.jsx)(L,{active:u===`marketplace`,onClick:()=>d(`marketplace`),label:t.appsPage.tabMarketplace})]}),u!==`marketplace`&&a.length>0?(0,P.jsxs)(`div`,{className:`relative w-full sm:max-w-xs`,children:[(0,P.jsx)(T,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,P.jsx)(`input`,{type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),u===`marketplace`?(0,P.jsx)(F,{}):a.length===0?(0,P.jsx)(G,{message:t.appsPage.empty}):g.length===0?(0,P.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,P.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:g.map(e=>(0,P.jsx)(V,{extension:e,copy:t.appsPage,onOpen:()=>h(e)},e.id))})]}),m?(0,P.jsx)(H,{extension:m,copy:t.appsPage,onClose:()=>h(null),onAfterToggle:async()=>{await l(`gateway-extensions-list`)}},m.id):null]})}function L({active:e,onClick:t,label:n}){return(0,P.jsx)(`button`,{type:`button`,onClick:t,className:a(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),children:n})}function R(e){return e.activationEligible??e.active}function z(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function B(e,t){let n=R(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function V({extension:e,copy:t,onOpen:n}){let r=R(e);return(0,P.jsx)(`button`,{type:`button`,onClick:n,className:a(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),children:(0,P.jsxs)(`div`,{className:`flex gap-3`,children:[(0,P.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),e.version?(0,P.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,e.version]}):null]}),r?(0,P.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,P.jsx)(h,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),t.statusEnabled]}):(0,P.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,P.jsx)(f,{className:`size-4`,strokeWidth:2.5})})]}),(0,P.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description?.trim()||t.cardNoDescription}),(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,P.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:e.hasUi?t.badgeKindUi:t.badgeKindBackend}),e.source===`bundled`?(0,P.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:t.badgeBundled}):null]})]})]})})}function H({extension:e,copy:t,onClose:n,onAfterToggle:r}){let[i,o]=(0,N.useState)(!1),[c,u]=(0,N.useState)(null),f=e.ui?.contributions?.pages??[],p=e.ui?.contributions?.settingsPanels??[],h=e.ui?.contributions?.chatWidgets??[],g=e.ui?.contributions?.sidebarPanels??[],v=f.find(e=>e.showInNav)??f[0],T=p[0],D=v?M(e.id,v):null,O=T?`/settings/ext/${e.id}/${T.id}`:e.hasConfigSchema?`/settings/ext/${e.id}`:null,F=R(e),I=e.source===`bundled`,L=async n=>{u(null),o(!0);try{await d(y(`/api/extensions/bundled/activation`),{method:`POST`,body:JSON.stringify({extensionId:e.id,enabled:n})}),await r()}catch(e){u(e instanceof Error?e.message:t.toggleError)}finally{o(!1)}};return(0,P.jsx)(S,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,P.jsxs)(A,{children:[(0,P.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,P.jsxs)(k,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,P.jsx)(_,{className:`size-5`})}),(0,P.jsx)(w,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,P.jsxs)(x,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,P.jsx)(C,{className:`size-5`})})]}),(0,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,P.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,P.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,z(e,t)]}),e.version?(0,P.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]}),I?(0,P.jsx)(`div`,{className:`flex w-full flex-col items-stretch gap-2 sm:w-auto sm:items-end`,children:(0,P.jsxs)(`button`,{type:`button`,disabled:i,"aria-busy":i,onClick:()=>void L(!F),className:a(`relative inline-flex max-w-full rounded-full py-1.5 text-sm font-medium`,`transition-[color,background-color,border-color,opacity] duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 motion-reduce:transition-none`,F?`border-2 border-red-500/50 text-red-600 hover:bg-red-500/10 focus-visible:ring-red-500/40 dark:text-red-400`:`border-2 border-transparent bg-accent text-white hover:opacity-90 focus-visible:ring-accent`,i&&`cursor-wait opacity-80`),children:[(0,P.jsx)(`span`,{className:`block whitespace-nowrap px-4 text-center leading-none`,children:F?t.actionDisable:t.actionEnable}),(0,P.jsx)(b,{className:a(`pointer-events-none absolute right-2 top-1/2 size-3 -translate-y-1/2 text-current opacity-90`,i?`animate-spin`:`invisible`),"aria-hidden":!0})]})}):null]}),(0,P.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,P.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,P.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:B(e,t)}),c?(0,P.jsx)(`p`,{className:`mt-3 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-fg`,role:`alert`,children:c}):null,I?null:(0,P.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(f.length>0||p.length>0||h.length>0)?(0,P.jsxs)(`section`,{className:`mt-8`,children:[(0,P.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,P.jsx)(U,{template:t.badgePages,count:f.length,hidden:f.length===0}),(0,P.jsx)(U,{template:t.badgeSettings,count:p.length,hidden:p.length===0}),(0,P.jsx)(U,{template:t.badgeWidgets,count:h.length,hidden:h.length===0}),(0,P.jsx)(U,{template:t.badgeSidebar,count:g.length,hidden:g.length===0})]})]}):null,s(e)&&(D||O)?(0,P.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[D?(0,P.jsxs)(l,{to:D,onClick:n,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,P.jsx)(j,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,O?(0,P.jsxs)(l,{to:O,onClick:n,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,P.jsx)(m,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,P.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function U({template:e,count:t,hidden:n}){return n||t===0?null:(0,P.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.replace(/\{\{count\}\}/g,String(t))})}function W(){return(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:(0,P.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,P.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,P.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),(0,P.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),(0,P.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:[0,1,2,3,4,5].map(e=>(0,P.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e))})]})})}function G({message:e}){return(0,P.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e})})}export{I as AppsPage};
|
|
2
|
-
//# sourceMappingURL=apps-page-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{i as t,t as n}from"./vendor-react-DbimaAId.js";import{a as r,i}from"./vendor-swr-B5fPo7KK.js";import{t as a}from"./cn-BMCV0OMB.js";import{$t as o,Bt as s,Ht as c,Jr as l,Jt as u,Kt as d,Ln as f,Mr as p,On as m,Rr as h,Un as g,Ur as _,Vt as v,Wt as y,Zn as b,ct as x,dt as S,fn as C,ft as w,jn as T,lt as E,qt as D,sn as O,st as k,ut as A,yr as j,zt as M}from"./index-lV8FGWlt.js";var N=e(t(),1),P=n();function F({className:e}){let t=u(e=>!!e.token),[n,r]=(0,N.useState)(``),[o,s]=(0,N.useState)(``),c=t?`marketplace-${o}`:null;(0,N.useEffect)(()=>{let e=window.setTimeout(()=>s(n.trim()),300);return()=>window.clearTimeout(e)},[n]);let{data:l,isLoading:f,error:m}=i(c,async()=>d(o.length>0?y(`/api/marketplace?q=${encodeURIComponent(o)}`):y(`/api/marketplace`)),{revalidateOnFocus:!1}),h=l?.extensions??[];return(0,P.jsxs)(`div`,{className:a(`flex flex-col gap-4`,e),children:[(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(T,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,P.jsx)(`input`,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:`Search extensions…`,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),m?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m instanceof Error?m.message:`Failed to load marketplace`}):null,f&&!l?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading…`}):(0,P.jsx)(`ul`,{className:`flex flex-col gap-3`,children:h.length===0?(0,P.jsx)(`li`,{className:`text-sm text-fg-muted`,children:`No extensions in registry.`}):h.map(e=>(0,P.jsxs)(`li`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,P.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,P.jsx)(p,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,P.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.description}):null,(0,P.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,P.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,P.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,P.jsx)(g,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,P.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]}),e.homepage?(0,P.jsxs)(`a`,{href:e.homepage,target:`_blank`,rel:`noreferrer`,className:`mt-2 inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[(0,P.jsx)(j,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),`Homepage`]}):null]})}),(0,P.jsxs)(`p`,{className:`mt-3 text-[11px] text-fg-muted`,children:[`npm package:`,` `,(0,P.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]},e.id))})]})}function I(){let e=o(e=>e.language),t=O(e),n=D(e=>e.setPageHeader),i=D(e=>e.clearPageHeader),a=v(),s=c(),{mutate:l}=r(),[u,d]=(0,N.useState)(`all`),[f,p]=(0,N.useState)(``),[m,h]=(0,N.useState)(null),g=(0,N.useMemo)(()=>{let t=a;u===`ui`&&(t=t.filter(e=>e.hasUi)),u===`backend`&&(t=t.filter(e=>!e.hasUi));let n=f.trim().toLowerCase();return n&&(t=t.filter(e=>(e.name??``).toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||(e.description??``).toLowerCase().includes(n))),[...t].sort((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[a,u,f,e]);return(0,N.useEffect)(()=>{h(e=>{if(!e)return e;let t=a.find(t=>t.id===e.id);return t?R(e)===R(t)&&e.active===t.active?e:t:null})},[a]),(0,N.useLayoutEffect)(()=>(n({startExtra:null,main:(0,P.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,P.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>i()),[i,t.appsPage.title,n]),s&&u!==`marketplace`?(0,P.jsx)(W,{}):(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:[(0,P.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,P.jsxs)(`header`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:t.appsPage.title}),(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.appsPage.subtitle})]}),(0,P.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(L,{active:u===`all`,onClick:()=>d(`all`),label:t.appsPage.tabAll}),(0,P.jsx)(L,{active:u===`ui`,onClick:()=>d(`ui`),label:t.appsPage.tabWithUi}),(0,P.jsx)(L,{active:u===`backend`,onClick:()=>d(`backend`),label:t.appsPage.tabBackend}),(0,P.jsx)(L,{active:u===`marketplace`,onClick:()=>d(`marketplace`),label:t.appsPage.tabMarketplace})]}),u!==`marketplace`&&a.length>0?(0,P.jsxs)(`div`,{className:`relative w-full sm:max-w-xs`,children:[(0,P.jsx)(T,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,P.jsx)(`input`,{type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),u===`marketplace`?(0,P.jsx)(F,{}):a.length===0?(0,P.jsx)(G,{message:t.appsPage.empty}):g.length===0?(0,P.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,P.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:g.map(e=>(0,P.jsx)(V,{extension:e,copy:t.appsPage,onOpen:()=>h(e)},e.id))})]}),m?(0,P.jsx)(H,{extension:m,copy:t.appsPage,onClose:()=>h(null),onAfterToggle:async()=>{await l(`gateway-extensions-list`)}},m.id):null]})}function L({active:e,onClick:t,label:n}){return(0,P.jsx)(`button`,{type:`button`,onClick:t,className:a(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),children:n})}function R(e){return e.activationEligible??e.active}function z(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function B(e,t){let n=R(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function V({extension:e,copy:t,onOpen:n}){let r=R(e);return(0,P.jsx)(`button`,{type:`button`,onClick:n,className:a(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),children:(0,P.jsxs)(`div`,{className:`flex gap-3`,children:[(0,P.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),e.version?(0,P.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,e.version]}):null]}),r?(0,P.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,P.jsx)(h,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),t.statusEnabled]}):(0,P.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,P.jsx)(f,{className:`size-4`,strokeWidth:2.5})})]}),(0,P.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description?.trim()||t.cardNoDescription}),(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,P.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:e.hasUi?t.badgeKindUi:t.badgeKindBackend}),e.source===`bundled`?(0,P.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:t.badgeBundled}):null]})]})]})})}function H({extension:e,copy:t,onClose:n,onAfterToggle:r}){let[i,o]=(0,N.useState)(!1),[c,u]=(0,N.useState)(null),f=e.ui?.contributions?.pages??[],p=e.ui?.contributions?.settingsPanels??[],h=e.ui?.contributions?.chatWidgets??[],g=e.ui?.contributions?.sidebarPanels??[],v=f.find(e=>e.showInNav)??f[0],T=p[0],D=v?M(e.id,v):null,O=T?`/settings/ext/${e.id}/${T.id}`:e.hasConfigSchema?`/settings/ext/${e.id}`:null,F=R(e),I=e.source===`bundled`,L=async n=>{u(null),o(!0);try{await d(y(`/api/extensions/bundled/activation`),{method:`POST`,body:JSON.stringify({extensionId:e.id,enabled:n})}),await r()}catch(e){u(e instanceof Error?e.message:t.toggleError)}finally{o(!1)}};return(0,P.jsx)(S,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,P.jsxs)(A,{children:[(0,P.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,P.jsxs)(k,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,P.jsx)(_,{className:`size-5`})}),(0,P.jsx)(w,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,P.jsxs)(x,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,P.jsx)(C,{className:`size-5`})})]}),(0,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,P.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,P.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,z(e,t)]}),e.version?(0,P.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]}),I?(0,P.jsx)(`div`,{className:`flex w-full flex-col items-stretch gap-2 sm:w-auto sm:items-end`,children:(0,P.jsxs)(`button`,{type:`button`,disabled:i,"aria-busy":i,onClick:()=>void L(!F),className:a(`relative inline-flex max-w-full rounded-full py-1.5 text-sm font-medium`,`transition-[color,background-color,border-color,opacity] duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 motion-reduce:transition-none`,F?`border-2 border-red-500/50 text-red-600 hover:bg-red-500/10 focus-visible:ring-red-500/40 dark:text-red-400`:`border-2 border-transparent bg-accent text-white hover:opacity-90 focus-visible:ring-accent`,i&&`cursor-wait opacity-80`),children:[(0,P.jsx)(`span`,{className:`block whitespace-nowrap px-4 text-center leading-none`,children:F?t.actionDisable:t.actionEnable}),(0,P.jsx)(b,{className:a(`pointer-events-none absolute right-2 top-1/2 size-3 -translate-y-1/2 text-current opacity-90`,i?`animate-spin`:`invisible`),"aria-hidden":!0})]})}):null]}),(0,P.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,P.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,P.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:B(e,t)}),c?(0,P.jsx)(`p`,{className:`mt-3 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-fg`,role:`alert`,children:c}):null,I?null:(0,P.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(f.length>0||p.length>0||h.length>0)?(0,P.jsxs)(`section`,{className:`mt-8`,children:[(0,P.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,P.jsx)(U,{template:t.badgePages,count:f.length,hidden:f.length===0}),(0,P.jsx)(U,{template:t.badgeSettings,count:p.length,hidden:p.length===0}),(0,P.jsx)(U,{template:t.badgeWidgets,count:h.length,hidden:h.length===0}),(0,P.jsx)(U,{template:t.badgeSidebar,count:g.length,hidden:g.length===0})]})]}):null,s(e)&&(D||O)?(0,P.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[D?(0,P.jsxs)(l,{to:D,onClick:n,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,P.jsx)(j,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,O?(0,P.jsxs)(l,{to:O,onClick:n,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,P.jsx)(m,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,P.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function U({template:e,count:t,hidden:n}){return n||t===0?null:(0,P.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.replace(/\{\{count\}\}/g,String(t))})}function W(){return(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:(0,P.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,P.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,P.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),(0,P.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),(0,P.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:[0,1,2,3,4,5].map(e=>(0,P.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e))})]})})}function G({message:e}){return(0,P.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e})})}export{I as AppsPage};
|
|
2
|
+
//# sourceMappingURL=apps-page-Co95hLOJ.js.map
|
package/dist/gateway/static/root/assets/{apps-page-DqclV-PP.js.map → apps-page-Co95hLOJ.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps-page-DqclV-PP.js","names":[],"sources":["../../../../../web/src/features/extensions/extension-marketplace.tsx","../../../../../web/src/pages/apps-page.tsx"],"sourcesContent":["import { CheckCircle, ExternalLink, Package, Search } from 'lucide-react';\nimport { useEffect, useState } from 'react';\nimport useSWR from 'swr';\n\nimport { useGatewayStore } from '@/stores/gateway-store';\nimport { fetchJson } from '@/lib/fetch';\nimport { apiUrl } from '@/lib/url';\nimport { cn } from '@/lib/cn';\n\ntype RegistryEntry = {\n id: string;\n name: string;\n description?: string;\n npmPackage: string;\n version?: string;\n categories?: string[];\n tags?: string[];\n verified?: boolean;\n homepage?: string;\n author?: string;\n};\n\ntype MarketplaceResponse = { ok: boolean; extensions: RegistryEntry[] };\n\nexport function ExtensionMarketplacePanel({ className }: { className?: string }) {\n const hasToken = useGatewayStore((s) => Boolean(s.token));\n const [q, setQ] = useState('');\n const [debounced, setDebounced] = useState('');\n const key = hasToken ? `marketplace-${debounced}` : null;\n\n useEffect(() => {\n const t = window.setTimeout(() => setDebounced(q.trim()), 300);\n return () => window.clearTimeout(t);\n }, [q]);\n\n const { data, isLoading, error } = useSWR(\n key,\n async () => {\n const url =\n debounced.length > 0\n ? apiUrl(`/api/marketplace?q=${encodeURIComponent(debounced)}`)\n : apiUrl('/api/marketplace');\n return fetchJson<MarketplaceResponse>(url);\n },\n { revalidateOnFocus: false },\n );\n\n const extensions = data?.extensions ?? [];\n\n return (\n <div className={cn('flex flex-col gap-4', className)}>\n <div className=\"relative\">\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted\"\n strokeWidth={1.75}\n aria-hidden\n />\n <input\n type=\"search\"\n value={q}\n onChange={(e) => setQ(e.target.value)}\n placeholder=\"Search extensions…\"\n className=\"ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted\"\n />\n </div>\n\n {error ? (\n <p className=\"text-sm text-fg-muted\">\n {error instanceof Error ? error.message : 'Failed to load marketplace'}\n </p>\n ) : null}\n\n {isLoading && !data ? (\n <p className=\"text-sm text-fg-muted\">Loading…</p>\n ) : (\n <ul className=\"flex flex-col gap-3\">\n {extensions.length === 0 ? (\n <li className=\"text-sm text-fg-muted\">No extensions in registry.</li>\n ) : (\n extensions.map((e) => (\n <li\n key={e.id}\n className=\"rounded-xl border border-edge bg-surface-base p-4 shadow-surface\"\n >\n <div className=\"flex flex-wrap items-start justify-between gap-2\">\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"font-semibold text-fg\">{e.name}</h3>\n {e.verified ? (\n <CheckCircle\n className=\"size-4 shrink-0 text-emerald-600 dark:text-emerald-400\"\n strokeWidth={1.75}\n aria-label=\"Verified\"\n />\n ) : null}\n {e.version ? (\n <span className=\"text-xs text-fg-muted\">{e.version}</span>\n ) : null}\n </div>\n {e.description ? (\n <p className=\"mt-1 text-sm text-fg-muted\">{e.description}</p>\n ) : null}\n <div className=\"mt-2 flex flex-wrap gap-1.5\">\n {(e.categories ?? []).map((c) => (\n <span\n key={c}\n className=\"rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted\"\n >\n {c}\n </span>\n ))}\n </div>\n <p className=\"mt-2 flex items-center gap-1.5 text-xs text-fg-muted\">\n <Package className=\"size-3.5 shrink-0\" strokeWidth={1.75} aria-hidden />\n <code className=\"rounded bg-surface-panel px-1 py-0.5\">{e.npmPackage}</code>\n </p>\n {e.homepage ? (\n <a\n href={e.homepage}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"mt-2 inline-flex items-center gap-1 text-xs text-accent hover:underline\"\n >\n <ExternalLink className=\"size-3.5\" strokeWidth={1.75} aria-hidden />\n Homepage\n </a>\n ) : null}\n </div>\n </div>\n <p className=\"mt-3 text-[11px] text-fg-muted\">\n npm package:{' '}\n <code className=\"rounded bg-surface-panel px-1 py-0.5\">{e.npmPackage}</code>\n </p>\n </li>\n ))\n )}\n </ul>\n )}\n </div>\n );\n}\n","import * as Dialog from '@radix-ui/react-dialog';\nimport {\n ArrowLeft,\n Check,\n ExternalLink,\n Loader2,\n Plus,\n Search,\n Settings,\n X,\n} from 'lucide-react';\nimport { useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport { Link } from 'react-router-dom';\nimport { useSWRConfig } from 'swr';\n\nimport {\n extensionExposesGatewayShellUi,\n useExtensions,\n useExtensionsLoading,\n} from '@/features/extensions/extension-provider';\nimport { ExtensionMarketplacePanel } from '@/features/extensions/extension-marketplace';\nimport { extensionPagePath } from '@/features/extensions/extension-paths';\nimport type { ExtensionApiRow, PageContribution } from '@/features/extensions/types';\nimport { messages } from '@/i18n/messages';\nimport type { MessageBundle } from '@/i18n/messages';\nimport { cn } from '@/lib/cn';\nimport { fetchJson } from '@/lib/fetch';\nimport { apiUrl } from '@/lib/url';\nimport { usePageHeaderStore } from '@/stores/page-header-store';\nimport { useLocaleStore } from '@/stores/locale-store';\n\ntype AppsPageCopy = MessageBundle['appsPage'];\ntype AppsTab = 'all' | 'ui' | 'backend' | 'marketplace';\n\nexport function AppsPage() {\n const language = useLocaleStore((s) => s.language);\n const m = messages(language);\n const setPageHeader = usePageHeaderStore((s) => s.setPageHeader);\n const clearPageHeader = usePageHeaderStore((s) => s.clearPageHeader);\n const extensions = useExtensions();\n const loading = useExtensionsLoading();\n const { mutate } = useSWRConfig();\n const [tab, setTab] = useState<AppsTab>('all');\n const [search, setSearch] = useState('');\n const [detail, setDetail] = useState<ExtensionApiRow | null>(null);\n\n const filtered = useMemo(() => {\n let list = extensions;\n if (tab === 'ui') list = list.filter((e) => e.hasUi);\n if (tab === 'backend') list = list.filter((e) => !e.hasUi);\n const q = search.trim().toLowerCase();\n if (q) {\n list = list.filter(\n (e) =>\n (e.name ?? '').toLowerCase().includes(q) ||\n e.id.toLowerCase().includes(q) ||\n (e.description ?? '').toLowerCase().includes(q),\n );\n }\n return [...list].sort((a, b) => {\n if (a.hasUi !== b.hasUi) return a.hasUi ? -1 : 1;\n return (a.name || a.id).localeCompare(b.name || b.id, language);\n });\n }, [extensions, tab, search, language]);\n\n /** Keep dialog + cards in sync after SWR refetch (detail was a stale row reference). */\n useEffect(() => {\n setDetail((prev) => {\n if (!prev) return prev;\n const next = extensions.find((e) => e.id === prev.id);\n if (!next) return null;\n const eligPrev = activationEligibleFor(prev);\n const eligNext = activationEligibleFor(next);\n if (eligPrev === eligNext && prev.active === next.active) return prev;\n return next;\n });\n }, [extensions]);\n\n useLayoutEffect(() => {\n setPageHeader({\n startExtra: null,\n main: (\n <div className=\"w-full min-w-0 px-3 sm:px-5 xl:px-6\">\n <h1 className=\"min-w-0 truncate text-base font-semibold tracking-tight text-fg\">{m.appsPage.title}</h1>\n </div>\n ),\n end: null,\n });\n return () => clearPageHeader();\n }, [clearPageHeader, m.appsPage.title, setPageHeader]);\n\n if (loading && tab !== 'marketplace') {\n return <AppsPageSkeleton />;\n }\n\n return (\n <div className=\"flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel\">\n <div className=\"mx-auto w-full max-w-app-main px-4 py-8\">\n <header className=\"mb-6\">\n <h1 className=\"text-xl font-semibold text-fg\">{m.appsPage.title}</h1>\n <p className=\"mt-1 text-sm text-fg-muted\">{m.appsPage.subtitle}</p>\n </header>\n\n <div className=\"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div className=\"flex flex-wrap gap-2\">\n <TabChip active={tab === 'all'} onClick={() => setTab('all')} label={m.appsPage.tabAll} />\n <TabChip\n active={tab === 'ui'}\n onClick={() => setTab('ui')}\n label={m.appsPage.tabWithUi}\n />\n <TabChip\n active={tab === 'backend'}\n onClick={() => setTab('backend')}\n label={m.appsPage.tabBackend}\n />\n <TabChip\n active={tab === 'marketplace'}\n onClick={() => setTab('marketplace')}\n label={m.appsPage.tabMarketplace}\n />\n </div>\n {tab !== 'marketplace' && extensions.length > 0 ? (\n <div className=\"relative w-full sm:max-w-xs\">\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted\"\n aria-hidden\n />\n <input\n type=\"search\"\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder={m.appsPage.searchPlaceholder}\n className=\"w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent\"\n autoComplete=\"off\"\n />\n </div>\n ) : null}\n </div>\n\n {tab === 'marketplace' ? (\n <ExtensionMarketplacePanel />\n ) : extensions.length === 0 ? (\n <EmptyAppsState message={m.appsPage.empty} />\n ) : filtered.length === 0 ? (\n <p className=\"rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15\">\n {m.appsPage.noSearchResults}\n </p>\n ) : (\n <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {filtered.map((ext) => (\n <ExtensionAppCard\n key={ext.id}\n extension={ext}\n copy={m.appsPage}\n onOpen={() => setDetail(ext)}\n />\n ))}\n </div>\n )}\n </div>\n\n {detail ? (\n <ExtensionDetailDialog\n key={detail.id}\n extension={detail}\n copy={m.appsPage}\n onClose={() => setDetail(null)}\n onAfterToggle={async () => {\n await mutate('gateway-extensions-list');\n }}\n />\n ) : null}\n </div>\n );\n}\n\nfunction TabChip({\n active,\n onClick,\n label,\n}: {\n active: boolean;\n onClick: () => void;\n label: string;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className={cn(\n 'rounded-full border px-3 py-1.5 text-xs font-medium transition-colors',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',\n active\n ? 'border-accent/40 bg-accent-soft text-accent-fg'\n : 'border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg',\n )}\n >\n {label}\n </button>\n );\n}\n\nfunction activationEligibleFor(ext: ExtensionApiRow): boolean {\n return ext.activationEligible ?? ext.active;\n}\n\nfunction providerLabel(ext: ExtensionApiRow, copy: AppsPageCopy): string {\n if (ext.source === 'bundled') return copy.providerBundled;\n if (ext.source === 'global') return copy.providerGlobal;\n if (ext.source === 'workspace') return copy.providerWorkspace;\n return copy.providerOther;\n}\n\nfunction bundledRunCaption(ext: ExtensionApiRow, copy: AppsPageCopy): string {\n const eligible = activationEligibleFor(ext);\n if (eligible && ext.active) return copy.runStateLive;\n if (eligible && !ext.active) return copy.runStatePendingOn;\n if (!eligible && ext.active) return copy.runStatePendingOff;\n return copy.runStateOff;\n}\n\nfunction ExtensionAppCard({\n extension: ext,\n copy,\n onOpen,\n}: {\n extension: ExtensionApiRow;\n copy: AppsPageCopy;\n onOpen: () => void;\n}) {\n const eligible = activationEligibleFor(ext);\n\n return (\n <button\n type=\"button\"\n onClick={onOpen}\n className={cn(\n 'group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors',\n 'hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',\n 'dark:hover:bg-surface-hover/25',\n )}\n >\n <div className=\"flex gap-3\">\n <div\n className=\"flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg\"\n aria-hidden\n >\n {(ext.name || ext.id).charAt(0).toUpperCase()}\n </div>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-start justify-between gap-2\">\n <div className=\"min-w-0\">\n <h2 className=\"truncate text-sm font-semibold text-fg\">{ext.name}</h2>\n {ext.version ? (\n <span className=\"text-[11px] text-fg-muted\">v{ext.version}</span>\n ) : null}\n </div>\n {eligible ? (\n <span className=\"inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted\">\n <Check className=\"size-3\" strokeWidth={2.5} aria-hidden />\n {copy.statusEnabled}\n </span>\n ) : (\n <span\n className=\"flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent\"\n aria-hidden\n >\n <Plus className=\"size-4\" strokeWidth={2.5} />\n </span>\n )}\n </div>\n <p className=\"mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted\">\n {ext.description?.trim() || copy.cardNoDescription}\n </p>\n <div className=\"mt-2 flex flex-wrap gap-1.5\">\n <span className=\"rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted\">\n {ext.hasUi ? copy.badgeKindUi : copy.badgeKindBackend}\n </span>\n {ext.source === 'bundled' ? (\n <span className=\"rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted\">\n {copy.badgeBundled}\n </span>\n ) : null}\n </div>\n </div>\n </div>\n </button>\n );\n}\n\nfunction ExtensionDetailDialog({\n extension: ext,\n copy,\n onClose,\n onAfterToggle,\n}: {\n extension: ExtensionApiRow;\n copy: AppsPageCopy;\n onClose: () => void;\n onAfterToggle: () => void | Promise<void>;\n}) {\n const [saving, setSaving] = useState(false);\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n\n const pages = ext.ui?.contributions?.pages ?? [];\n const settingsPanels = ext.ui?.contributions?.settingsPanels ?? [];\n const chatWidgets = ext.ui?.contributions?.chatWidgets ?? [];\n const sidebarPanels = ext.ui?.contributions?.sidebarPanels ?? [];\n const primaryPage: PageContribution | undefined = pages.find((p) => p.showInNav) ?? pages[0];\n const primarySettingsPanel = settingsPanels[0];\n const openPath = primaryPage ? extensionPagePath(ext.id, primaryPage) : null;\n const settingsPath = primarySettingsPanel\n ? `/settings/ext/${ext.id}/${primarySettingsPanel.id}`\n : ext.hasConfigSchema\n ? `/settings/ext/${ext.id}`\n : null;\n\n const eligible = activationEligibleFor(ext);\n const isBundled = ext.source === 'bundled';\n\n const toggleBundled = async (next: boolean) => {\n setErrorMessage(null);\n setSaving(true);\n try {\n await fetchJson<{ ok: true; payload: { requiresGatewayRestart: boolean } }>(\n apiUrl('/api/extensions/bundled/activation'),\n { method: 'POST', body: JSON.stringify({ extensionId: ext.id, enabled: next }) },\n );\n await onAfterToggle();\n } catch (e) {\n setErrorMessage(e instanceof Error ? e.message : copy.toggleError);\n } finally {\n setSaving(false);\n }\n };\n\n return (\n <Dialog.Root defaultOpen onOpenChange={(o) => !o && onClose()}>\n <Dialog.Portal>\n <Dialog.Overlay className=\"xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim\" />\n <Dialog.Content\n className=\"fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated\"\n onOpenAutoFocus={(e) => e.preventDefault()}\n >\n <div className=\"flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent\"\n aria-label={copy.detailBack}\n >\n <ArrowLeft className=\"size-5\" />\n </button>\n <Dialog.Title className=\"min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg\">\n {copy.detailTitle}\n </Dialog.Title>\n <Dialog.Description className=\"sr-only\">\n {ext.name} ({ext.id})\n </Dialog.Description>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent\"\n aria-label={copy.detailClose}\n >\n <X className=\"size-5\" />\n </button>\n </div>\n\n <div className=\"min-h-0 flex-1 overflow-y-auto px-5 py-5\">\n <div className=\"flex flex-wrap items-start gap-4\">\n <div\n className=\"flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg\"\n aria-hidden\n >\n {(ext.name || ext.id).charAt(0).toUpperCase()}\n </div>\n <div className=\"min-w-0 flex-1\">\n <h3 className=\"text-lg font-semibold text-fg\">{ext.name}</h3>\n <p className=\"mt-0.5 text-sm text-fg-muted\">\n {copy.detailProviderPrefix} {providerLabel(ext, copy)}\n </p>\n {ext.version ? (\n <p className=\"mt-1 text-xs text-fg-muted\">v{ext.version}</p>\n ) : null}\n </div>\n {isBundled ? (\n <div className=\"flex w-full flex-col items-stretch gap-2 sm:w-auto sm:items-end\">\n <button\n type=\"button\"\n disabled={saving}\n aria-busy={saving}\n onClick={() => void toggleBundled(!eligible)}\n className={cn(\n 'relative inline-flex max-w-full rounded-full py-1.5 text-sm font-medium',\n 'transition-[color,background-color,border-color,opacity] duration-200 ease-out',\n 'focus-visible:outline-none focus-visible:ring-2 motion-reduce:transition-none',\n eligible\n ? 'border-2 border-red-500/50 text-red-600 hover:bg-red-500/10 focus-visible:ring-red-500/40 dark:text-red-400'\n : 'border-2 border-transparent bg-accent text-white hover:opacity-90 focus-visible:ring-accent',\n saving && 'cursor-wait opacity-80',\n )}\n >\n <span className=\"block whitespace-nowrap px-4 text-center leading-none\">\n {eligible ? copy.actionDisable : copy.actionEnable}\n </span>\n <Loader2\n className={cn(\n 'pointer-events-none absolute right-2 top-1/2 size-3 -translate-y-1/2 text-current opacity-90',\n saving ? 'animate-spin' : 'invisible',\n )}\n aria-hidden\n />\n </button>\n </div>\n ) : null}\n </div>\n\n <p className=\"mt-5 text-sm leading-relaxed text-fg\">\n {ext.description?.trim() || copy.detailNoDescription}\n </p>\n\n {!ext.hasUi ? (\n <p className=\"mt-3 text-xs text-fg-muted\">{copy.backendOnlyHint}</p>\n ) : null}\n\n <p className=\"mt-2 text-xs text-fg-muted\">{bundledRunCaption(ext, copy)}</p>\n\n {errorMessage ? (\n <p className=\"mt-3 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-fg\" role=\"alert\">\n {errorMessage}\n </p>\n ) : null}\n\n {!isBundled ? (\n <p className=\"mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20\">\n {copy.cliManageHint}\n </p>\n ) : null}\n\n {ext.hasUi && (pages.length > 0 || settingsPanels.length > 0 || chatWidgets.length > 0) ? (\n <section className=\"mt-8\">\n <h4 className=\"mb-3 text-sm font-semibold text-fg\">{copy.detailSectionFeatures}</h4>\n <div className=\"flex flex-wrap gap-1.5\">\n <ContributionBadge\n template={copy.badgePages}\n count={pages.length}\n hidden={pages.length === 0}\n />\n <ContributionBadge\n template={copy.badgeSettings}\n count={settingsPanels.length}\n hidden={settingsPanels.length === 0}\n />\n <ContributionBadge\n template={copy.badgeWidgets}\n count={chatWidgets.length}\n hidden={chatWidgets.length === 0}\n />\n <ContributionBadge\n template={copy.badgeSidebar}\n count={sidebarPanels.length}\n hidden={sidebarPanels.length === 0}\n />\n </div>\n </section>\n ) : null}\n\n {extensionExposesGatewayShellUi(ext) && (openPath || settingsPath) ? (\n <div className=\"mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4\">\n {openPath ? (\n <Link\n to={openPath}\n onClick={onClose}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg',\n 'hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',\n )}\n >\n <ExternalLink className=\"size-4 shrink-0 opacity-80\" aria-hidden />\n {copy.open}\n </Link>\n ) : null}\n {settingsPath ? (\n <Link\n to={settingsPath}\n onClick={onClose}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg',\n 'hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',\n )}\n >\n <Settings className=\"size-4 shrink-0 opacity-80\" aria-hidden />\n {copy.openSettings}\n </Link>\n ) : null}\n </div>\n ) : null}\n\n <p className=\"mt-6 text-[11px] leading-relaxed text-fg-muted\">{copy.restartNote}</p>\n </div>\n </Dialog.Content>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n\nfunction ContributionBadge({\n template,\n count,\n hidden,\n}: {\n template: string;\n count: number;\n hidden: boolean;\n}) {\n if (hidden || count === 0) return null;\n return (\n <span className=\"inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted\">\n {template.replace(/\\{\\{count\\}\\}/g, String(count))}\n </span>\n );\n}\n\nfunction AppsPageSkeleton() {\n return (\n <div className=\"flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel\">\n <div className=\"mx-auto w-full max-w-app-main px-4 py-8\">\n <div className=\"mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover\" />\n <div className=\"mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover\" />\n <div className=\"mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover\" />\n <div className=\"mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {[0, 1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"h-36 animate-pulse rounded-xl border border-edge bg-surface-base\" />\n ))}\n </div>\n </div>\n </div>\n );\n}\n\nfunction EmptyAppsState({ message }: { message: string }) {\n return (\n <div className=\"flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20\">\n <p className=\"text-sm text-fg-muted\">{message}</p>\n </div>\n );\n}\n"],"mappings":"2cAwBA,SAAgB,EAA0B,CAAE,aAAqC,CAC/E,IAAM,EAAW,EAAiB,GAAM,EAAQ,EAAE,MAAO,CACnD,CAAC,EAAG,IAAA,EAAA,EAAA,UAAiB,GAAG,CACxB,CAAC,EAAW,IAAA,EAAA,EAAA,UAAyB,GAAG,CACxC,EAAM,EAAW,eAAe,IAAc,MAEpD,EAAA,EAAA,eAAgB,CACd,IAAM,EAAI,OAAO,eAAiB,EAAa,EAAE,MAAM,CAAC,CAAE,IAAI,CAC9D,UAAa,OAAO,aAAa,EAAE,EAClC,CAAC,EAAE,CAAC,CAEP,GAAM,CAAE,OAAM,YAAW,SAAU,EACjC,EACA,SAKS,EAHL,EAAU,OAAS,EACf,EAAO,sBAAsB,mBAAmB,EAAU,GAAG,CAC7D,EAAO,mBAAmB,CACU,CAE5C,CAAE,kBAAmB,GAAO,CAC7B,CAEK,EAAa,GAAM,YAAc,EAAE,CAEzC,OACE,EAAA,EAAA,MAAC,MAAD,CAAK,UAAW,EAAG,sBAAuB,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AA,KAAC,EAAD,CAAU,UAAU,6BAA6B,cAAA,GAAc,CAAA,CAC9D,EAAK,aACD,GACL,KACA,GACJ,MAEJ,EAAA,EAAA,KAAC,IAAD,CAAG,UAAU,0DAAkD,EAAK,YAAgB,CAAA,CAChF,GACS,GACH,CAAA,CAAA,CACJ,CAAA,CAIlB,SAAS,EAAkB,CACzB,WACA,QACA,UAKC,CAED,OADI,GAAU,IAAU,EAAU,MAEhC,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,kHACb,EAAS,QAAQ,iBAAkB,OAAO,EAAM,CAAC,CAC7C,CAAA,CAIX,SAAS,GAAmB,CAC1B,OACE,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,0EACb,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,mDAAf,EACE,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,qEAAuE,CAAA,EACtF,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,kEAAoE,CAAA,EACnF,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,uEAAyE,CAAA,EACxF,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,yDACZ,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAE,CAAC,IAAK,IACvB,EAAA,EAAA,KAAC,MAAD,CAAa,UAAU,mEAAqE,CAAlF,EAAkF,CAC5F,CACE,CAAA,CACF,GACF,CAAA,CAIV,SAAS,EAAe,CAAE,WAAgC,CACxD,OACE,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,qMACb,EAAA,EAAA,KAAC,IAAD,CAAG,UAAU,iCAAyB,EAAY,CAAA,CAC9C,CAAA"}
|
|
1
|
+
{"version":3,"file":"apps-page-Co95hLOJ.js","names":[],"sources":["../../../../../web/src/features/extensions/extension-marketplace.tsx","../../../../../web/src/pages/apps-page.tsx"],"sourcesContent":["import { CheckCircle, ExternalLink, Package, Search } from 'lucide-react';\nimport { useEffect, useState } from 'react';\nimport useSWR from 'swr';\n\nimport { useGatewayStore } from '@/stores/gateway-store';\nimport { fetchJson } from '@/lib/fetch';\nimport { apiUrl } from '@/lib/url';\nimport { cn } from '@/lib/cn';\n\ntype RegistryEntry = {\n id: string;\n name: string;\n description?: string;\n npmPackage: string;\n version?: string;\n categories?: string[];\n tags?: string[];\n verified?: boolean;\n homepage?: string;\n author?: string;\n};\n\ntype MarketplaceResponse = { ok: boolean; extensions: RegistryEntry[] };\n\nexport function ExtensionMarketplacePanel({ className }: { className?: string }) {\n const hasToken = useGatewayStore((s) => Boolean(s.token));\n const [q, setQ] = useState('');\n const [debounced, setDebounced] = useState('');\n const key = hasToken ? `marketplace-${debounced}` : null;\n\n useEffect(() => {\n const t = window.setTimeout(() => setDebounced(q.trim()), 300);\n return () => window.clearTimeout(t);\n }, [q]);\n\n const { data, isLoading, error } = useSWR(\n key,\n async () => {\n const url =\n debounced.length > 0\n ? apiUrl(`/api/marketplace?q=${encodeURIComponent(debounced)}`)\n : apiUrl('/api/marketplace');\n return fetchJson<MarketplaceResponse>(url);\n },\n { revalidateOnFocus: false },\n );\n\n const extensions = data?.extensions ?? [];\n\n return (\n <div className={cn('flex flex-col gap-4', className)}>\n <div className=\"relative\">\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted\"\n strokeWidth={1.75}\n aria-hidden\n />\n <input\n type=\"search\"\n value={q}\n onChange={(e) => setQ(e.target.value)}\n placeholder=\"Search extensions…\"\n className=\"ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted\"\n />\n </div>\n\n {error ? (\n <p className=\"text-sm text-fg-muted\">\n {error instanceof Error ? error.message : 'Failed to load marketplace'}\n </p>\n ) : null}\n\n {isLoading && !data ? (\n <p className=\"text-sm text-fg-muted\">Loading…</p>\n ) : (\n <ul className=\"flex flex-col gap-3\">\n {extensions.length === 0 ? (\n <li className=\"text-sm text-fg-muted\">No extensions in registry.</li>\n ) : (\n extensions.map((e) => (\n <li\n key={e.id}\n className=\"rounded-xl border border-edge bg-surface-base p-4 shadow-surface\"\n >\n <div className=\"flex flex-wrap items-start justify-between gap-2\">\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"font-semibold text-fg\">{e.name}</h3>\n {e.verified ? (\n <CheckCircle\n className=\"size-4 shrink-0 text-emerald-600 dark:text-emerald-400\"\n strokeWidth={1.75}\n aria-label=\"Verified\"\n />\n ) : null}\n {e.version ? (\n <span className=\"text-xs text-fg-muted\">{e.version}</span>\n ) : null}\n </div>\n {e.description ? (\n <p className=\"mt-1 text-sm text-fg-muted\">{e.description}</p>\n ) : null}\n <div className=\"mt-2 flex flex-wrap gap-1.5\">\n {(e.categories ?? []).map((c) => (\n <span\n key={c}\n className=\"rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted\"\n >\n {c}\n </span>\n ))}\n </div>\n <p className=\"mt-2 flex items-center gap-1.5 text-xs text-fg-muted\">\n <Package className=\"size-3.5 shrink-0\" strokeWidth={1.75} aria-hidden />\n <code className=\"rounded bg-surface-panel px-1 py-0.5\">{e.npmPackage}</code>\n </p>\n {e.homepage ? (\n <a\n href={e.homepage}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"mt-2 inline-flex items-center gap-1 text-xs text-accent hover:underline\"\n >\n <ExternalLink className=\"size-3.5\" strokeWidth={1.75} aria-hidden />\n Homepage\n </a>\n ) : null}\n </div>\n </div>\n <p className=\"mt-3 text-[11px] text-fg-muted\">\n npm package:{' '}\n <code className=\"rounded bg-surface-panel px-1 py-0.5\">{e.npmPackage}</code>\n </p>\n </li>\n ))\n )}\n </ul>\n )}\n </div>\n );\n}\n","import * as Dialog from '@radix-ui/react-dialog';\nimport {\n ArrowLeft,\n Check,\n ExternalLink,\n Loader2,\n Plus,\n Search,\n Settings,\n X,\n} from 'lucide-react';\nimport { useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport { Link } from 'react-router-dom';\nimport { useSWRConfig } from 'swr';\n\nimport {\n extensionExposesGatewayShellUi,\n useExtensions,\n useExtensionsLoading,\n} from '@/features/extensions/extension-provider';\nimport { ExtensionMarketplacePanel } from '@/features/extensions/extension-marketplace';\nimport { extensionPagePath } from '@/features/extensions/extension-paths';\nimport type { ExtensionApiRow, PageContribution } from '@/features/extensions/types';\nimport { messages } from '@/i18n/messages';\nimport type { MessageBundle } from '@/i18n/messages';\nimport { cn } from '@/lib/cn';\nimport { fetchJson } from '@/lib/fetch';\nimport { apiUrl } from '@/lib/url';\nimport { usePageHeaderStore } from '@/stores/page-header-store';\nimport { useLocaleStore } from '@/stores/locale-store';\n\ntype AppsPageCopy = MessageBundle['appsPage'];\ntype AppsTab = 'all' | 'ui' | 'backend' | 'marketplace';\n\nexport function AppsPage() {\n const language = useLocaleStore((s) => s.language);\n const m = messages(language);\n const setPageHeader = usePageHeaderStore((s) => s.setPageHeader);\n const clearPageHeader = usePageHeaderStore((s) => s.clearPageHeader);\n const extensions = useExtensions();\n const loading = useExtensionsLoading();\n const { mutate } = useSWRConfig();\n const [tab, setTab] = useState<AppsTab>('all');\n const [search, setSearch] = useState('');\n const [detail, setDetail] = useState<ExtensionApiRow | null>(null);\n\n const filtered = useMemo(() => {\n let list = extensions;\n if (tab === 'ui') list = list.filter((e) => e.hasUi);\n if (tab === 'backend') list = list.filter((e) => !e.hasUi);\n const q = search.trim().toLowerCase();\n if (q) {\n list = list.filter(\n (e) =>\n (e.name ?? '').toLowerCase().includes(q) ||\n e.id.toLowerCase().includes(q) ||\n (e.description ?? '').toLowerCase().includes(q),\n );\n }\n return [...list].sort((a, b) => {\n if (a.hasUi !== b.hasUi) return a.hasUi ? -1 : 1;\n return (a.name || a.id).localeCompare(b.name || b.id, language);\n });\n }, [extensions, tab, search, language]);\n\n /** Keep dialog + cards in sync after SWR refetch (detail was a stale row reference). */\n useEffect(() => {\n setDetail((prev) => {\n if (!prev) return prev;\n const next = extensions.find((e) => e.id === prev.id);\n if (!next) return null;\n const eligPrev = activationEligibleFor(prev);\n const eligNext = activationEligibleFor(next);\n if (eligPrev === eligNext && prev.active === next.active) return prev;\n return next;\n });\n }, [extensions]);\n\n useLayoutEffect(() => {\n setPageHeader({\n startExtra: null,\n main: (\n <div className=\"w-full min-w-0 px-3 sm:px-5 xl:px-6\">\n <h1 className=\"min-w-0 truncate text-base font-semibold tracking-tight text-fg\">{m.appsPage.title}</h1>\n </div>\n ),\n end: null,\n });\n return () => clearPageHeader();\n }, [clearPageHeader, m.appsPage.title, setPageHeader]);\n\n if (loading && tab !== 'marketplace') {\n return <AppsPageSkeleton />;\n }\n\n return (\n <div className=\"flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel\">\n <div className=\"mx-auto w-full max-w-app-main px-4 py-8\">\n <header className=\"mb-6\">\n <h1 className=\"text-xl font-semibold text-fg\">{m.appsPage.title}</h1>\n <p className=\"mt-1 text-sm text-fg-muted\">{m.appsPage.subtitle}</p>\n </header>\n\n <div className=\"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div className=\"flex flex-wrap gap-2\">\n <TabChip active={tab === 'all'} onClick={() => setTab('all')} label={m.appsPage.tabAll} />\n <TabChip\n active={tab === 'ui'}\n onClick={() => setTab('ui')}\n label={m.appsPage.tabWithUi}\n />\n <TabChip\n active={tab === 'backend'}\n onClick={() => setTab('backend')}\n label={m.appsPage.tabBackend}\n />\n <TabChip\n active={tab === 'marketplace'}\n onClick={() => setTab('marketplace')}\n label={m.appsPage.tabMarketplace}\n />\n </div>\n {tab !== 'marketplace' && extensions.length > 0 ? (\n <div className=\"relative w-full sm:max-w-xs\">\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted\"\n aria-hidden\n />\n <input\n type=\"search\"\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder={m.appsPage.searchPlaceholder}\n className=\"w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent\"\n autoComplete=\"off\"\n />\n </div>\n ) : null}\n </div>\n\n {tab === 'marketplace' ? (\n <ExtensionMarketplacePanel />\n ) : extensions.length === 0 ? (\n <EmptyAppsState message={m.appsPage.empty} />\n ) : filtered.length === 0 ? (\n <p className=\"rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15\">\n {m.appsPage.noSearchResults}\n </p>\n ) : (\n <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {filtered.map((ext) => (\n <ExtensionAppCard\n key={ext.id}\n extension={ext}\n copy={m.appsPage}\n onOpen={() => setDetail(ext)}\n />\n ))}\n </div>\n )}\n </div>\n\n {detail ? (\n <ExtensionDetailDialog\n key={detail.id}\n extension={detail}\n copy={m.appsPage}\n onClose={() => setDetail(null)}\n onAfterToggle={async () => {\n await mutate('gateway-extensions-list');\n }}\n />\n ) : null}\n </div>\n );\n}\n\nfunction TabChip({\n active,\n onClick,\n label,\n}: {\n active: boolean;\n onClick: () => void;\n label: string;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className={cn(\n 'rounded-full border px-3 py-1.5 text-xs font-medium transition-colors',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',\n active\n ? 'border-accent/40 bg-accent-soft text-accent-fg'\n : 'border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg',\n )}\n >\n {label}\n </button>\n );\n}\n\nfunction activationEligibleFor(ext: ExtensionApiRow): boolean {\n return ext.activationEligible ?? ext.active;\n}\n\nfunction providerLabel(ext: ExtensionApiRow, copy: AppsPageCopy): string {\n if (ext.source === 'bundled') return copy.providerBundled;\n if (ext.source === 'global') return copy.providerGlobal;\n if (ext.source === 'workspace') return copy.providerWorkspace;\n return copy.providerOther;\n}\n\nfunction bundledRunCaption(ext: ExtensionApiRow, copy: AppsPageCopy): string {\n const eligible = activationEligibleFor(ext);\n if (eligible && ext.active) return copy.runStateLive;\n if (eligible && !ext.active) return copy.runStatePendingOn;\n if (!eligible && ext.active) return copy.runStatePendingOff;\n return copy.runStateOff;\n}\n\nfunction ExtensionAppCard({\n extension: ext,\n copy,\n onOpen,\n}: {\n extension: ExtensionApiRow;\n copy: AppsPageCopy;\n onOpen: () => void;\n}) {\n const eligible = activationEligibleFor(ext);\n\n return (\n <button\n type=\"button\"\n onClick={onOpen}\n className={cn(\n 'group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors',\n 'hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',\n 'dark:hover:bg-surface-hover/25',\n )}\n >\n <div className=\"flex gap-3\">\n <div\n className=\"flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg\"\n aria-hidden\n >\n {(ext.name || ext.id).charAt(0).toUpperCase()}\n </div>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-start justify-between gap-2\">\n <div className=\"min-w-0\">\n <h2 className=\"truncate text-sm font-semibold text-fg\">{ext.name}</h2>\n {ext.version ? (\n <span className=\"text-[11px] text-fg-muted\">v{ext.version}</span>\n ) : null}\n </div>\n {eligible ? (\n <span className=\"inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted\">\n <Check className=\"size-3\" strokeWidth={2.5} aria-hidden />\n {copy.statusEnabled}\n </span>\n ) : (\n <span\n className=\"flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent\"\n aria-hidden\n >\n <Plus className=\"size-4\" strokeWidth={2.5} />\n </span>\n )}\n </div>\n <p className=\"mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted\">\n {ext.description?.trim() || copy.cardNoDescription}\n </p>\n <div className=\"mt-2 flex flex-wrap gap-1.5\">\n <span className=\"rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted\">\n {ext.hasUi ? copy.badgeKindUi : copy.badgeKindBackend}\n </span>\n {ext.source === 'bundled' ? (\n <span className=\"rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted\">\n {copy.badgeBundled}\n </span>\n ) : null}\n </div>\n </div>\n </div>\n </button>\n );\n}\n\nfunction ExtensionDetailDialog({\n extension: ext,\n copy,\n onClose,\n onAfterToggle,\n}: {\n extension: ExtensionApiRow;\n copy: AppsPageCopy;\n onClose: () => void;\n onAfterToggle: () => void | Promise<void>;\n}) {\n const [saving, setSaving] = useState(false);\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n\n const pages = ext.ui?.contributions?.pages ?? [];\n const settingsPanels = ext.ui?.contributions?.settingsPanels ?? [];\n const chatWidgets = ext.ui?.contributions?.chatWidgets ?? [];\n const sidebarPanels = ext.ui?.contributions?.sidebarPanels ?? [];\n const primaryPage: PageContribution | undefined = pages.find((p) => p.showInNav) ?? pages[0];\n const primarySettingsPanel = settingsPanels[0];\n const openPath = primaryPage ? extensionPagePath(ext.id, primaryPage) : null;\n const settingsPath = primarySettingsPanel\n ? `/settings/ext/${ext.id}/${primarySettingsPanel.id}`\n : ext.hasConfigSchema\n ? `/settings/ext/${ext.id}`\n : null;\n\n const eligible = activationEligibleFor(ext);\n const isBundled = ext.source === 'bundled';\n\n const toggleBundled = async (next: boolean) => {\n setErrorMessage(null);\n setSaving(true);\n try {\n await fetchJson<{ ok: true; payload: { requiresGatewayRestart: boolean } }>(\n apiUrl('/api/extensions/bundled/activation'),\n { method: 'POST', body: JSON.stringify({ extensionId: ext.id, enabled: next }) },\n );\n await onAfterToggle();\n } catch (e) {\n setErrorMessage(e instanceof Error ? e.message : copy.toggleError);\n } finally {\n setSaving(false);\n }\n };\n\n return (\n <Dialog.Root defaultOpen onOpenChange={(o) => !o && onClose()}>\n <Dialog.Portal>\n <Dialog.Overlay className=\"xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim\" />\n <Dialog.Content\n className=\"fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated\"\n onOpenAutoFocus={(e) => e.preventDefault()}\n >\n <div className=\"flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent\"\n aria-label={copy.detailBack}\n >\n <ArrowLeft className=\"size-5\" />\n </button>\n <Dialog.Title className=\"min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg\">\n {copy.detailTitle}\n </Dialog.Title>\n <Dialog.Description className=\"sr-only\">\n {ext.name} ({ext.id})\n </Dialog.Description>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent\"\n aria-label={copy.detailClose}\n >\n <X className=\"size-5\" />\n </button>\n </div>\n\n <div className=\"min-h-0 flex-1 overflow-y-auto px-5 py-5\">\n <div className=\"flex flex-wrap items-start gap-4\">\n <div\n className=\"flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg\"\n aria-hidden\n >\n {(ext.name || ext.id).charAt(0).toUpperCase()}\n </div>\n <div className=\"min-w-0 flex-1\">\n <h3 className=\"text-lg font-semibold text-fg\">{ext.name}</h3>\n <p className=\"mt-0.5 text-sm text-fg-muted\">\n {copy.detailProviderPrefix} {providerLabel(ext, copy)}\n </p>\n {ext.version ? (\n <p className=\"mt-1 text-xs text-fg-muted\">v{ext.version}</p>\n ) : null}\n </div>\n {isBundled ? (\n <div className=\"flex w-full flex-col items-stretch gap-2 sm:w-auto sm:items-end\">\n <button\n type=\"button\"\n disabled={saving}\n aria-busy={saving}\n onClick={() => void toggleBundled(!eligible)}\n className={cn(\n 'relative inline-flex max-w-full rounded-full py-1.5 text-sm font-medium',\n 'transition-[color,background-color,border-color,opacity] duration-200 ease-out',\n 'focus-visible:outline-none focus-visible:ring-2 motion-reduce:transition-none',\n eligible\n ? 'border-2 border-red-500/50 text-red-600 hover:bg-red-500/10 focus-visible:ring-red-500/40 dark:text-red-400'\n : 'border-2 border-transparent bg-accent text-white hover:opacity-90 focus-visible:ring-accent',\n saving && 'cursor-wait opacity-80',\n )}\n >\n <span className=\"block whitespace-nowrap px-4 text-center leading-none\">\n {eligible ? copy.actionDisable : copy.actionEnable}\n </span>\n <Loader2\n className={cn(\n 'pointer-events-none absolute right-2 top-1/2 size-3 -translate-y-1/2 text-current opacity-90',\n saving ? 'animate-spin' : 'invisible',\n )}\n aria-hidden\n />\n </button>\n </div>\n ) : null}\n </div>\n\n <p className=\"mt-5 text-sm leading-relaxed text-fg\">\n {ext.description?.trim() || copy.detailNoDescription}\n </p>\n\n {!ext.hasUi ? (\n <p className=\"mt-3 text-xs text-fg-muted\">{copy.backendOnlyHint}</p>\n ) : null}\n\n <p className=\"mt-2 text-xs text-fg-muted\">{bundledRunCaption(ext, copy)}</p>\n\n {errorMessage ? (\n <p className=\"mt-3 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-fg\" role=\"alert\">\n {errorMessage}\n </p>\n ) : null}\n\n {!isBundled ? (\n <p className=\"mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20\">\n {copy.cliManageHint}\n </p>\n ) : null}\n\n {ext.hasUi && (pages.length > 0 || settingsPanels.length > 0 || chatWidgets.length > 0) ? (\n <section className=\"mt-8\">\n <h4 className=\"mb-3 text-sm font-semibold text-fg\">{copy.detailSectionFeatures}</h4>\n <div className=\"flex flex-wrap gap-1.5\">\n <ContributionBadge\n template={copy.badgePages}\n count={pages.length}\n hidden={pages.length === 0}\n />\n <ContributionBadge\n template={copy.badgeSettings}\n count={settingsPanels.length}\n hidden={settingsPanels.length === 0}\n />\n <ContributionBadge\n template={copy.badgeWidgets}\n count={chatWidgets.length}\n hidden={chatWidgets.length === 0}\n />\n <ContributionBadge\n template={copy.badgeSidebar}\n count={sidebarPanels.length}\n hidden={sidebarPanels.length === 0}\n />\n </div>\n </section>\n ) : null}\n\n {extensionExposesGatewayShellUi(ext) && (openPath || settingsPath) ? (\n <div className=\"mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4\">\n {openPath ? (\n <Link\n to={openPath}\n onClick={onClose}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg',\n 'hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',\n )}\n >\n <ExternalLink className=\"size-4 shrink-0 opacity-80\" aria-hidden />\n {copy.open}\n </Link>\n ) : null}\n {settingsPath ? (\n <Link\n to={settingsPath}\n onClick={onClose}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg',\n 'hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',\n )}\n >\n <Settings className=\"size-4 shrink-0 opacity-80\" aria-hidden />\n {copy.openSettings}\n </Link>\n ) : null}\n </div>\n ) : null}\n\n <p className=\"mt-6 text-[11px] leading-relaxed text-fg-muted\">{copy.restartNote}</p>\n </div>\n </Dialog.Content>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n\nfunction ContributionBadge({\n template,\n count,\n hidden,\n}: {\n template: string;\n count: number;\n hidden: boolean;\n}) {\n if (hidden || count === 0) return null;\n return (\n <span className=\"inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted\">\n {template.replace(/\\{\\{count\\}\\}/g, String(count))}\n </span>\n );\n}\n\nfunction AppsPageSkeleton() {\n return (\n <div className=\"flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel\">\n <div className=\"mx-auto w-full max-w-app-main px-4 py-8\">\n <div className=\"mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover\" />\n <div className=\"mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover\" />\n <div className=\"mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover\" />\n <div className=\"mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {[0, 1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"h-36 animate-pulse rounded-xl border border-edge bg-surface-base\" />\n ))}\n </div>\n </div>\n </div>\n );\n}\n\nfunction EmptyAppsState({ message }: { message: string }) {\n return (\n <div className=\"flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20\">\n <p className=\"text-sm text-fg-muted\">{message}</p>\n </div>\n );\n}\n"],"mappings":"2cAwBA,SAAgB,EAA0B,CAAE,aAAqC,CAC/E,IAAM,EAAW,EAAiB,GAAM,EAAQ,EAAE,MAAO,CACnD,CAAC,EAAG,IAAA,EAAA,EAAA,UAAiB,GAAG,CACxB,CAAC,EAAW,IAAA,EAAA,EAAA,UAAyB,GAAG,CACxC,EAAM,EAAW,eAAe,IAAc,MAEpD,EAAA,EAAA,eAAgB,CACd,IAAM,EAAI,OAAO,eAAiB,EAAa,EAAE,MAAM,CAAC,CAAE,IAAI,CAC9D,UAAa,OAAO,aAAa,EAAE,EAClC,CAAC,EAAE,CAAC,CAEP,GAAM,CAAE,OAAM,YAAW,SAAU,EACjC,EACA,SAKS,EAHL,EAAU,OAAS,EACf,EAAO,sBAAsB,mBAAmB,EAAU,GAAG,CAC7D,EAAO,mBAAmB,CACU,CAE5C,CAAE,kBAAmB,GAAO,CAC7B,CAEK,EAAa,GAAM,YAAc,EAAE,CAE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EACJ,QAAS,EACT,UAAW,EACT,uGACA,mGACD,UANH,EAQE,EAAA,EAAA,KAAC,EAAD,CAAU,UAAU,6BAA6B,cAAA,GAAc,CAAA,CAC9D,EAAK,aACD,GACL,KACA,GACJ,MAEJ,EAAA,EAAA,KAAC,IAAD,CAAG,UAAU,0DAAkD,EAAK,YAAgB,CAAA,CAChF,GACS,GACH,CAAA,CAAA,CACJ,CAAA,CAIlB,SAAS,EAAkB,CACzB,WACA,QACA,UAKC,CAED,OADI,GAAU,IAAU,EAAU,MAEhC,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,kHACb,EAAS,QAAQ,iBAAkB,OAAO,EAAM,CAAC,CAC7C,CAAA,CAIX,SAAS,GAAmB,CAC1B,OACE,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,0EACb,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,mDAAf,EACE,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,qEAAuE,CAAA,EACtF,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,kEAAoE,CAAA,EACnF,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,uEAAyE,CAAA,EACxF,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,yDACZ,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAE,CAAC,IAAK,IACvB,EAAA,EAAA,KAAC,MAAD,CAAa,UAAU,mEAAqE,CAAlF,EAAkF,CAC5F,CACE,CAAA,CACF,GACF,CAAA,CAIV,SAAS,EAAe,CAAE,WAAgC,CACxD,OACE,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,qMACb,EAAA,EAAA,KAAC,IAAD,CAAG,UAAU,iCAAyB,EAAY,CAAA,CAC9C,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,t}from"./rolldown-runtime-DWdDZTNf.js";import{i as n,t as r}from"./vendor-react-DbimaAId.js";import{i}from"./vendor-swr-B5fPo7KK.js";import{t as a}from"./cn-BMCV0OMB.js";import{$t as o,A as s,An as c,Hn as l,Jt as u,Kn as d,Kt as f,Lr as p,Rr as m,Wt as h,Yt as g,_r as _,an as v,br as y,cn as b,ct as x,dt as S,fn as C,ft as ee,j as w,lt as te,on as T,ot as ne,rn as E,sn as re,st as ie,u as ae,ut as oe,vn as D,vr as se,wr as ce,yr as le}from"./index-Gr2HWo-G.js";import{a as ue,i as O,n as de,r as fe,t as pe}from"./dist-Xqb4IGWC.js";var k=e(n(),1);function A(e){return(e??``).trim().toLowerCase()}function me(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 he(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.botToken==`string`&&e.botToken.trim()?[`default`]:[]}function j(e){return Object.keys(e.accounts??{}).sort()}function ge(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 M(e,t,n,r,i){let a={},o={},s={};for(let n of t)a[n]=(e.find(e=>A(e.match?.channel)===`telegram`&&A(e.match?.accountId)===A(n)&&me(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>A(e.match?.channel)===`weixin`&&A(e.match?.accountId)===A(t)&&me(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>A(e.match?.channel)===`feishu`&&A(e.match?.accountId)===A(t)&&me(e))?.agentId??i).trim().toLowerCase();return{telegram:a,weixin:o,feishu:s}}function N(e,t,n,r,i,a){let o=new Set(n.map(A)),s=new Set(r.map(A)),c=new Set(i.map(A)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!me(e))return!0;let t=A(e.match.channel),n=A(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[A(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[A(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[A(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 _e(){return{bindingsFull:[],channelAgentRoutes:{telegram:{},weixin:{},feishu:{}},defaultAgentId:`main`,telegram:{enabled:!1,botToken:``,apiRoot:``,debug:!1,allowFrom:[],groupAllowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,proxy:``,accounts:{}},weixin:{enabled:!1,dmPolicy:`pairing`,allowFrom:[],debug:!1,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,routeTag:``,accounts:{}},feishu:{enabled:!1,defaultAccount:``,appId:``,appSecret:``,domain:`feishu`,connectionMode:`websocket`,verificationToken:``,encryptKey:``,webhookHost:`127.0.0.1`,webhookPort:3e3,webhookPath:`/feishu/events`,dmPolicy:`pairing`,groupPolicy:`allowlist`,allowFrom:[],groupAllowFrom:[],requireMention:!0,historyLimit:50,textChunkLimit:4e3,renderMode:`auto`,streaming:!1,reactionNotifications:`own`,tools:{doc:!0,wiki:!0,drive:!0,scopes:!0,bitable:!0,perm:!1},actions:{reactions:!0},accounts:{}}}}function ve(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=i?.accounts,l=c&&typeof c==`object`&&!Array.isArray(c)?c:{},u=(()=>{let t=(e&&typeof e==`object`?e:{}).bindings;return Array.isArray(t)?t:[]})(),d=(()=>{let t=(e&&typeof e==`object`?e:{}).agents;return t&&typeof t==`object`?t:{}})(),f=typeof d.defaultId==`string`&&d.defaultId.trim()?d.defaultId.trim().toLowerCase():`main`,p={telegram:{enabled:!!r?.enabled,botToken:typeof r?.botToken==`string`?r.botToken:``,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||`pairing`,allowFrom:Array.isArray(i?.allowFrom)?[...i.allowFrom]:[],debug:!!i?.debug,streamMode:i?.streamMode??`partial`,historyLimit:typeof i?.historyLimit==`number`?i.historyLimit:50,textChunkLimit:typeof i?.textChunkLimit==`number`?i.textChunkLimit:4e3,routeTag:i?.routeTag==null?``:String(i.routeTag),accounts:{...l}},feishu:{enabled:!!a?.enabled,defaultAccount:typeof a?.defaultAccount==`string`?a.defaultAccount:``,appId:typeof a?.appId==`string`?a.appId:``,appSecret:typeof a?.appSecret==`string`?a.appSecret:``,domain:typeof a?.domain==`string`&&a.domain||`feishu`,connectionMode:a?.connectionMode||`websocket`,verificationToken:typeof a?.verificationToken==`string`?a.verificationToken:``,encryptKey:typeof a?.encryptKey==`string`?a.encryptKey:``,webhookHost:typeof a?.webhookHost==`string`?a.webhookHost:`127.0.0.1`,webhookPort:typeof a?.webhookPort==`number`?a.webhookPort:3e3,webhookPath:typeof a?.webhookPath==`string`?a.webhookPath:`/feishu/events`,dmPolicy:a?.dmPolicy||`pairing`,groupPolicy:a?.groupPolicy||`allowlist`,allowFrom:Array.isArray(a?.allowFrom)?[...a.allowFrom]:[],groupAllowFrom:Array.isArray(a?.groupAllowFrom)?[...a.groupAllowFrom]:[],requireMention:a?.requireMention===void 0?!0:!!a.requireMention,historyLimit:typeof a?.historyLimit==`number`?a.historyLimit:50,textChunkLimit:typeof a?.textChunkLimit==`number`?a.textChunkLimit:4e3,renderMode:a?.renderMode||`auto`,streaming:a?.streaming===void 0?!1:!!a.streaming,reactionNotifications:a?.reactionNotifications||`own`,tools:a?.tools&&typeof a.tools==`object`&&!Array.isArray(a.tools)?{...a.tools}:void 0,actions:a?.actions&&typeof a.actions==`object`&&!Array.isArray(a.actions)?{...a.actions}:void 0,accounts:a?.accounts&&typeof a.accounts==`object`&&!Array.isArray(a.accounts)?{...a.accounts}:{}}},m=M(u,he(p.telegram),j(p.weixin),ge(p.feishu),f);return{...p,bindingsFull:u.map(e=>({...e})),channelAgentRoutes:m,defaultAgentId:f}}async function ye(e){return(await f(h(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function be(e){return(await f(h(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function xe(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=N(e.bindingsFull,e.channelAgentRoutes,he(t),j(n),ge(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await f(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({bindings:i,channels:{telegram:{enabled:t.enabled,botToken:t.botToken,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 s(),o?ve(o):{...e,bindingsFull:i}}async function Se(e){return(await f(h(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Ce(e){return(await f(h(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function we(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T,`dark:border-edge`)}function Te(){return a(v,E)}function Ee(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).map(e=>/^-?\d+$/.test(e)?Number(e):e)}function De(e){return e.map(String).join(`, `)}function Oe(e){return!!e.botToken?.trim()||Object.keys(e.accounts??{}).length>0}function ke(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function Ae(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}var P=r();function F({children:e}){return(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e})}function I({children:e}){return(0,P.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:e})}function L({label:e,value:t,onChange:n,options:r}){return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:e}),(0,P.jsx)(`select`,{className:Te(),value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,P.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function je({accountIds:e,routes:t,defaultAgentId:n,agentItems:r,disabled:i,onChange:o,ch:s}){if(e.length===0)return null;let c=r.length>0?r:[{id:n}];return(0,P.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(F,{children:s.agentRoutingTitle}),(0,P.jsx)(I,{children:s.agentRoutingHint})]}),(0,P.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,P.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,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:s.agentRoutingAccountLabel}),(0,P.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:e,children:e})]}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${e}`,children:s.agentRoutingAgentLabel}),(0,P.jsx)(`select`,{id:`agent-route-${e}`,className:a(we(),E),disabled:i,value:(t[e]??n).toLowerCase(),onChange:t=>o(e,t.target.value),children:c.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.name?.trim()?`${e.name} (${e.id})`:e.id},e.id))})]})]},e))})]})}function Me({icon:e,title:t,subtitle:n,configured:r,enabled:i,onToggle:o,toggleDisabled:s,onConfigure:c,onEdit:u,onRemove:d,ch:f}){return(0,P.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,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[(0,P.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:e}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),r?(0,P.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,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n})]})]}),r?(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,P.jsxs)(O,{children:[(0,P.jsx)(ue,{asChild:!0,children:(0,P.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":f.menuMoreAria,children:(0,P.jsx)(y,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,P.jsx)(fe,{children:(0,P.jsxs)(pe,{className:`z-[70] min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,P.jsx)(de,{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,P.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(l,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),f.menuEditConfig]})}),(0,P.jsx)(de,{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,P.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(D,{className:`size-4 shrink-0`,strokeWidth:1.75}),f.menuRemoveConfig]})})]})})]}),(0,P.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} — ${f.enableChannelAria}`,disabled:s,className:a(`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`,s&&`cursor-not-allowed opacity-50`),onClick:()=>void o(!i),children:(0,P.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,P.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,P.jsx)(b,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:c,children:f.hubConfigureButton})})]})}function Ne({tg:e,updateTelegram:t,ch:n,dmOpts:r,groupOpts:i,replyOpts:o,streamOpts:s,tgAccountsDraft:c,setTgAccountsDraft:l,tgAccountsError:u,onTgAccountsBlur:d}){let f=we;return(0,P.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.apiRoot}),(0,P.jsx)(`input`,{className:f(),value:e.apiRoot,onChange:e=>t({apiRoot:e.target.value}),placeholder:`https://api.telegram.org`})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.proxy}),(0,P.jsx)(`input`,{className:f(),value:e.proxy,onChange:e=>t({proxy:e.target.value}),placeholder:`http://proxy.example.com:8080`})]}),(0,P.jsx)(L,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,P.jsx)(L,{label:n.groupPolicy,value:e.groupPolicy,onChange:e=>t({groupPolicy:e}),options:i}),(0,P.jsx)(L,{label:n.replyToMode,value:e.replyToMode,onChange:e=>t({replyToMode:e}),options:o}),(0,P.jsx)(L,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:s}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.allowFromGroups}),(0,P.jsx)(`textarea`,{className:a(f(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`-1001234567890`,value:De(e.groupAllowFrom),onChange:e=>t({groupAllowFrom:Ee(e.target.value)})})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.historyLimit}),(0,P.jsx)(`input`,{type:`number`,min:10,max:200,className:f(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.textChunkLimit}),(0,P.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,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.telegramDebug]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.multiAccountJson}),(0,P.jsx)(`textarea`,{className:a(f(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:c,onChange:e=>l(e.target.value),onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),u?(0,P.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,P.jsx)(I,{children:n.multiAccountJsonDesc})]})]})}function Pe({wx:e,updateWeixin:t,ch:n,dmOpts:r,streamOpts:i,wxAccountsDraft:o,setWxAccountsDraft:s,wxAccountsError:c,onWxAccountsBlur:l,channelAgentRoutesWx:u,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}){let h=we;return(0,P.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.weixinAllowFrom}),(0,P.jsx)(`textarea`,{className:a(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,P.jsx)(I,{children:n.weixinAllowFromDesc})]}),(0,P.jsx)(L,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,P.jsx)(L,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:i}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.historyLimit}),(0,P.jsx)(`input`,{type:`number`,min:10,max:200,className:h(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.textChunkLimit}),(0,P.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,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.weixinRouteTag}),(0,P.jsx)(`input`,{className:h(),value:e.routeTag,onChange:e=>t({routeTag:e.target.value}),placeholder:n.routeTagPlaceholder}),(0,P.jsx)(I,{children:n.weixinRouteTagDesc})]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.weixinDebug]}),(0,P.jsx)(I,{children:n.weixinDebugDesc}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.weixinAccountsJson}),(0,P.jsx)(`textarea`,{className:a(h(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:o,onChange:e=>s(e.target.value),onBlur:l,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),c?(0,P.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c}):(0,P.jsx)(I,{children:n.weixinAccountsJsonDesc})]}),(0,P.jsx)(je,{accountIds:j(e),routes:u,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:n})]})}var Fe=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),R=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),z=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Ie=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Le=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Re=t((e=>{var t=R().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),ze=t((e=>{var t=R().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Be=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Ve=t((e=>{var t=z(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),He=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Ue=t((e=>{var t=He();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),We=t(((e,t)=>{var n=Ue();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Ge=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Ke=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
1
|
+
import{i as e,t}from"./rolldown-runtime-DWdDZTNf.js";import{i as n,t as r}from"./vendor-react-DbimaAId.js";import{i}from"./vendor-swr-B5fPo7KK.js";import{t as a}from"./cn-BMCV0OMB.js";import{$t as o,A as s,An as c,Hn as l,Jt as u,Kn as d,Kt as f,Lr as p,Rr as m,Wt as h,Yt as g,_r as _,an as v,br as y,cn as b,ct as x,dt as S,fn as C,ft as ee,j as w,lt as te,on as T,ot as ne,rn as E,sn as re,st as ie,u as ae,ut as oe,vn as D,vr as se,wr as ce,yr as le}from"./index-lV8FGWlt.js";import{a as ue,i as O,n as de,r as fe,t as pe}from"./dist-Dn-ufXyc.js";var k=e(n(),1);function A(e){return(e??``).trim().toLowerCase()}function me(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 he(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.botToken==`string`&&e.botToken.trim()?[`default`]:[]}function j(e){return Object.keys(e.accounts??{}).sort()}function ge(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 M(e,t,n,r,i){let a={},o={},s={};for(let n of t)a[n]=(e.find(e=>A(e.match?.channel)===`telegram`&&A(e.match?.accountId)===A(n)&&me(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>A(e.match?.channel)===`weixin`&&A(e.match?.accountId)===A(t)&&me(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>A(e.match?.channel)===`feishu`&&A(e.match?.accountId)===A(t)&&me(e))?.agentId??i).trim().toLowerCase();return{telegram:a,weixin:o,feishu:s}}function N(e,t,n,r,i,a){let o=new Set(n.map(A)),s=new Set(r.map(A)),c=new Set(i.map(A)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!me(e))return!0;let t=A(e.match.channel),n=A(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[A(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[A(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[A(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 _e(){return{bindingsFull:[],channelAgentRoutes:{telegram:{},weixin:{},feishu:{}},defaultAgentId:`main`,telegram:{enabled:!1,botToken:``,apiRoot:``,debug:!1,allowFrom:[],groupAllowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,proxy:``,accounts:{}},weixin:{enabled:!1,dmPolicy:`pairing`,allowFrom:[],debug:!1,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,routeTag:``,accounts:{}},feishu:{enabled:!1,defaultAccount:``,appId:``,appSecret:``,domain:`feishu`,connectionMode:`websocket`,verificationToken:``,encryptKey:``,webhookHost:`127.0.0.1`,webhookPort:3e3,webhookPath:`/feishu/events`,dmPolicy:`pairing`,groupPolicy:`allowlist`,allowFrom:[],groupAllowFrom:[],requireMention:!0,historyLimit:50,textChunkLimit:4e3,renderMode:`auto`,streaming:!1,reactionNotifications:`own`,tools:{doc:!0,wiki:!0,drive:!0,scopes:!0,bitable:!0,perm:!1},actions:{reactions:!0},accounts:{}}}}function ve(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=i?.accounts,l=c&&typeof c==`object`&&!Array.isArray(c)?c:{},u=(()=>{let t=(e&&typeof e==`object`?e:{}).bindings;return Array.isArray(t)?t:[]})(),d=(()=>{let t=(e&&typeof e==`object`?e:{}).agents;return t&&typeof t==`object`?t:{}})(),f=typeof d.defaultId==`string`&&d.defaultId.trim()?d.defaultId.trim().toLowerCase():`main`,p={telegram:{enabled:!!r?.enabled,botToken:typeof r?.botToken==`string`?r.botToken:``,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||`pairing`,allowFrom:Array.isArray(i?.allowFrom)?[...i.allowFrom]:[],debug:!!i?.debug,streamMode:i?.streamMode??`partial`,historyLimit:typeof i?.historyLimit==`number`?i.historyLimit:50,textChunkLimit:typeof i?.textChunkLimit==`number`?i.textChunkLimit:4e3,routeTag:i?.routeTag==null?``:String(i.routeTag),accounts:{...l}},feishu:{enabled:!!a?.enabled,defaultAccount:typeof a?.defaultAccount==`string`?a.defaultAccount:``,appId:typeof a?.appId==`string`?a.appId:``,appSecret:typeof a?.appSecret==`string`?a.appSecret:``,domain:typeof a?.domain==`string`&&a.domain||`feishu`,connectionMode:a?.connectionMode||`websocket`,verificationToken:typeof a?.verificationToken==`string`?a.verificationToken:``,encryptKey:typeof a?.encryptKey==`string`?a.encryptKey:``,webhookHost:typeof a?.webhookHost==`string`?a.webhookHost:`127.0.0.1`,webhookPort:typeof a?.webhookPort==`number`?a.webhookPort:3e3,webhookPath:typeof a?.webhookPath==`string`?a.webhookPath:`/feishu/events`,dmPolicy:a?.dmPolicy||`pairing`,groupPolicy:a?.groupPolicy||`allowlist`,allowFrom:Array.isArray(a?.allowFrom)?[...a.allowFrom]:[],groupAllowFrom:Array.isArray(a?.groupAllowFrom)?[...a.groupAllowFrom]:[],requireMention:a?.requireMention===void 0?!0:!!a.requireMention,historyLimit:typeof a?.historyLimit==`number`?a.historyLimit:50,textChunkLimit:typeof a?.textChunkLimit==`number`?a.textChunkLimit:4e3,renderMode:a?.renderMode||`auto`,streaming:a?.streaming===void 0?!1:!!a.streaming,reactionNotifications:a?.reactionNotifications||`own`,tools:a?.tools&&typeof a.tools==`object`&&!Array.isArray(a.tools)?{...a.tools}:void 0,actions:a?.actions&&typeof a.actions==`object`&&!Array.isArray(a.actions)?{...a.actions}:void 0,accounts:a?.accounts&&typeof a.accounts==`object`&&!Array.isArray(a.accounts)?{...a.accounts}:{}}},m=M(u,he(p.telegram),j(p.weixin),ge(p.feishu),f);return{...p,bindingsFull:u.map(e=>({...e})),channelAgentRoutes:m,defaultAgentId:f}}async function ye(e){return(await f(h(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function be(e){return(await f(h(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function xe(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=N(e.bindingsFull,e.channelAgentRoutes,he(t),j(n),ge(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await f(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({bindings:i,channels:{telegram:{enabled:t.enabled,botToken:t.botToken,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 s(),o?ve(o):{...e,bindingsFull:i}}async function Se(e){return(await f(h(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Ce(e){return(await f(h(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function we(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T,`dark:border-edge`)}function Te(){return a(v,E)}function Ee(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).map(e=>/^-?\d+$/.test(e)?Number(e):e)}function De(e){return e.map(String).join(`, `)}function Oe(e){return!!e.botToken?.trim()||Object.keys(e.accounts??{}).length>0}function ke(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function Ae(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}var P=r();function F({children:e}){return(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e})}function I({children:e}){return(0,P.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:e})}function L({label:e,value:t,onChange:n,options:r}){return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:e}),(0,P.jsx)(`select`,{className:Te(),value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,P.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function je({accountIds:e,routes:t,defaultAgentId:n,agentItems:r,disabled:i,onChange:o,ch:s}){if(e.length===0)return null;let c=r.length>0?r:[{id:n}];return(0,P.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(F,{children:s.agentRoutingTitle}),(0,P.jsx)(I,{children:s.agentRoutingHint})]}),(0,P.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,P.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,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:s.agentRoutingAccountLabel}),(0,P.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:e,children:e})]}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${e}`,children:s.agentRoutingAgentLabel}),(0,P.jsx)(`select`,{id:`agent-route-${e}`,className:a(we(),E),disabled:i,value:(t[e]??n).toLowerCase(),onChange:t=>o(e,t.target.value),children:c.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.name?.trim()?`${e.name} (${e.id})`:e.id},e.id))})]})]},e))})]})}function Me({icon:e,title:t,subtitle:n,configured:r,enabled:i,onToggle:o,toggleDisabled:s,onConfigure:c,onEdit:u,onRemove:d,ch:f}){return(0,P.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,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[(0,P.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:e}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),r?(0,P.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,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n})]})]}),r?(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,P.jsxs)(O,{children:[(0,P.jsx)(ue,{asChild:!0,children:(0,P.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":f.menuMoreAria,children:(0,P.jsx)(y,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,P.jsx)(fe,{children:(0,P.jsxs)(pe,{className:`z-[70] min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,P.jsx)(de,{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,P.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(l,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),f.menuEditConfig]})}),(0,P.jsx)(de,{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,P.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(D,{className:`size-4 shrink-0`,strokeWidth:1.75}),f.menuRemoveConfig]})})]})})]}),(0,P.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} — ${f.enableChannelAria}`,disabled:s,className:a(`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`,s&&`cursor-not-allowed opacity-50`),onClick:()=>void o(!i),children:(0,P.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,P.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,P.jsx)(b,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:c,children:f.hubConfigureButton})})]})}function Ne({tg:e,updateTelegram:t,ch:n,dmOpts:r,groupOpts:i,replyOpts:o,streamOpts:s,tgAccountsDraft:c,setTgAccountsDraft:l,tgAccountsError:u,onTgAccountsBlur:d}){let f=we;return(0,P.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.apiRoot}),(0,P.jsx)(`input`,{className:f(),value:e.apiRoot,onChange:e=>t({apiRoot:e.target.value}),placeholder:`https://api.telegram.org`})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.proxy}),(0,P.jsx)(`input`,{className:f(),value:e.proxy,onChange:e=>t({proxy:e.target.value}),placeholder:`http://proxy.example.com:8080`})]}),(0,P.jsx)(L,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,P.jsx)(L,{label:n.groupPolicy,value:e.groupPolicy,onChange:e=>t({groupPolicy:e}),options:i}),(0,P.jsx)(L,{label:n.replyToMode,value:e.replyToMode,onChange:e=>t({replyToMode:e}),options:o}),(0,P.jsx)(L,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:s}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.allowFromGroups}),(0,P.jsx)(`textarea`,{className:a(f(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`-1001234567890`,value:De(e.groupAllowFrom),onChange:e=>t({groupAllowFrom:Ee(e.target.value)})})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.historyLimit}),(0,P.jsx)(`input`,{type:`number`,min:10,max:200,className:f(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.textChunkLimit}),(0,P.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,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.telegramDebug]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.multiAccountJson}),(0,P.jsx)(`textarea`,{className:a(f(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:c,onChange:e=>l(e.target.value),onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),u?(0,P.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,P.jsx)(I,{children:n.multiAccountJsonDesc})]})]})}function Pe({wx:e,updateWeixin:t,ch:n,dmOpts:r,streamOpts:i,wxAccountsDraft:o,setWxAccountsDraft:s,wxAccountsError:c,onWxAccountsBlur:l,channelAgentRoutesWx:u,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}){let h=we;return(0,P.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.weixinAllowFrom}),(0,P.jsx)(`textarea`,{className:a(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,P.jsx)(I,{children:n.weixinAllowFromDesc})]}),(0,P.jsx)(L,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,P.jsx)(L,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:i}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.historyLimit}),(0,P.jsx)(`input`,{type:`number`,min:10,max:200,className:h(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.textChunkLimit}),(0,P.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,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.weixinRouteTag}),(0,P.jsx)(`input`,{className:h(),value:e.routeTag,onChange:e=>t({routeTag:e.target.value}),placeholder:n.routeTagPlaceholder}),(0,P.jsx)(I,{children:n.weixinRouteTagDesc})]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.weixinDebug]}),(0,P.jsx)(I,{children:n.weixinDebugDesc}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.weixinAccountsJson}),(0,P.jsx)(`textarea`,{className:a(h(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:o,onChange:e=>s(e.target.value),onBlur:l,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),c?(0,P.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c}):(0,P.jsx)(I,{children:n.weixinAccountsJsonDesc})]}),(0,P.jsx)(je,{accountIds:j(e),routes:u,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:n})]})}var Fe=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),R=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),z=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Ie=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Le=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Re=t((e=>{var t=R().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),ze=t((e=>{var t=R().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Be=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Ve=t((e=>{var t=z(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),He=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Ue=t((e=>{var t=He();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),We=t(((e,t)=>{var n=Ue();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Ge=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Ke=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
2
2
|
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),B=t((e=>{var t=Ge(),n=Ke();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),V=t((e=>{var t=R(),n=Ve(),r=z(),i=B(),a=Ge(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),qe=t((e=>{var t=R(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),H=t(((e,t)=>{var n=B();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),Je=t(((e,t)=>{var n=B(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),U=t(((e,t)=>{var n=B();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),Ye=t(((e,t)=>{var n=B(),r=R();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
3
3
|
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),W=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),Xe=t((e=>{var t=B(),n=H(),r=Je(),i=U(),a=Ye(),o=Ke(),s=R(),c=W();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
|
|
4
4
|
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),G=t((e=>{var t=R(),n=z(),r=Ie(),i=Le(),a=Re(),o=ze(),s=Be(),c=Ve(),l=We(),u=V(),d=qe(),f=B(),p=Xe();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
|
|
@@ -6,4 +6,4 @@ The chosen QR Code version cannot contain this amount of data.
|
|
|
6
6
|
Minimum version required to store current data is: `+c+`.
|
|
7
7
|
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),Ze=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),K=t((e=>{var t=Ze();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Qe=t((e=>{var t=Ze();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
8
8
|
`;return typeof a==`function`&&a(null,p),p}})),q=e(t((e=>{var t=Fe(),n=G(),r=K(),i=Qe();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function $e({open:e,onOpenChange:t,ch:n,onSetupSuccess:r}){let[i,o]=(0,k.useState)(!1),[s,c]=(0,k.useState)(`feishu`),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(null),[p,m]=(0,k.useState)(null),[h,g]=(0,k.useState)(null),[_,v]=(0,k.useState)(!1),[y,w]=(0,k.useState)(!0),T=(0,k.useCallback)(async()=>{m(null),u(null),f(null),o(!0),w(!1);try{let e=await Se({domain:s});f(e.qrUrl),u(e.sessionKey)}catch(e){m(e instanceof Error?e.message:`Start failed`),w(!0)}finally{o(!1)}},[s]);(0,k.useEffect)(()=>{e||(u(null),f(null),m(null),g(null),v(!1),w(!0),o(!1))},[e]),(0,k.useEffect)(()=>{if(!l)return;let e=!1,n,i=async()=>{try{let i=await Ce(l);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),u(null),i.ok?(f(null),t(!1),r({appId:i.appId,domain:i.domain,openId:i.openId})):(m(i.message),f(null),w(!0));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),m(i.message),u(null),f(null),w(!0))}catch(t){e||(n!==void 0&&window.clearInterval(n),m(t instanceof Error?t.message:`Request failed`),u(null),f(null),w(!0))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[l,t,r]),(0,k.useEffect)(()=>{if(!d){g(null),v(!1);return}let e=!1;return v(!1),q.toDataURL(d,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||g(t)}).catch(()=>{e||(v(!0),g(null))}),()=>{e=!0}},[d]);let E=!!(d&&l);return(0,P.jsx)(S,{open:e,onOpenChange:t,children:(0,P.jsxs)(oe,{children:[(0,P.jsx)(te,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,P.jsx)(ne,{asChild:!0,children:(0,P.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,P.jsx)(C,{className:`size-4`})})}),(0,P.jsx)(ee,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,P.jsx)(x,{className:`sr-only`,children:n.feishuQrModalSubtitle}),(0,P.jsxs)(`div`,{className:`text-center`,children:[(0,P.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.feishuQrModalTitle}),(0,P.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.feishuQrModalSubtitle})]}),y&&!E?(0,P.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`feishu-qr-domain`,children:n.feishuQrDomainLabel}),(0,P.jsxs)(`select`,{id:`feishu-qr-domain`,className:`w-full rounded-lg border border-edge bg-surface px-3 py-2 text-sm text-fg outline-none focus:ring-2 focus:ring-accent/40`,value:s,onChange:e=>c(e.target.value),children:[(0,P.jsx)(`option`,{value:`feishu`,children:`feishu (open.feishu.cn) — China`}),(0,P.jsx)(`option`,{value:`lark`,children:`lark (open.larksuite.com) — International`})]})]}),(0,P.jsx)(b,{type:`button`,variant:`primary`,className:`h-11 w-full rounded-full`,disabled:i,onClick:()=>void T(),children:i?n.feishuQrStarting:n.feishuQrStartButton})]}):null,(0,P.jsxs)(`div`,{className:`mt-6 flex min-h-[200px] flex-col items-center justify-center`,children:[i&&!E?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.feishuQrStarting}):null,p?(0,P.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:p}):null,E&&d&&!p?(0,P.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.feishuQrScanHint}),h&&!_?(0,P.jsx)(`img`,{src:h,alt:``,className:`h-52 w-52 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,!h&&!_?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,_?(0,P.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,P.jsx)(`p`,{className:`max-w-[16rem] text-center text-sm text-fg-muted`,children:n.feishuQrImageError}),(0,P.jsxs)(`a`,{href:d,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-sm text-accent underline-offset-2 hover:underline`,children:[(0,P.jsx)(le,{className:`size-3.5 shrink-0`}),n.feishuQrOpenLink]})]}):null]}):null]}),E?(0,P.jsx)(`div`,{className:`mt-6`,children:(0,P.jsx)(b,{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:i,onClick:()=>void T(),children:i?n.feishuQrStarting:n.feishuQrRegenerate})}):null]})]})})}function et({open:e,onOpenChange:t,ch:n,onLoginSuccess:r,moreSettings:i}){let[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(null),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(null),[m,h]=(0,k.useState)(null),[g,_]=(0,k.useState)(null),[v,y]=(0,k.useState)(!1),w=(0,k.useCallback)(async()=>{p(null),h(null),l(null),s(!0);try{let e=await ye();d(e.qrcodeUrl),l(e.sessionKey)}catch(e){p(e instanceof Error?e.message:`Start failed`)}finally{s(!1)}},[]);(0,k.useEffect)(()=>{if(!e){l(null),d(null),p(null),_(null),y(!1),h(null);return}w()},[e,w]),(0,k.useEffect)(()=>{if(!c)return;let e=!1,i,a=async()=>{try{let a=await be(c);if(e)return;if(a.phase===`polling`){d(a.qrcodeUrl),a.qrStatus===`scaned`?h(n.weixinQrLoginScanned):h(null);return}if(a.phase===`done`){i!==void 0&&(window.clearInterval(i),i=void 0),l(null),a.ok?(d(null),t(!1),await r()):(p(a.message),d(null));return}a.phase===`unknown`&&h(null)}catch(t){e||(i!==void 0&&window.clearInterval(i),p(t instanceof Error?t.message:`Request failed`),l(null),d(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[c,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,k.useEffect)(()=>{if(!u){_(null),y(!1);return}let e=!1;return y(!1),q.toDataURL(u,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||_(t)}).catch(()=>{e||(y(!0),_(null))}),()=>{e=!0}},[u]);let T=!!(u&&c);return(0,P.jsx)(S,{open:e,onOpenChange:t,children:(0,P.jsxs)(oe,{children:[(0,P.jsx)(te,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,P.jsx)(ne,{asChild:!0,children:(0,P.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,P.jsx)(C,{className:`size-4`})})}),(0,P.jsx)(ee,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,P.jsx)(x,{className:`sr-only`,children:n.weixinQrModalSubtitle}),(0,P.jsxs)(`div`,{className:`text-center`,children:[(0,P.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.weixinQrModalTitle}),(0,P.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.weixinQrModalSubtitle})]}),(0,P.jsxs)(`div`,{className:`mt-6 flex min-h-[200px] flex-col items-center justify-center`,children:[o&&!T?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.weixinQrLoginBusy}):null,f?(0,P.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:f}):null,m&&!f?(0,P.jsx)(`p`,{className:`mb-3 text-center text-sm text-accent`,children:m}):null,T&&u&&!f?(0,P.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[g&&!v?(0,P.jsx)(`img`,{src:g,alt:``,className:`h-52 w-52 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,!g&&!v?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,v?(0,P.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,P.jsx)(`p`,{className:`max-w-[16rem] text-center text-sm text-fg-muted`,children:n.weixinQrImageError}),(0,P.jsxs)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-sm text-accent underline-offset-2 hover:underline`,children:[(0,P.jsx)(le,{className:`size-3.5 shrink-0`}),n.weixinQrOpenLink]})]}):null]}):null]}),(0,P.jsx)(`div`,{className:`mt-6`,children:(0,P.jsx)(b,{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:o,onClick:()=>void w(),children:o?n.weixinQrLoginBusy:n.weixinQrRegenerate})}),i?(0,P.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function J(){let e=we,t=o(e=>e.language),n=re(t),r=n.channelsSettings,s=!!u(e=>e.token),[l,f]=(0,k.useState)(null),[h,v]=(0,k.useState)(null),[y,T]=(0,k.useState)(!1),[E,D]=(0,k.useState)(null),[ue,O]=(0,k.useState)(!1),[de,fe]=(0,k.useState)(!1),[pe,A]=(0,k.useState)(!1),[me,j]=(0,k.useState)(!1),[M,N]=(0,k.useState)(null),[ye,be]=(0,k.useState)(null),[Se,Ce]=(0,k.useState)(!1),[Te,L]=(0,k.useState)(null),[Fe,R]=(0,k.useState)(!1),[z,Ie]=(0,k.useState)(!1),[Le,Re]=(0,k.useState)(!1),[ze,Be]=(0,k.useState)(!1),[Ve,He]=(0,k.useState)(!1),[Ue,We]=(0,k.useState)(!1),[Ge,Ke]=(0,k.useState)(!1),[B,V]=(0,k.useState)(``),[qe,H]=(0,k.useState)(``),[Je,U]=(0,k.useState)(``),[Ye,W]=(0,k.useState)(``),[Xe,G]=(0,k.useState)(``),[Ze,K]=(0,k.useState)(``),{data:Qe}=i(s?`gateway-chat-agents-ch`:null,ae,{revalidateOnFocus:!1}),{data:q,error:J,isLoading:tt,mutate:nt}=w(s),Y=(0,k.useMemo)(()=>q?.payload?.config===void 0?null:ve(q.payload.config),[q]),rt=(0,k.useMemo)(()=>!l||!h?!1:JSON.stringify(l)!==JSON.stringify(h),[l,h]);(0,k.useEffect)(()=>{if(!s){f(null),v(null);return}Y!==null&&(rt||(f(Y),v(structuredClone(Y)),V(JSON.stringify(Y.telegram.accounts??{},null,2)),H(``),U(JSON.stringify(Y.weixin.accounts??{},null,2)),W(``),G(JSON.stringify(Y.feishu?.accounts??{},null,2)),K(``),O(!1)))},[s,Y,rt]);let it=!!(s&&tt&&q===void 0&&!J),at=J instanceof Error?J.message:J?String(J):null,ot=(0,k.useCallback)((e,t,n)=>{f(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()}}}})},[]),X=(0,k.useCallback)(e=>{f(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),st=(0,k.useCallback)(e=>{f(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),Z=(0,k.useCallback)(e=>{f(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]),ct=(0,k.useCallback)(async()=>{if(!l||y)return!1;T(!0),D(null),O(!1);try{let e=await xe(l);f(e);let t=structuredClone(e);return v(t),V(JSON.stringify(t.telegram.accounts??{},null,2)),H(``),U(JSON.stringify(t.weixin.accounts??{},null,2)),W(``),G(JSON.stringify(t.feishu?.accounts??{},null,2)),K(``),O(!0),window.setTimeout(()=>O(!1),2500),!0}catch(e){return D(e instanceof Error?e.message:r.saveError),!1}finally{T(!1)}},[l,y,r.saveError]),lt=(0,k.useCallback)(async(e,t)=>{if(!l||y)return;let n=l,i=e===`weixin`?{...l,weixin:{...l.weixin,enabled:t}}:e===`telegram`?{...l,telegram:{...l.telegram,enabled:t}}:{...l,feishu:{...l.feishu,enabled:t}};f(i),T(!0),D(null);try{let e=await xe(i);f(e);let t=structuredClone(e);v(t),V(JSON.stringify(t.telegram.accounts??{},null,2)),U(JSON.stringify(t.weixin.accounts??{},null,2)),G(JSON.stringify(t.feishu?.accounts??{},null,2))}catch(e){D(e instanceof Error?e.message:r.saveError),f(n)}finally{T(!1)}},[l,y,r.saveError]),ut=(0,k.useCallback)(async()=>{if(!l||!M||y)return;let e=_e(),t=M===`weixin`?{...l,weixin:e.weixin}:M===`telegram`?{...l,telegram:e.telegram}:{...l,feishu:e.feishu};T(!0),D(null);try{let e=await xe(t);f(e);let n=structuredClone(e);v(n),V(JSON.stringify(n.telegram.accounts??{},null,2)),U(JSON.stringify(n.weixin.accounts??{},null,2)),H(``),W(``),G(JSON.stringify(n.feishu?.accounts??{},null,2)),K(``),N(null),O(!0),window.setTimeout(()=>O(!1),2500)}catch(e){D(e instanceof Error?e.message:r.saveError)}finally{T(!1)}},[l,M,y,r.saveError]),dt=(0,k.useCallback)(async()=>{let e=l?.telegram.botToken;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),He(!0),window.setTimeout(()=>He(!1),2e3))},[l?.telegram.botToken]),ft=(0,k.useCallback)(e=>{Z({appId:e.appId,domain:e.domain,enabled:!0}),nt(),L(r.feishuQrSetupSuccess),window.setTimeout(()=>L(null),4e3)},[Z,nt,r.feishuQrSetupSuccess]),pt=(0,k.useCallback)(async()=>{let e=l?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),We(!0),window.setTimeout(()=>We(!1),2e3))},[l]),mt=(0,k.useCallback)(async()=>{let e=l?.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(()=>{}),Ke(!0),window.setTimeout(()=>Ke(!1),2e3)},[l]),ht=(0,k.useCallback)(()=>{if(!l)return;let e=B.trim();if(!e){X({accounts:{}}),H(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(r.jsonObjectAccounts);X({accounts:t}),H(``)}catch(e){H(e instanceof Error?e.message:r.jsonInvalid)}},[l,B,X,r.jsonObjectAccounts,r.jsonInvalid]),gt=(0,k.useCallback)(()=>{if(!l)return;let e=Je.trim();if(!e){st({accounts:{}}),W(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(r.jsonObjectAccounts);st({accounts:t}),W(``)}catch(e){W(e instanceof Error?e.message:r.jsonInvalid)}},[l,Je,st,r.jsonObjectAccounts,r.jsonInvalid]),_t=(0,k.useCallback)(()=>{if(!l)return;let e=Xe.trim();if(!e){Z({accounts:{}}),K(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(r.jsonObjectAccounts);Z({accounts:t}),K(``)}catch(e){K(e instanceof Error?e.message:r.jsonInvalid)}},[l,Xe,Z,r.jsonObjectAccounts,r.jsonInvalid]),vt=(0,k.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:r.policy.dm[e]})),[r.policy.dm]),yt=(0,k.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:r.policy.group[e]})),[r.policy.group]),bt=(0,k.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:r.policy.reply[e]})),[r.policy.reply]),xt=(0,k.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:r.policy.stream[e]})),[r.policy.stream]);if(!s)return(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.channels}),(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]});if(it)return(0,P.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,P.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,P.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,P.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r.loading})]});if(!l)return(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:E??at??r.loadError}),(0,P.jsx)(b,{type:`button`,variant:`secondary`,onClick:()=>void nt(),children:r.retry})]});let Q=l.telegram,St=l.weixin,$=l.feishu,Ct=h?.telegram?.botToken??``,wt=!z&&!!String(Ct).trim()&&Q.botToken===Ct,Tt=h?.feishu?.appSecret??``,Et=!Le&&!!String(Tt).trim()&&$.appSecret===Tt,Dt=ke(St),Ot=Oe(Q),kt=Ae($),At=(0,P.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,P.jsx)(`summary`,{className:`cursor-pointer list-none px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover [&::-webkit-details-marker]:hidden`,children:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,P.jsx)(p,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),r.advancedShow]})}),(0,P.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,P.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:r.weixinAdvancedHint}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:St.enabled,onChange:e=>st({enabled:e.target.checked})}),(0,P.jsx)(`span`,{children:r.enableWeixinAria})]}),(0,P.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,P.jsx)(Pe,{wx:St,updateWeixin:st,ch:r,dmOpts:vt,streamOpts:xt,wxAccountsDraft:Je,setWxAccountsDraft:U,wxAccountsError:Ye,onWxAccountsBlur:gt,channelAgentRoutesWx:l.channelAgentRoutes.weixin,defaultAgentId:l.defaultAgentId,agentItems:Qe?.items??[],onAgentRouteChange:(e,t)=>ot(`weixin`,e,t),routingDisabled:y})}),(0,P.jsx)(b,{type:`button`,variant:`primary`,className:`w-full`,disabled:!rt||y,onClick:async()=>{await ct()},children:y?r.saving:r.save})]})]});return(0,P.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.channels}),(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,P.jsxs)(`a`,{href:g(t,`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:[r.docsLink,(0,P.jsx)(le,{className:`size-3.5`})]})]}),rt?(0,P.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,ue?(0,P.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.saved}):null,E?(0,P.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E}):null,ye?(0,P.jsx)(`p`,{className:`text-xs text-accent`,children:ye}):null,Te?(0,P.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:Te}):null,(0,P.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,P.jsx)(Me,{icon:(0,P.jsx)(d,{className:`size-6 text-accent`,strokeWidth:1.75}),title:r.weixinTitle,subtitle:r.weixinSubtitle,configured:Dt,enabled:St.enabled,toggleDisabled:y,onToggle:e=>void lt(`weixin`,e),onConfigure:()=>fe(!0),onEdit:()=>fe(!0),onRemove:()=>N(`weixin`),ch:r}),(0,P.jsx)(Me,{icon:(0,P.jsx)(c,{className:`size-6 text-accent`,strokeWidth:1.75}),title:r.telegramTitle,subtitle:r.telegramSubtitle,configured:Ot,enabled:Q.enabled,toggleDisabled:y,onToggle:e=>void lt(`telegram`,e),onConfigure:()=>A(!0),onEdit:()=>A(!0),onRemove:()=>N(`telegram`),ch:r}),(0,P.jsx)(Me,{icon:(0,P.jsx)(d,{className:`size-6 text-accent`,strokeWidth:1.75}),title:r.feishuTitle,subtitle:r.feishuSubtitle,configured:kt,enabled:$.enabled,toggleDisabled:y,onToggle:e=>void lt(`feishu`,e),onConfigure:()=>j(!0),onEdit:()=>j(!0),onRemove:()=>N(`feishu`),ch:r})]}),(0,P.jsx)(et,{open:de,onOpenChange:fe,ch:r,onLoginSuccess:async()=>{await nt(),be(r.weixinQrLoginSuccess),window.setTimeout(()=>be(null),4e3)},moreSettings:At}),(0,P.jsx)($e,{open:Se,onOpenChange:Ce,ch:r,onSetupSuccess:ft}),(0,P.jsx)(S,{open:pe,onOpenChange:A,children:(0,P.jsxs)(oe,{children:[(0,P.jsx)(te,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(ee,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.telegramTitle}),(0,P.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:r.telegramSubtitle})]}),(0,P.jsx)(ne,{asChild:!0,children:(0,P.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":r.modalCancel,children:(0,P.jsx)(C,{className:`size-4`})})})]}),(0,P.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:Q.enabled,onChange:e=>X({enabled:e.target.checked})}),(0,P.jsx)(`span`,{children:r.enableTelegramAria})]}),(0,P.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsxs)(F,{children:[r.telegramToken,(0,P.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:z?`text`:`password`,autoComplete:`off`,readOnly:wt,value:wt?`*`.repeat(Math.max(1,Q.botToken.length)):Q.botToken,onChange:e=>{wt||X({botToken:e.target.value})},placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`}),Q.botToken?(0,P.jsxs)(b,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void dt(),children:[Ve?(0,P.jsx)(m,{className:`size-3.5`}):(0,P.jsx)(ce,{className:`size-3.5`}),Ve?r.copied:r.copy]}):null,(0,P.jsxs)(b,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Ie(e=>!e),children:[z?(0,P.jsx)(se,{className:`size-3.5`}):(0,P.jsx)(_,{className:`size-3.5`}),z?r.hide:r.show]})]}),(0,P.jsx)(I,{children:r.telegramTokenDesc})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.allowFromDm}),(0,P.jsx)(`textarea`,{className:a(e(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`123456789, 987654321`,value:De(Q.allowFrom),onChange:e=>X({allowFrom:Ee(e.target.value)})}),(0,P.jsx)(I,{children:r.allowFromDmDesc})]}),l?(0,P.jsx)(je,{accountIds:he(Q),routes:l.channelAgentRoutes.telegram,defaultAgentId:l.defaultAgentId,agentItems:Qe?.items??[],disabled:y,onChange:(e,t)=>ot(`telegram`,e,t),ch:r}):null,(0,P.jsxs)(b,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:()=>R(e=>!e),children:[(0,P.jsx)(p,{className:a(`mr-1 size-4 transition-transform`,Fe&&`rotate-180`)}),Fe?r.advancedHide:r.advancedShow]}),Fe?(0,P.jsx)(Ne,{tg:Q,updateTelegram:X,ch:r,dmOpts:vt,groupOpts:yt,replyOpts:bt,streamOpts:xt,tgAccountsDraft:B,setTgAccountsDraft:V,tgAccountsError:qe,onTgAccountsBlur:ht}):null]}),(0,P.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,P.jsx)(b,{type:`button`,variant:`secondary`,onClick:()=>A(!1),children:r.modalCancel}),(0,P.jsx)(b,{type:`button`,variant:`primary`,disabled:!rt||y,onClick:async()=>{await ct()&&A(!1)},children:y?r.saving:r.save})]})]})]})}),(0,P.jsx)(S,{open:me,onOpenChange:j,children:(0,P.jsxs)(oe,{children:[(0,P.jsx)(te,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(ee,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.feishuTitle}),(0,P.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:r.feishuSubtitle})]}),(0,P.jsx)(ne,{asChild:!0,children:(0,P.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":r.modalCancel,children:(0,P.jsx)(C,{className:`size-4`})})})]}),(0,P.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:$.enabled,onChange:e=>Z({enabled:e.target.checked})}),(0,P.jsx)(`span`,{children:r.enableFeishuAria})]}),kt?null:(0,P.jsx)(`div`,{className:`mt-6 rounded-xl border border-dashed border-accent/40 bg-accent/5 px-4 py-3 dark:bg-accent/10`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.feishuQrSetupTitle}),(0,P.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:r.feishuQrSetupDesc})]}),(0,P.jsx)(b,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:()=>Ce(!0),children:r.feishuQrSetupButton})]})}),(0,P.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsxs)(F,{children:[r.feishuAppId,(0,P.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),value:$.appId,onChange:e=>Z({appId:e.target.value}),placeholder:`cli_xxx`}),(0,P.jsx)(I,{children:r.feishuAppIdDesc})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsxs)(F,{children:[r.feishuAppSecret,(0,P.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:Le?`text`:`password`,autoComplete:`off`,readOnly:Et,value:Et?`*`.repeat(Math.max(1,$.appSecret.length)):$.appSecret,onChange:e=>{Et||Z({appSecret:e.target.value})},placeholder:`••••••••`}),$.appSecret?(0,P.jsxs)(b,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void pt(),children:[Ue?(0,P.jsx)(m,{className:`size-3.5`}):(0,P.jsx)(ce,{className:`size-3.5`}),Ue?r.copied:r.copy]}):null,(0,P.jsxs)(b,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Re(e=>!e),children:[Le?(0,P.jsx)(se,{className:`size-3.5`}):(0,P.jsx)(_,{className:`size-3.5`}),Le?r.hide:r.show]})]}),(0,P.jsx)(I,{children:r.feishuAppSecretDesc})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.feishuDomain}),(0,P.jsxs)(`select`,{className:e(),value:String($.domain||`feishu`),onChange:e=>Z({domain:e.target.value}),children:[(0,P.jsx)(`option`,{value:`feishu`,children:`feishu`}),(0,P.jsx)(`option`,{value:`lark`,children:`lark`})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.connectionMode}),(0,P.jsxs)(`select`,{className:e(),value:$.connectionMode,onChange:e=>Z({connectionMode:e.target.value}),children:[(0,P.jsx)(`option`,{value:`websocket`,children:`websocket`}),(0,P.jsx)(`option`,{value:`webhook`,children:`webhook`})]}),(0,P.jsx)(I,{children:r.connectionModeDesc})]})]}),$.connectionMode===`webhook`?(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.webhookTitle}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsxs)(b,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Be(e=>!e),children:[ze?(0,P.jsx)(se,{className:`size-3.5`}):(0,P.jsx)(_,{className:`size-3.5`}),ze?r.hide:r.show]}),(0,P.jsxs)(b,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void mt(),children:[Ge?(0,P.jsx)(m,{className:`size-3.5`}):(0,P.jsx)(ce,{className:`size-3.5`}),Ge?r.copied:r.copy]})]})]}),(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.verificationToken}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:ze?`text`:`password`,autoComplete:`off`,value:$.verificationToken??``,onChange:e=>Z({verificationToken:e.target.value})}),(0,P.jsx)(I,{children:r.verificationTokenDesc})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.encryptKey}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:ze?`text`:`password`,autoComplete:`off`,value:$.encryptKey??``,onChange:e=>Z({encryptKey:e.target.value})}),(0,P.jsx)(I,{children:r.encryptKeyDesc})]})]}),(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,P.jsx)(F,{children:r.webhookHost}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),value:$.webhookHost??``,onChange:e=>Z({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.webhookPort}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String($.webhookPort??``),onChange:e=>Z({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,P.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.webhookPath}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),value:$.webhookPath??``,onChange:e=>Z({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,P.jsx)(I,{children:r.webhookPathDesc})]})]}):null,(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.renderMode}),(0,P.jsxs)(`select`,{className:e(),value:$.renderMode,onChange:e=>Z({renderMode:e.target.value}),children:[(0,P.jsx)(`option`,{value:`auto`,children:`auto`}),(0,P.jsx)(`option`,{value:`raw`,children:`raw`}),(0,P.jsx)(`option`,{value:`card`,children:`card`})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.reactionNotifications}),(0,P.jsxs)(`select`,{className:e(),value:$.reactionNotifications,onChange:e=>Z({reactionNotifications:e.target.value}),children:[(0,P.jsx)(`option`,{value:`off`,children:`off`}),(0,P.jsx)(`option`,{value:`own`,children:`own`}),(0,P.jsx)(`option`,{value:`all`,children:`all`})]})]})]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:$.streaming,onChange:e=>Z({streaming:e.target.checked})}),r.enableStreaming]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.dmPolicy}),(0,P.jsx)(`select`,{className:e(),value:$.dmPolicy,onChange:e=>Z({dmPolicy:e.target.value}),children:vt.map(e=>(0,P.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.groupPolicy}),(0,P.jsx)(`select`,{className:e(),value:$.groupPolicy,onChange:e=>Z({groupPolicy:e.target.value}),children:yt.map(e=>(0,P.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:$.requireMention,onChange:e=>Z({requireMention:e.target.checked})}),r.requireMention]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.allowFromDm}),(0,P.jsx)(`textarea`,{className:a(e(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`ou_xxx, on_xxx`,value:De($.allowFrom),onChange:e=>Z({allowFrom:Ee(e.target.value)})}),(0,P.jsx)(I,{children:r.allowFromDmDesc})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.allowFromGroups}),(0,P.jsx)(`textarea`,{className:a(e(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`oc_xxx, oc_yyy`,value:De($.groupAllowFrom),onChange:e=>Z({groupAllowFrom:Ee(e.target.value)})}),(0,P.jsx)(I,{children:r.allowFromGroupsDesc})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.historyLimit}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String($.historyLimit),onChange:e=>Z({historyLimit:Number(e.target.value||`0`)||0})})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.textChunkLimit}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String($.textChunkLimit),onChange:e=>Z({textChunkLimit:Number(e.target.value||`0`)||0})})]})]}),(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.feishuToolsTitle}),(0,P.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[`doc`,r.feishuToolDoc],[`wiki`,r.feishuToolWiki],[`drive`,r.feishuToolDrive],[`perm`,r.feishuToolPerm],[`bitable`,r.feishuToolBitable],[`scopes`,r.feishuToolScopes]].map(([e,t])=>(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!$.tools?.[e],onChange:t=>Z({tools:{...$.tools,[e]:t.target.checked}})}),t]},e))}),(0,P.jsx)(`div`,{className:`mt-2`,children:(0,P.jsx)(I,{children:r.feishuToolsDesc})})]}),(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.feishuActionsTitle}),(0,P.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!$.actions?.reactions,onChange:e=>Z({actions:{...$.actions,reactions:e.target.checked}})}),r.feishuActionReactions]})]}),l?(0,P.jsx)(je,{accountIds:ge($),routes:l.channelAgentRoutes.feishu,defaultAgentId:l.defaultAgentId,agentItems:Qe?.items??[],disabled:y,onChange:(e,t)=>ot(`feishu`,e,t),ch:r}):null,(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.multiAccountJson}),(0,P.jsx)(`textarea`,{className:a(e(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:Xe,onChange:e=>G(e.target.value),onBlur:_t,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),Ze?(0,P.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:Ze}):(0,P.jsx)(I,{children:r.multiAccountJsonDesc})]})]}),(0,P.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,P.jsx)(b,{type:`button`,variant:`secondary`,onClick:()=>j(!1),children:r.modalCancel}),(0,P.jsx)(b,{type:`button`,variant:`primary`,disabled:!rt||y,onClick:async()=>{await ct()&&j(!1)},children:y?r.saving:r.save})]})]})]})}),(0,P.jsx)(S,{open:M!==null,onOpenChange:e=>!e&&N(null),children:(0,P.jsxs)(oe,{children:[(0,P.jsx)(te,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[70] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,P.jsx)(ee,{className:`text-base font-semibold text-fg`,children:r.removeChannelTitle}),(0,P.jsx)(x,{className:`mt-2 text-sm text-fg-muted`,children:M?r.removeChannelConfirm.replace(`{{name}}`,M===`weixin`?r.weixinTitle:M===`telegram`?r.telegramTitle:r.feishuTitle):`\xA0`}),(0,P.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,P.jsx)(b,{type:`button`,variant:`secondary`,onClick:()=>N(null),children:r.modalCancel}),(0,P.jsx)(b,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:y,onClick:()=>void ut(),children:y?r.saving:r.removeChannelAction})]})]})]})})]})})}export{J as ChannelsSettingsPanel};
|
|
9
|
-
//# sourceMappingURL=channels-settings-
|
|
9
|
+
//# sourceMappingURL=channels-settings-CkfSST0k.js.map
|