@xopcai/xopc 0.0.108 → 0.0.110
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/feishu/src/pairing-config-resolver.d.ts +1 -0
- package/dist/extensions/feishu/src/pairing-config-resolver.js +30 -0
- package/dist/extensions/feishu/src/pairing-config-resolver.js.map +1 -0
- package/dist/extensions/feishu/src/plugin.d.ts +1 -0
- package/dist/extensions/feishu/src/plugin.js +1 -0
- package/dist/extensions/feishu/src/plugin.js.map +1 -1
- package/dist/extensions/feishu/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/src/access-control.d.ts +2 -1
- package/dist/extensions/telegram/src/access-control.js.map +1 -1
- package/dist/extensions/telegram/src/account-manager.d.ts +2 -1
- package/dist/extensions/telegram/src/account-manager.js.map +1 -1
- package/dist/extensions/telegram/src/adapters/gateway-setup.js +26 -26
- package/dist/extensions/telegram/src/adapters/gateway-setup.js.map +1 -1
- package/dist/extensions/telegram/src/adapters/onboard-cli.js +8 -4
- package/dist/extensions/telegram/src/adapters/onboard-cli.js.map +1 -1
- package/dist/extensions/telegram/src/adapters/streaming-adapter.js +1 -1
- package/dist/extensions/telegram/src/config-schema.d.ts +88 -50
- package/dist/extensions/telegram/src/config-schema.js +40 -32
- package/dist/extensions/telegram/src/config-schema.js.map +1 -1
- package/dist/extensions/telegram/src/config-types.d.ts +54 -0
- package/dist/extensions/telegram/src/config-types.js +1 -0
- package/dist/extensions/telegram/src/doctor.js +17 -16
- package/dist/extensions/telegram/src/doctor.js.map +1 -1
- package/dist/extensions/telegram/src/exec-approvals.js +2 -3
- package/dist/extensions/telegram/src/exec-approvals.js.map +1 -1
- package/dist/extensions/telegram/src/group-config-resolver.d.ts +1 -1
- package/dist/extensions/telegram/src/group-config-resolver.js.map +1 -1
- package/dist/extensions/telegram/src/inbound-processor.js +1 -1
- package/dist/extensions/telegram/src/pairing-config-resolver.d.ts +1 -0
- package/dist/extensions/telegram/src/pairing-config-resolver.js +56 -0
- package/dist/extensions/telegram/src/pairing-config-resolver.js.map +1 -0
- package/dist/extensions/telegram/src/plugin.d.ts +1 -0
- package/dist/extensions/telegram/src/plugin.js +9 -10
- package/dist/extensions/telegram/src/plugin.js.map +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/telegram/src/update-offset-store.js +1 -1
- package/dist/extensions/telegram/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +156 -122
- package/dist/extensions/weixin/src/api/api.js +2 -2
- package/dist/extensions/weixin/src/auth/accounts.js +1 -1
- package/dist/extensions/weixin/src/cdn/upload.js +1 -1
- package/dist/extensions/weixin/src/media/data-url.js +1 -1
- package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
- package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
- package/dist/extensions/weixin/src/pairing-config-resolver.d.ts +1 -0
- package/dist/extensions/weixin/src/pairing-config-resolver.js +54 -0
- package/dist/extensions/weixin/src/pairing-config-resolver.js.map +1 -0
- package/dist/extensions/weixin/src/plugin.d.ts +1 -0
- package/dist/extensions/weixin/src/plugin.js +2 -1
- package/dist/extensions/weixin/src/plugin.js.map +1 -1
- package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
- package/dist/extensions/weixin/src/workflow-progress.js +1 -1
- package/dist/gateway/static/root/assets/{agents-56kCGHdV.js → agents-CFFioJCI.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Dd88J47r.js → apps-page-BYDmkbzG.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-Ckyvnvml.js → channels-settings-CsbDaMvd.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-DKo2ZdRA.js → cron-page-Apk-7p4p.js} +1 -1
- package/dist/gateway/static/root/assets/{dist-dmxWdtPG.js → dist-DmGDgpy2.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-iGpG-vpp.js → extension-debug-page-pxFC-tUa.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-I7-3uHiD.js → extension-page-W1wiG38F.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BisnHG7r.js → extension-settings-page-COXSv6xP.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-tbWAFPN8.js → heartbeat-config-api-DcmAMYmN.js} +1 -1
- package/dist/gateway/static/root/assets/{index-slwUkhxH.js → index-C_2yKRJX.js} +3 -3
- package/dist/gateway/static/root/assets/{logs-page-CCZiXrWu.js → logs-page-DvTWUOzd.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-page-BYbw2GLl.js → note-detail-page-CZbdugWZ.js} +1 -1
- package/dist/gateway/static/root/assets/{note-time-Cya72Lte.js → note-time-RdyBZxj3.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-DrAO7VRK.js → notes-page-mEAwy3e1.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-a6UJCK55.js → schema-form-DEvdni_r.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-DNU3Ymvz.js → sessions-page-BsgffzV4.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-advanced-gate-CyEJYTbw.js → settings-advanced-gate-t6v8Dwb8.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DpHo2ecA.js → settings-form-section-BoYYZmJG.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-YRwe4q56.js → settings-page-ClIthYF8.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-B7rf4QB4.js → share-preview-page-Dd9et7KD.js} +1 -1
- package/dist/gateway/static/root/assets/skills-page-DEXtxyfQ.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-Btagks_B.js → voice-api-key-field-CNrKzQrf.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-page.utils-DvzJKs6W.js → workflow-page.utils-EYg_xBQS.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-BgOAgCOG.js → workflows-page-EMZkzJNN.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +7 -7
- package/dist/src/agent/agent-scope.js +1 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
- package/dist/src/agent/context/workspace-seed.js +2 -2
- package/dist/src/agent/context/workspace-state.js +1 -1
- package/dist/src/agent/goals/goal-run-store.js +4 -4
- package/dist/src/agent/goals/persistent-goal-service.js +1 -1
- package/dist/src/agent/goals/post-turn.js +2 -2
- package/dist/src/agent/image/load-image-media.js +2 -2
- package/dist/src/agent/ipc/bus.js +1 -1
- package/dist/src/agent/ipc/inbox.js +2 -2
- package/dist/src/agent/ipc/socket.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
- package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
- package/dist/src/agent/memory/dreaming/events.js +1 -1
- package/dist/src/agent/memory/dreaming/last-run.js +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
- package/dist/src/agent/memory/dreaming/preview.js +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
- package/dist/src/agent/memory/dreaming/utils.js +1 -1
- package/dist/src/agent/memory/memory-flush.js +1 -1
- package/dist/src/agent/memory/plugin-discovery.js +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
- package/dist/src/agent/reply/post-compaction-context.js +1 -1
- package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
- package/dist/src/agent/sandbox/path-policy.js +2 -2
- package/dist/src/agent/service.js +4 -4
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/config.js +1 -1
- package/dist/src/agent/skills/hub-hash.js +2 -2
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +2 -2
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/scanner.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/skill-manager.js +1 -1
- package/dist/src/agent/starter-agents.js +1 -1
- package/dist/src/agent/tools/dreaming-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -1
- package/dist/src/agent/tools/send-media.js +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/workflow-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/workflow/catalog.js +1 -1
- package/dist/src/auth/credentials.js +3 -3
- package/dist/src/auth/profiles/store.js +2 -2
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/browser/cache-dir-policy.js +1 -1
- package/dist/src/browser/cdp-local-launcher.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +3 -3
- package/dist/src/browser/providers/cloakbrowser.js +4 -4
- package/dist/src/browser/providers/playwright-doctor.js +1 -1
- package/dist/src/browser/stealth.js +1 -1
- package/dist/src/channels/channel-domain.d.ts +1 -81
- package/dist/src/channels/outbound/persist-store.js +1 -1
- package/dist/src/channels/pairing/allow-from-file.js +1 -1
- package/dist/src/channels/pairing/index.d.ts +2 -2
- package/dist/src/channels/pairing/index.js +2 -2
- package/dist/src/channels/pairing/pairing-service.d.ts +13 -0
- package/dist/src/channels/pairing/pairing-service.js +78 -63
- package/dist/src/channels/pairing/pairing-service.js.map +1 -1
- package/dist/src/channels/pairing/pairing-store.js +2 -2
- package/dist/src/chat-commands/agent-edit.js +2 -2
- package/dist/src/chat-commands/builtins/config.js +6 -13
- package/dist/src/chat-commands/builtins/config.js.map +1 -1
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/config.js +1 -1
- package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
- package/dist/src/cli/commands/extension-create.js +1 -1
- package/dist/src/cli/commands/extension-dev.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +2 -2
- package/dist/src/cli/commands/extension-pack.js +2 -2
- package/dist/src/cli/commands/extension.js +2 -2
- package/dist/src/cli/commands/gateway/logs.js +1 -1
- package/dist/src/cli/commands/image.js +1 -1
- package/dist/src/cli/commands/init.js +3 -3
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/utils/init-workspace-core.js +2 -2
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/agent-typed-models.js +1 -1
- package/dist/src/config/gateway-bind.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/paths-state.js +1 -1
- package/dist/src/config/profile.js +2 -2
- package/dist/src/config/schema.js +9 -14
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/workspace-path.js +1 -1
- package/dist/src/cron/executor.js +2 -2
- package/dist/src/cron/persistence.js +1 -1
- package/dist/src/daemon/constants.js +1 -1
- package/dist/src/daemon/install-plan.js +2 -2
- package/dist/src/daemon/launchd.js +2 -2
- package/dist/src/daemon/schtasks.js +2 -2
- package/dist/src/daemon/systemd.js +2 -2
- package/dist/src/extensions/bundle-mcp.js +1 -1
- package/dist/src/extensions/discover-extensions.js +1 -1
- package/dist/src/extensions/health.js +1 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/lockfile.js +2 -2
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/lib/extension-store.js +2 -2
- package/dist/src/gateway/hono/lib/static-ui.js +2 -2
- package/dist/src/gateway/hono/oauth-async.js +1 -1
- package/dist/src/gateway/hono/oauth.js +1 -1
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +1 -1
- package/dist/src/gateway/hono/routes/host-fs.js +2 -2
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +2 -2
- package/dist/src/gateway/lock.js +3 -3
- package/dist/src/gateway/ports.js +1 -1
- package/dist/src/gateway/service/agent-runner.js +2 -2
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service.js +3 -3
- package/dist/src/gateway/workspace-fs-file-list.js +1 -1
- package/dist/src/infra/brew.js +1 -1
- package/dist/src/infra/package-json.js +1 -1
- package/dist/src/infra/package-update-steps.js +1 -1
- package/dist/src/infra/path-env.js +2 -2
- package/dist/src/infra/restart.js +2 -2
- package/dist/src/infra/stable-node-path.js +1 -1
- package/dist/src/infra/update-check.js +1 -1
- package/dist/src/infra/update-global.js +1 -1
- package/dist/src/infra/update-lock.js +3 -3
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/infra/update-startup.js +2 -2
- package/dist/src/infra/write-file-atomic.js +2 -2
- package/dist/src/media/store.js +1 -1
- package/dist/src/notes/agent-context.js +1 -1
- package/dist/src/notes/store.js +2 -2
- package/dist/src/project-trust/trust-store.js +2 -2
- package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/session/init-session-turn.js +2 -2
- package/dist/src/session/resolve-session.js +3 -3
- package/dist/src/session/session-title.js +2 -2
- package/dist/src/session/store.js +2 -2
- package/dist/src/share/share-auto.js +2 -2
- package/dist/src/share/share-store.js +3 -3
- package/dist/src/share/share-thumbnail.js +2 -2
- package/dist/src/share/share-zip.js +1 -1
- package/dist/src/share/site-share-store.js +3 -3
- package/dist/src/share/site-static-serve.js +1 -1
- package/dist/src/storage/sqlite/connection.js +2 -2
- package/dist/src/storage/sqlite/memory-index-repository.js +2 -2
- package/dist/src/storage/sqlite/migrations/discover.js +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/clipboard-image.js +3 -3
- package/dist/src/tui/theme-manager.js +1 -1
- package/dist/src/tui/tui-command-formatters.js +3 -3
- package/dist/src/tui/tui-commands.js +2 -2
- package/dist/src/tui/tui-keybindings-file.js +1 -1
- package/dist/src/tui/tui-scoped-models.js +2 -2
- package/dist/src/tui/tui-settings.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +5 -5
- package/dist/src/tunnel/frpc-binary.js +3 -3
- package/dist/src/tunnel/frpc-config.js +1 -1
- package/dist/src/tunnel/frpc-extract.js +1 -1
- package/dist/src/tunnel/tunnel-state.js +1 -1
- package/dist/src/utils/logger/audit.js +1 -1
- package/dist/src/utils/logger/log-store.js +1 -1
- package/dist/src/utils/logger/rotation.js +1 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/voice/tts/providers/edge-speech.js +2 -2
- package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
- package/dist/src/workflows/store/event-store.js +1 -1
- package/dist/src/workflows/store/run-store.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/skills-page-we1NAt7u.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-DQRqHuL-.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./circle-check-C23XjkUj.js";import{i as l}from"./theme-store-BZozwAeK.js";import{a as u,n as d,t as f}from"./fetch-CFdKBnE6.js";import{i as p,r as m}from"./gateway-startup-retry-DdngdObI.js";import{$i as h,$n as g,$o as _,$r as v,Ar as y,B as b,Bn as x,Bt as S,Ca as C,Ci as w,Da as T,Di as E,Dr as D,Ei as O,Eo as k,Er as A,F as j,Fr as M,Ft as N,G as P,Gi as F,Gr as I,Gt as L,H as R,Ht as z,I as B,It as V,Jn as H,Ki as ee,Kn as U,L as W,La as G,Lt as te,Mo as ne,Mr as re,Mt as ie,Nr as ae,Nt as oe,Oo as se,Or as ce,Pi as le,Po as ue,Pr as de,Pt as fe,Qi as pe,Qn as me,R as he,Ri as ge,Ro as _e,Rt as ve,Si as ye,Ti as be,Tn as xe,To as Se,Tr as Ce,U as we,Ua as Te,Ui as Ee,Ut as De,V as Oe,Vi as ke,Vn as Ae,Vo as je,Vr as Me,Vt as Ne,W as Pe,Wa as Fe,Wo as Ie,Wt as Le,Xn as Re,Yn as K,Yo as ze,Zi as Be,Zn as Ve,Zo as He,Zr as Ue,_i as We,_o as Ge,bo as Ke,ca as qe,ci as Je,co as Ye,da as Xe,di as Ze,do as Qe,ei as $e,er as et,es as tt,fa as nt,fi as q,ga as rt,gi as it,go as at,hi as ot,ia as st,ii as ct,in as lt,ja as ut,jr as dt,kr as ft,mi as pt,mo as mt,n as ht,ni as gt,no as _t,nr as vt,ns as yt,oo as bt,p as xt,pa as St,pi as J,qa as Ct,qn as wt,qr as Tt,ri as Et,t as Dt,tr as Ot,ts as kt,ua as At,ui as jt,uo as Mt,wn as Nt,wo as Pt,wr as Ft,xi as It,xo as Lt,yi as Rt,yo as zt,z as Bt,za as Vt,zi as Ht,zn as Ut,zt as Wt}from"./index-slwUkhxH.js";import{n as Gt,t as Kt}from"./settings-form-section-DpHo2ecA.js";import{C as qt,D as Jt,c as Yt,m as Xt,n as Zt,o as Qt,p as $t,r as en,t as tn,v as nn}from"./settings-advanced-gate-CyEJYTbw.js";var Y=n(),X=r();function rn(e){let t=(0,Y.c)(40),{open:n,onOpenChange:r,busy:i,deletePurge:a,deleteTarget:o,deleteConfirmText:s,onDeleteConfirmTextChange:c,onConfirm:l,onCancel:u,a:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(ce,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=J(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),t[1]=p):p=t[1];let m=a?d.purgeDisk:d.removeFromConfig,h;t[2]===m?h=t[3]:(h=(0,X.jsx)(dt,{className:`text-base font-semibold text-fg`,children:m}),t[2]=m,t[3]=h);let g=a?d.confirmDeletePurge:d.confirmDelete,_;t[4]===g?_=t[5]:(_=(0,X.jsx)(D,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:g}),t[4]=g,t[5]=_);let v;t[6]!==d.purgeConfirmHint||t[7]!==d.purgeConfirmLabel||t[8]!==d.purgeConfirmPlaceholder||t[9]!==s||t[10]!==a||t[11]!==o||t[12]!==c?(v=a&&o?(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,X.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:d.purgeConfirmLabel}),(0,X.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:J(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:d.purgeConfirmPlaceholder.replace(`{{agentId}}`,o.id),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:d.purgeConfirmHint.replace(`{{agentId}}`,o.id)})]}):null,t[6]=d.purgeConfirmHint,t[7]=d.purgeConfirmLabel,t[8]=d.purgeConfirmPlaceholder,t[9]=s,t[10]=a,t[11]=o,t[12]=c,t[13]=v):v=t[13];let b;t[14]!==d.createModalCancel||t[15]!==i||t[16]!==u?(b=(0,X.jsx)(q,{type:`button`,variant:`ghost`,disabled:i,onClick:u,children:d.createModalCancel}),t[14]=d.createModalCancel,t[15]=i,t[16]=u,t[17]=b):b=t[17];let x=a?`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`:void 0,S;t[18]!==i||t[19]!==s||t[20]!==a||t[21]!==o?(S=i||!o||a&&s.trim().toLowerCase()!==o.id.toLowerCase(),t[18]=i,t[19]=s,t[20]=a,t[21]=o,t[22]=S):S=t[22];let C=a?d.purgeDisk:d.removeFromConfig,w;t[23]!==l||t[24]!==S||t[25]!==C||t[26]!==x?(w=(0,X.jsx)(q,{type:`button`,variant:`secondary`,className:x,disabled:S,onClick:l,children:C}),t[23]=l,t[24]=S,t[25]=C,t[26]=x,t[27]=w):w=t[27];let T;t[28]!==w||t[29]!==b?(T=(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[b,w]}),t[28]=w,t[29]=b,t[30]=T):T=t[30];let E;t[31]!==T||t[32]!==h||t[33]!==_||t[34]!==v?(E=(0,X.jsxs)(ft,{children:[f,(0,X.jsxs)(A,{className:p,onOpenAutoFocus:an,children:[h,_,v,T]})]}),t[31]=T,t[32]=h,t[33]=_,t[34]=v,t[35]=E):E=t[35];let O;return t[36]!==r||t[37]!==n||t[38]!==E?(O=(0,X.jsx)(y,{open:n,onOpenChange:r,children:E}),t[36]=r,t[37]=n,t[38]=E,t[39]=O):O=t[39],O}function an(e){return e.preventDefault()}var on=[{id:`overview`,labelKey:`navIdentity`,icon:Rt},{id:`profile`,labelKey:`navProfile`,icon:k},{id:`models`,labelKey:`navModels`,icon:Te},{id:`tools`,labelKey:`navTools`,icon:it},{id:`skills`,labelKey:`navSkills`,icon:qe},{id:`files`,labelKey:`navCoreFiles`,icon:Ye}],sn=[{id:`channels`,labelKey:`tabChannels`,icon:Xe},{id:`cron`,labelKey:`tabCron`,icon:Lt}];function cn(e){let t=(0,Y.c)(20),{a:n,panel:r,onPanelChange:i}=e,a;t[0]!==i||t[1]!==r?(a=(e,t,n)=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:J(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors`,ct.press,r===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,X.jsx)(n,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a,s=n.editorNavAria,c;t[3]!==n||t[4]!==o?(c=on.map(e=>{let{id:t,labelKey:r,icon:i}=e;return o(t,n[r],i)}),t[3]=n,t[4]=o,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=(0,X.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:c}),t[6]=c,t[7]=l);let u;t[8]===n.navAdvanced?u=t[9]:(u=(0,X.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:n.navAdvanced}),t[8]=n.navAdvanced,t[9]=u);let d;t[10]!==n||t[11]!==o?(d=sn.map(e=>{let{id:t,labelKey:r,icon:i}=e;return o(t,n[r],i)}),t[10]=n,t[11]=o,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,X.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==n.editorNavAria||t[16]!==l||t[17]!==u||t[18]!==f?(p=(0,X.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":s,children:[l,u,f]}),t[15]=n.editorNavAria,t[16]=l,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function ln(e){let t=(0,Y.c)(49),{open:n,onOpenChange:r,a:i,title:a,subtitle:o,panel:s,onPanelChange:c,onFooterSave:l,footerSaveDisabled:u,footerSavedFlash:d,busy:f,children:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(ce,{className:J(`xopc-dialog-overlay fixed inset-0 bg-scrim`,xe)}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=J(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,Nt,`inset-4 h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] min-h-0`,`sm:inset-auto sm:left-1/2 sm:top-1/2 sm:h-[min(88vh,48rem)] sm:max-h-[min(88vh,48rem)] sm:min-h-[32rem] sm:w-[min(100%-2rem,58rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),t[1]=h):h=t[1];let g;t[2]===a?g=t[3]:(g=(0,X.jsx)(dt,{className:`text-base font-semibold leading-snug text-fg`,children:a}),t[2]=a,t[3]=g);let _;t[4]===o?_=t[5]:(_=(0,X.jsx)(D,{className:`mt-1 font-mono text-xs text-fg-muted`,children:o}),t[4]=o,t[5]=_);let v;t[6]!==g||t[7]!==_?(v=(0,X.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[g,_]}),t[6]=g,t[7]=_,t[8]=v):v=t[8];let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=J(Et,`shrink-0 p-1.5 hover:bg-surface-base`),t[9]=b):b=t[9];let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,X.jsx)(ot,{className:`size-4`,"aria-hidden":!0}),t[10]=x):x=t[10];let S;t[11]===i.closeDialogAria?S=t[12]:(S=(0,X.jsx)(Ce,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:b,"aria-label":i.closeDialogAria,children:x})}),t[11]=i.closeDialogAria,t[12]=S);let C;t[13]!==v||t[14]!==S?(C=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge-subtle px-4 pb-3 pt-4 dark:border-edge`,children:[v,S]}),t[13]=v,t[14]=S,t[15]=C):C=t[15];let w;t[16]!==i||t[17]!==c||t[18]!==s?(w=(0,X.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 dark:border-edge sm:flex sm:w-56 sm:shrink-0 sm:flex-col sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-0 sm:py-4 sm:pl-4 sm:pr-3`,children:(0,X.jsx)(cn,{a:i,panel:s,onPanelChange:c})}),t[16]=i,t[17]=c,t[18]=s,t[19]=w):w=t[19];let T;t[20]===p?T=t[21]:(T=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden p-4 sm:pl-2 sm:pr-5`,children:p}),t[20]=p,t[21]=T);let E;t[22]!==i.footerSaveNotApplicable||t[23]!==i.personaSaved||t[24]!==u||t[25]!==d?(E=d?(0,X.jsxs)(`p`,{className:`order-2 text-center text-xs font-medium text-green-600 sm:order-1 sm:mr-auto sm:text-left dark:text-green-400`,children:[`✓ `,i.personaSaved]}):u?(0,X.jsx)(`p`,{className:`order-2 text-center text-xs text-fg-muted sm:order-1 sm:mr-auto sm:text-left`,children:i.footerSaveNotApplicable}):null,t[22]=i.footerSaveNotApplicable,t[23]=i.personaSaved,t[24]=u,t[25]=d,t[26]=E):E=t[26];let O=f||u,k;t[27]===l?k=t[28]:(k=()=>void l(),t[27]=l,t[28]=k);let j;t[29]!==i.save||t[30]!==O||t[31]!==k?(j=(0,X.jsx)(q,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:O,onClick:k,children:i.save}),t[29]=i.save,t[30]=O,t[31]=k,t[32]=j):j=t[32];let M;t[33]!==E||t[34]!==j?(M=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-t border-edge-subtle px-4 py-3 dark:border-edge sm:flex-row sm:items-center sm:justify-end sm:gap-3`,children:[E,j]}),t[33]=E,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==T||t[37]!==M?(N=(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[T,M]}),t[36]=T,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==N||t[40]!==w?(P=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[w,N]}),t[39]=N,t[40]=w,t[41]=P):P=t[41];let F;t[42]!==P||t[43]!==C?(F=(0,X.jsxs)(ft,{children:[m,(0,X.jsx)(A,{className:h,onOpenAutoFocus:un,children:(0,X.jsxs)(R,{layer:`modal`,children:[C,P]})})]}),t[42]=P,t[43]=C,t[44]=F):F=t[44];let I;return t[45]!==r||t[46]!==n||t[47]!==F?(I=(0,X.jsx)(y,{open:n,onOpenChange:r,children:F}),t[45]=r,t[46]=n,t[47]=F,t[48]=I):I=t[48],I}function un(e){return e.preventDefault()}function dn(){return J(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ze,`dark:border-edge`)}function fn(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function pn(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function mn(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}var hn=J(jt,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function gn(e){let t=(0,Y.c)(62),{a:n,busy:r,bindingsLoading:i,agentBindings:a,onRemoveBinding:o,onAddBinding:s,channelStatuses:c,channelsStatusLoading:l,useManualChannel:u,newBindChannel:d,setNewBindChannel:f,bindSessionChats:p,sessionsLoading:m,newBindSessionIdx:h,setNewBindSessionIdx:g,newBindCustomPeer:_,setNewBindCustomPeer:v,onRefreshSessions:y,lastActiveLabels:b,selectRecipient:x}=e,S=!l&&(u||c.length>0),C;t[0]!==n.channelsHint||t[1]!==n.channelsTitle?(C=(0,X.jsx)(Gt,{className:`shrink-0`,icon:G,title:n.channelsTitle,subtitle:n.channelsHint}),t[0]=n.channelsHint,t[1]=n.channelsTitle,t[2]=C):C=t[2];let w;t[3]!==n.channelsLoading||t[4]!==n.channelsNone||t[5]!==n.removeBinding||t[6]!==a||t[7]!==i||t[8]!==r||t[9]!==o?(w=i?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoading}):a.length===0?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsNone}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:a.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`font-mono text-xs`,children:pn(e.match)}),(0,X.jsx)(q,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>void o(e),children:n.removeBinding})]},`${e.match.channel}-${pn(e.match)}`))}),t[3]=n.channelsLoading,t[4]=n.channelsNone,t[5]=n.removeBinding,t[6]=a,t[7]=i,t[8]=r,t[9]=o,t[10]=w):w=t[10];let T;t[11]!==n.channelLabel||t[12]!==n.channelsDisabledSuffix||t[13]!==n.channelsLoadingChannels||t[14]!==n.channelsManualChannelHint||t[15]!==c||t[16]!==l||t[17]!==d||t[18]!==f||t[19]!==v||t[20]!==g||t[21]!==u?(T=l?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoadingChannels}):u?(0,X.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,X.jsx)(`input`,{className:dn(),value:d,onChange:e=>f(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsManualChannelHint})]}):(0,X.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,X.jsx)(`select`,{className:J(dn(),`py-2`),value:d,onChange:e=>{f(e.target.value),g(null),v(``)},children:c.map(e=>(0,X.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:n.channelsDisabledSuffix]},e.name))})]}),t[11]=n.channelLabel,t[12]=n.channelsDisabledSuffix,t[13]=n.channelsLoadingChannels,t[14]=n.channelsManualChannelHint,t[15]=c,t[16]=l,t[17]=d,t[18]=f,t[19]=v,t[20]=g,t[21]=u,t[22]=T):T=t[22];let E;t[23]!==n.channelsCustomPeerHint||t[24]!==n.channelsCustomPeerPlaceholder||t[25]!==n.channelsLoadingSessions||t[26]!==n.channelsNoSessionsHint||t[27]!==n.channelsPeerAny||t[28]!==n.channelsPeerFromSessions||t[29]!==n.channelsRefreshSessions||t[30]!==n.channelsRefreshSessionsHint||t[31]!==n.channelsSessionLabel||t[32]!==n.peerIdLabel||t[33]!==p||t[34]!==r||t[35]!==b||t[36]!==d||t[37]!==_||t[38]!==h||t[39]!==y||t[40]!==x||t[41]!==m||t[42]!==v||t[43]!==g||t[44]!==S?(E=S&&d.trim()?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsSessionLabel}),(0,X.jsxs)(q,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:r||m||!d.trim(),title:n.channelsRefreshSessionsHint,onClick:()=>y(),children:[(0,X.jsx)(st,{className:J(`size-3.5`,m&&`animate-spin`),strokeWidth:1.75}),n.channelsRefreshSessions]})]}),m&&p.length===0?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsLoadingSessions}):null,(0,X.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsPeerFromSessions}),(0,X.jsxs)(`select`,{className:J(dn(),`py-2`),value:h==null?``:String(h),disabled:r||!d.trim()||!!_.trim(),onChange:e=>{let t=e.target.value;g(t===``?null:Number(t))},children:[(0,X.jsx)(`option`,{value:``,children:n.channelsPeerAny}),p.map((e,t)=>(0,X.jsx)(`option`,{value:String(t),children:qt(e,b)},`${e.channel}-${e.chatId}`))]})]}),p.length===0&&d.trim()&&!m?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsNoSessionsHint}):null,(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.peerIdLabel}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,X.jsx)(`input`,{type:`text`,className:J(dn(),`min-w-0 w-full sm:flex-1`),value:_,onChange:e=>{v(e.target.value),e.target.value.trim()&&g(null)},placeholder:n.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,X.jsxs)(`select`,{className:hn,value:_,onChange:e=>{let t=e.target.value;v(t||``),g(null)},children:[(0,X.jsx)(`option`,{value:``,children:x}),p.map(e=>(0,X.jsx)(`option`,{value:e.chatId,children:qt(e,b)},`${e.channel}-${e.chatId}`))]})]}),(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsCustomPeerHint})]})]}):null,t[23]=n.channelsCustomPeerHint,t[24]=n.channelsCustomPeerPlaceholder,t[25]=n.channelsLoadingSessions,t[26]=n.channelsNoSessionsHint,t[27]=n.channelsPeerAny,t[28]=n.channelsPeerFromSessions,t[29]=n.channelsRefreshSessions,t[30]=n.channelsRefreshSessionsHint,t[31]=n.channelsSessionLabel,t[32]=n.peerIdLabel,t[33]=p,t[34]=r,t[35]=b,t[36]=d,t[37]=_,t[38]=h,t[39]=y,t[40]=x,t[41]=m,t[42]=v,t[43]=g,t[44]=S,t[45]=E):E=t[45];let D;t[46]!==r||t[47]!==l||t[48]!==d?(D=r||!d.trim()||l,t[46]=r,t[47]=l,t[48]=d,t[49]=D):D=t[49];let O;t[50]!==n.addBinding||t[51]!==D?(O=(0,X.jsx)(`div`,{children:(0,X.jsx)(q,{type:`submit`,disabled:D,children:n.addBinding})}),t[50]=n.addBinding,t[51]=D,t[52]=O):O=t[52];let k;t[53]!==s||t[54]!==T||t[55]!==E||t[56]!==O?(k=(0,X.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:s,children:[T,E,O]}),t[53]=s,t[54]=T,t[55]=E,t[56]=O,t[57]=k):k=t[57];let A;return t[58]!==C||t[59]!==w||t[60]!==k?(A=(0,X.jsxs)(Kt,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[C,w,k]}),t[58]=C,t[59]=w,t[60]=k,t[61]=A):A=t[61],A}function _n(e){let t=(0,Y.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?Jt(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):en(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,X.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function vn(e){let t=(0,Y.c)(24),{a:n,data:r,busy:o,cronLoading:s,agentCronJobs:c,onSetCronJobAgent:l}=e,u=i(bn),d;t[0]===u?d=t[1]:(d=a(u),t[0]=u,t[1]=d);let f=d,p=u===`zh`?`zh-CN`:`en-US`,m=f.cron.scheduleBadge,h;t[2]!==n.cronHint||t[3]!==n.cronTitle?(h=(0,X.jsx)(Gt,{className:`shrink-0`,icon:ze,title:n.cronTitle,subtitle:n.cronHint}),t[2]=n.cronHint,t[3]=n.cronTitle,t[4]=h):h=t[4];let g;t[5]!==n.cronAgentClear||t[6]!==n.cronAgentDefault||t[7]!==n.cronColAgent||t[8]!==n.cronColMessage||t[9]!==n.cronColSchedule||t[10]!==n.cronColSession||t[11]!==n.cronLoading||t[12]!==n.cronNone||t[13]!==c||t[14]!==o||t[15]!==s||t[16]!==r||t[17]!==p||t[18]!==l||t[19]!==m?(g=s?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronLoading}):c.length===0?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronNone}):(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,X.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSchedule}),(0,X.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColMessage}),(0,X.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSession}),(0,X.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColAgent})]})}),(0,X.jsx)(`tbody`,{children:c.map(e=>{let t=!e.agentId?.trim(),i=t?``:e.agentId.trim().toLowerCase();return(0,X.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,X.jsx)(`td`,{className:`py-2 pr-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(_n,{kind:`cron`,expression:e.schedule,locale:p,labels:m,timezone:e.timezone,nextRun:e.next_run,className:`text-sm font-medium text-fg`}),(0,X.jsx)(`span`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:e.schedule,children:e.schedule})]})}),(0,X.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:Qt(e),children:Qt(e)}),(0,X.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,X.jsx)(`td`,{className:`py-2 pr-3`,children:(0,X.jsxs)(`select`,{className:J(dn(),`min-w-[8rem] py-1 text-xs`),value:i,disabled:o||e.sessionTarget!==`isolated`,onChange:t=>void l(e,t.target.value),children:[(0,X.jsx)(`option`,{value:``,children:t?n.cronAgentDefault:n.cronAgentClear}),r.agents.map(yn)]})})]},e.id)})})]})}),t[5]=n.cronAgentClear,t[6]=n.cronAgentDefault,t[7]=n.cronColAgent,t[8]=n.cronColMessage,t[9]=n.cronColSchedule,t[10]=n.cronColSession,t[11]=n.cronLoading,t[12]=n.cronNone,t[13]=c,t[14]=o,t[15]=s,t[16]=r,t[17]=p,t[18]=l,t[19]=m,t[20]=g):g=t[20];let _;return t[21]!==h||t[22]!==g?(_=(0,X.jsxs)(Kt,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[h,g]}),t[21]=h,t[22]=g,t[23]=_):_=t[23],_}function yn(e){return(0,X.jsx)(`option`,{value:e.id,children:e.id},e.id)}function bn(e){return e.language}function xn(e){let t=(0,Y.c)(29),{a:n,filesLoading:r,files:i,activeFile:a,setActiveFile:o,filesViewMode:s,setFilesViewMode:c,fileDraft:u,setFileDraft:d,fileSaving:f,profileFileLoading:p,profileEditorNonce:m,onTryInChat:h}=e,g=l(Sn),_;t[0]===n.filesHint?_=t[1]:(_=(0,X.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesHint}),t[0]=n.filesHint,t[1]=_);let v;t[2]!==n.filesAutoSaveHint||t[3]!==n.filesEmpty||t[4]!==n.filesLoading||t[5]!==n.filesMarkdownEdit||t[6]!==n.filesMarkdownPreview||t[7]!==n.filesSavingStatus||t[8]!==n.missing||t[9]!==n.navCoreFiles||t[10]!==n.pickFile||t[11]!==n.tryInChat||t[12]!==a||t[13]!==u||t[14]!==f||t[15]!==i||t[16]!==r||t[17]!==s||t[18]!==g||t[19]!==h||t[20]!==m||t[21]!==p||t[22]!==o||t[23]!==d||t[24]!==c?(v=r?(0,X.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesLoading}):i?(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,X.jsx)(`nav`,{className:`-mx-1 flex shrink-0 flex-wrap gap-1 px-1 pb-1`,role:`tablist`,"aria-label":n.navCoreFiles,children:i.files.map(e=>{let t=a===e.name;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:J(`inline-flex shrink-0 items-center rounded-lg px-3 py-2 font-mono text-xs font-medium whitespace-nowrap transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,ct.press,t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,e.missing&&`opacity-60`),onClick:()=>o(e.name),children:[e.name,e.missing?` (${n.missing})`:``]},e.name)})}),(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":`${n.filesMarkdownEdit} / ${n.filesMarkdownPreview}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:J(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,ct.press,s===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>c(`edit`),children:[(0,X.jsx)(Ht,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownEdit]}),(0,X.jsxs)(`button`,{type:`button`,className:J(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,ct.press,s===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>c(`preview`),children:[(0,X.jsx)(Mt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownPreview]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[f?(0,X.jsx)(`span`,{children:n.filesSavingStatus}):null,(0,X.jsx)(`span`,{children:n.filesAutoSaveHint}),h?(0,X.jsxs)(q,{type:`button`,variant:`secondary`,className:`ml-auto text-xs`,onClick:h,children:[(0,X.jsx)(T,{className:`mr-1 size-3.5`,"aria-hidden":!0}),n.tryInChat]}):null]})]}),s===`edit`?(0,X.jsx)(`div`,{className:J(dn(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,p&&`pointer-events-none opacity-60`),children:(0,X.jsx)(x,{initialContent:u,onChange:d,isDark:g,className:`min-h-0 flex-1`},`${a??`file`}-${m}`)}):(0,X.jsx)(`div`,{className:J(dn(),`min-h-0 flex-1 overflow-y-auto text-sm`,p&&`pointer-events-none opacity-60`),children:(0,X.jsx)(Ut,{content:u,className:`text-sm`})})]}):(0,X.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.pickFile})})]}):(0,X.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesEmpty}),t[2]=n.filesAutoSaveHint,t[3]=n.filesEmpty,t[4]=n.filesLoading,t[5]=n.filesMarkdownEdit,t[6]=n.filesMarkdownPreview,t[7]=n.filesSavingStatus,t[8]=n.missing,t[9]=n.navCoreFiles,t[10]=n.pickFile,t[11]=n.tryInChat,t[12]=a,t[13]=u,t[14]=f,t[15]=i,t[16]=r,t[17]=s,t[18]=g,t[19]=h,t[20]=m,t[21]=p,t[22]=o,t[23]=d,t[24]=c,t[25]=v):v=t[25];let y;return t[26]!==_||t[27]!==v?(y=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function Sn(e){return e.resolved===`dark`}function Z(){return J(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ze,`dark:border-edge`)}function Cn(){return J(jt,Je)}var wn=`h-auto shrink-0 px-2.5 py-1.5 text-xs font-medium`;function Tn(e){let t=(0,Y.c)(25),{rows:n,onChange:r,disabled:i,chat:a,labels:o}=e,s;t[0]!==r||t[1]!==n?(s=(e,t)=>{r(n.map((n,r)=>r===e?{...n,...t}:n))},t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s,l;t[3]!==a||t[4]!==i||t[5]!==o.description||t[6]!==o.descriptionPlaceholder||t[7]!==o.id||t[8]!==o.idPlaceholder||t[9]!==o.remove||t[10]!==r||t[11]!==n||t[12]!==c?(l=n.map((e,t)=>(0,X.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3 sm:grid-cols-[minmax(0,8rem)_minmax(0,1.2fr)_minmax(0,1fr)_auto] sm:items-start dark:border-edge-subtle`,children:[(0,X.jsx)(`input`,{type:`text`,className:Z(),value:e.id,disabled:i,placeholder:o.idPlaceholder,"aria-label":o.id,onChange:e=>c(t,{id:e.target.value.toLowerCase()})}),(0,X.jsx)(Oe,{value:e.model,disabled:i,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,onChange:e=>c(t,{model:e})}),(0,X.jsx)(`input`,{type:`text`,className:Z(),value:e.description,disabled:i,placeholder:o.descriptionPlaceholder,"aria-label":o.description,onChange:e=>c(t,{description:e.target.value})}),(0,X.jsx)(q,{type:`button`,variant:`secondary`,className:`shrink-0 sm:mt-0`,disabled:i,"aria-label":o.remove,onClick:()=>r(n.filter((e,n)=>n!==t)),children:(0,X.jsx)(O,{className:`size-4`,strokeWidth:1.75})})]},e.id||`typed-model-${e.model}-${e.description}`)),t[3]=a,t[4]=i,t[5]=o.description,t[6]=o.descriptionPlaceholder,t[7]=o.id,t[8]=o.idPlaceholder,t[9]=o.remove,t[10]=r,t[11]=n,t[12]=c,t[13]=l):l=t[13];let u;t[14]!==r||t[15]!==n?(u=()=>r([...n,{id:``,description:``,model:``}]),t[14]=r,t[15]=n,t[16]=u):u=t[16];let d;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,X.jsx)(At,{className:`size-4 shrink-0`,strokeWidth:1.75}),t[17]=d):d=t[17];let f;t[18]!==i||t[19]!==o.add||t[20]!==u?(f=(0,X.jsxs)(q,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,disabled:i,onClick:u,children:[d,o.add]}),t[18]=i,t[19]=o.add,t[20]=u,t[21]=f):f=t[21];let p;return t[22]!==l||t[23]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[l,f]}),t[22]=l,t[23]=f,t[24]=p):p=t[24],p}var En=/^[a-z][a-z0-9_-]{0,63}$/;function Dn(e){let t=e.trim(),n=t.indexOf(`/`);return n>0&&n<t.length-1}function On(e){let t=e&&typeof e==`object`&&!Array.isArray(e)&&`roles`in e?Object.entries(e.roles??{}).map(([e,t])=>({id:e,...t&&typeof t==`object`&&!Array.isArray(t)?t:{}})):e;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e,r=typeof t.id==`string`?t.id.trim():``,i=typeof t.model==`string`?t.model.trim():``;if(!r||!i)continue;let a=typeof t.description==`string`?t.description.trim():``;n.push({id:r,model:i,description:a})}return n}function kn(e){let t=new Map;for(let n of e){let e=n.id.trim(),r=n.model.trim();if(!e||!En.test(e)||!r||!Dn(r))continue;let i=n.description.trim();t.set(e,i?{description:i,model:r}:{model:r})}return t.size===0?null:{roles:Object.fromEntries(t.entries())}}function An(e,t){let n=new Set;for(let r of e){let e=r.id.trim(),i=r.model.trim();if(!(!e&&!i&&!r.description.trim())){if(!e||!En.test(e))return t.invalidId;if(n.has(e))return t.duplicateId;if(n.add(e),!i||!Dn(i))return t.invalidModel}}return null}function jn(e){return e.length===0?`—`:e.map(e=>`${e.id} → ${e.model}`).join(`, `)}function Mn(e){return(e??[]).map(e=>({id:e.id,model:e.model,description:e.description?.trim()??``}))}function Nn(e){let t=(0,Y.c)(52),{a:n,chat:r,selected:i,busy:a,modelRows:o,setModelRows:s,onSaveModels:c,onClearModelsEntry:l,hideInlineSave:u}=e,d;t[0]!==n.modelsTabHint||t[1]!==n.modelsTabTitle?(d=(0,X.jsx)(Gt,{className:`shrink-0`,icon:Te,title:n.modelsTabTitle,subtitle:n.modelsTabHint}),t[0]=n.modelsTabHint,t[1]=n.modelsTabTitle,t[2]=d):d=t[2];let f;t[3]===n.modelsDefaultsLabel?f=t[4]:(f=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelsDefaultsLabel}),t[3]=n.modelsDefaultsLabel,t[4]=f);let p;t[5]===i.typedModels.defaults?p=t[6]:(p=jn(i.typedModels.defaults),t[5]=i.typedModels.defaults,t[6]=p);let m;t[7]!==f||t[8]!==p?(m=(0,X.jsxs)(`div`,{children:[f,` `,p]}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]===n.modelsEffectiveLabel?h=t[11]:(h=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelsEffectiveLabel}),t[10]=n.modelsEffectiveLabel,t[11]=h);let g;t[12]===i.typedModels.effective?g=t[13]:(g=jn(i.typedModels.effective),t[12]=i.typedModels.effective,t[13]=g);let _;t[14]!==h||t[15]!==g?(_=(0,X.jsxs)(`div`,{children:[h,` `,g]}),t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==m||t[18]!==_?(v=(0,X.jsxs)(`div`,{className:`mb-4 grid gap-2 rounded-lg border border-edge-subtle bg-surface-base/60 p-3 text-xs text-fg-muted dark:border-edge`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==n.addTypedModel||t[21]!==n.removeTypedModel||t[22]!==n.typedModelDescriptionLabel||t[23]!==n.typedModelDescriptionPlaceholder||t[24]!==n.typedModelIdLabel||t[25]!==n.typedModelIdPlaceholder?(y={id:n.typedModelIdLabel,description:n.typedModelDescriptionLabel,add:n.addTypedModel,remove:n.removeTypedModel,idPlaceholder:n.typedModelIdPlaceholder,descriptionPlaceholder:n.typedModelDescriptionPlaceholder},t[20]=n.addTypedModel,t[21]=n.removeTypedModel,t[22]=n.typedModelDescriptionLabel,t[23]=n.typedModelDescriptionPlaceholder,t[24]=n.typedModelIdLabel,t[25]=n.typedModelIdPlaceholder,t[26]=y):y=t[26];let b;t[27]!==a||t[28]!==r||t[29]!==o||t[30]!==s||t[31]!==y?(b=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,X.jsx)(Tn,{rows:o,onChange:s,disabled:a,chat:r,labels:y})}),t[27]=a,t[28]=r,t[29]=o,t[30]=s,t[31]=y,t[32]=b):b=t[32];let x;t[33]!==n.modelsSave||t[34]!==a||t[35]!==u||t[36]!==c?(x=u?null:(0,X.jsx)(q,{type:`button`,disabled:a,onClick:()=>void c(),children:n.modelsSave}),t[33]=n.modelsSave,t[34]=a,t[35]=u,t[36]=c,t[37]=x):x=t[37];let S;t[38]===l?S=t[39]:(S=()=>void l(),t[38]=l,t[39]=S);let C;t[40]!==n.modelsResetInherit||t[41]!==a||t[42]!==S?(C=(0,X.jsx)(q,{type:`button`,variant:`secondary`,disabled:a,onClick:S,children:n.modelsResetInherit}),t[40]=n.modelsResetInherit,t[41]=a,t[42]=S,t[43]=C):C=t[43];let w;t[44]!==x||t[45]!==C?(w=(0,X.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[x,C]}),t[44]=x,t[45]=C,t[46]=w):w=t[46];let T;return t[47]!==d||t[48]!==w||t[49]!==v||t[50]!==b?(T=(0,X.jsxs)(Kt,{className:`flex min-h-0 flex-1 flex-col`,children:[d,v,b,w]}),t[47]=d,t[48]=w,t[49]=v,t[50]=b,t[51]=T):T=t[51],T}var Q=e(t(),1);function Pn(e){let t=(0,Y.c)(37),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,inputClassName:s,trailing:c}=e,l;t[0]!==r||t[1]!==n?(l={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=l):l=t[2];let u=Bt(l),d;t[3]===n?d=t[4]:(d=n.trim(),t[3]=n,t[4]=d);let f=d,p=f?`${f}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`,m;t[5]===s?m=t[6]:(m=J(`min-w-0 flex-1`,s),t[5]=s,t[6]=m);let h=i||u.picking,g;t[7]===r?g=t[8]:(g=e=>void r(e.target.value),t[7]=r,t[8]=g);let _=o??a.pathInputPlaceholder,v;t[9]!==m||t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==n?(v=(0,X.jsx)(`input`,{type:`text`,className:m,value:n,disabled:h,onChange:g,placeholder:_,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=n,t[14]=v):v=t[14];let y=i||u.picking,x;t[15]!==p||t[16]!==u.pick||t[17]!==y||t[18]!==n||t[19]!==a.selectWorkingDirectory?(x=(0,X.jsx)(b,{compact:!0,value:n,onPick:u.pick,disabled:y,title:p,"aria-label":a.selectWorkingDirectory}),t[15]=p,t[16]=u.pick,t[17]=y,t[18]=n,t[19]=a.selectWorkingDirectory,t[20]=x):x=t[20];let S;t[21]!==x||t[22]!==c?(S=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[x,c]}),t[21]=x,t[22]=c,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==v?(C=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[v,S]}),t[24]=S,t[25]=v,t[26]=C):C=t[26];let w;t[27]!==u.confirmPick||t[28]!==u.hasNativePicker||t[29]!==u.modalOpen||t[30]!==u.setModalOpen||t[31]!==f||t[32]!==a?(w=u.hasNativePicker?null:(0,X.jsx)(j,{open:u.modalOpen,onOpenChange:u.setModalOpen,initialAbsolutePath:f||void 0,onConfirm:u.confirmPick,wd:a}),t[27]=u.confirmPick,t[28]=u.hasNativePicker,t[29]=u.modalOpen,t[30]=u.setModalOpen,t[31]=f,t[32]=a,t[33]=w):w=t[33];let T;return t[34]!==C||t[35]!==w?(T=(0,X.jsxs)(X.Fragment,{children:[C,w]}),t[34]=C,t[35]=w,t[36]=T):T=t[36],T}function Fn(e){let t=(0,Y.c)(19),{label:n,mode:r,value:i,inheritedFrom:a,inheritLabel:o,overrideLabel:s}=e,c;t[0]===n?c=t[1]:(c=(0,X.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=c);let l=i||`—`,u;t[2]===l?u=t[3]:(u=(0,X.jsx)(`p`,{className:`mt-1 truncate text-sm font-medium text-fg`,children:l}),t[2]=l,t[3]=u);let d;t[4]!==a||t[5]!==r?(d=r===`inherit`&&a?(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:a}):null,t[4]=a,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==c||t[8]!==u||t[9]!==d?(f=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[c,u,d]}),t[7]=c,t[8]=u,t[9]=d,t[10]=f):f=t[10];let p=r===`inherit`?`bg-surface-hover text-fg-muted`:`bg-accent-soft text-accent-fg`,m;t[11]===p?m=t[12]:(m=J(`mt-2 inline-flex shrink-0 self-start rounded-full px-2.5 py-0.5 text-xs font-medium sm:mt-0`,p),t[11]=p,t[12]=m);let h=r===`inherit`?o:s,g;t[13]!==m||t[14]!==h?(g=(0,X.jsx)(`span`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==f||t[17]!==g?(_=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[f,g]}),t[16]=f,t[17]=g,t[18]=_):_=t[18],_}function In(e){let t=(0,Y.c)(41),{a:n,defaultModel:r,defaultWorkspace:i,agentModel:a,agentWorkspace:o,settingsPath:s,settingsState:c}=e,l=s===void 0?`/settings/agent-defaults`:s,u=n.inheritance,d;t[0]===a?d=t[1]:(d=a.trim(),t[0]=a,t[1]=d);let f=!d,p;t[2]!==o||t[3]!==i?(p=!o.trim()||i.trim().length>0&&o.trim()===i.trim(),t[2]=o,t[3]=i,t[4]=p):p=t[4];let m=p,h=f?r||u.unset:a,g=m?i||u.unset:o,_;t[5]!==u.editDefaultsLink||t[6]!==l||t[7]!==c?(_=(0,X.jsx)(He,{to:l,state:c,className:`text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:u.editDefaultsLink}),t[5]=u.editDefaultsLink,t[6]=l,t[7]=c,t[8]=_):_=t[8];let v;t[9]!==u.subtitle||t[10]!==u.title||t[11]!==_?(v=(0,X.jsx)(Gt,{icon:G,title:u.title,subtitle:u.subtitle,trailing:_}),t[9]=u.subtitle,t[10]=u.title,t[11]=_,t[12]=v):v=t[12];let y=f?`inherit`:`override`,b;t[13]!==r||t[14]!==u.inheritsValue||t[15]!==f?(b=f&&r?u.inheritsValue.replace(`{{value}}`,r):void 0,t[13]=r,t[14]=u.inheritsValue,t[15]=f,t[16]=b):b=t[16];let x;t[17]!==h||t[18]!==u.badgeInherit||t[19]!==u.badgeOverride||t[20]!==u.modelLabel||t[21]!==y||t[22]!==b?(x=(0,X.jsx)(Fn,{label:u.modelLabel,mode:y,value:h,inheritedFrom:b,inheritLabel:u.badgeInherit,overrideLabel:u.badgeOverride}),t[17]=h,t[18]=u.badgeInherit,t[19]=u.badgeOverride,t[20]=u.modelLabel,t[21]=y,t[22]=b,t[23]=x):x=t[23];let S=m?`inherit`:`override`,C;t[24]!==i||t[25]!==u.inheritsValue||t[26]!==m?(C=m&&i?u.inheritsValue.replace(`{{value}}`,i):void 0,t[24]=i,t[25]=u.inheritsValue,t[26]=m,t[27]=C):C=t[27];let w;t[28]!==g||t[29]!==u.badgeInherit||t[30]!==u.badgeOverride||t[31]!==u.workspaceLabel||t[32]!==S||t[33]!==C?(w=(0,X.jsx)(Fn,{label:u.workspaceLabel,mode:S,value:g,inheritedFrom:C,inheritLabel:u.badgeInherit,overrideLabel:u.badgeOverride}),t[28]=g,t[29]=u.badgeInherit,t[30]=u.badgeOverride,t[31]=u.workspaceLabel,t[32]=S,t[33]=C,t[34]=w):w=t[34];let T;t[35]!==w||t[36]!==x?(T=(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[x,w]}),t[35]=w,t[36]=x,t[37]=T):T=t[37];let E;return t[38]!==T||t[39]!==v?(E=(0,X.jsxs)(Kt,{children:[v,T]}),t[38]=T,t[39]=v,t[40]=E):E=t[40],E}function Ln(e,t){switch(e){case`adventurer`:return t.avatarStyleAdventurer;case`bottts`:return t.avatarStyleRobot;case`lorelei`:return t.avatarStyleLorelei;case`thumbs`:return t.avatarStyleThumbs;case`fun-emoji`:return t.avatarStyleFunEmoji;default:return e}}function Rn(e){let{agentId:t,value:n,onChange:r,a:i,id:a}=e,o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),p=(0,Q.useMemo)(()=>{let e=et(n.trim());return e&&g(e.styleId)?e.styleId:K[0]??`adventurer`},[n]),m=(0,Q.useCallback)(async(e,n)=>{try{await N(t)}catch{}r(Ve(e,n)),f(!1)},[t,r]),h=(0,Q.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){u(null),c(!0);try{await L(t,n),Ot(t),r(Re)}catch(e){let t=e instanceof Error?e.message:``;u(t===`avatar_too_large`?i.avatarTooLarge:t===`unsupported_image_type`||t===`empty_file`?i.avatarInvalidImage:i.avatarUploadFailed)}finally{c(!1)}}},[i,t,r]),_=(e,t)=>{let r=et(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,X.jsxs)(`div`,{...a?{id:a}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.avatarPickerTitle}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{ref:o,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void h(e)}),(0,X.jsxs)(q,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:s,onClick:()=>o.current?.click(),children:[(0,X.jsx)(ye,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s?i.avatarUploading:i.avatarUploadCustom]})]})]}),l?(0,X.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):null,(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:K.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>void m(e,H[0]??t),className:J(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,ct.press,p===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:Ln(e,i)},e))}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[H.map(e=>(0,X.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:J(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,ct.press,_(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,X.jsx)(`img`,{src:me(p,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,X.jsxs)(de,{open:d,onOpenChange:f,children:[(0,X.jsx)(M,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:J(`flex size-12 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-xs font-medium text-fg-muted hover:border-edge hover:text-fg`,ct.press),children:i.avatarMore})}),(0,X.jsx)(ae,{children:(0,X.jsxs)(re,{className:`z-[80] max-h-72 w-[min(22rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border border-edge-subtle bg-surface-panel p-3 shadow-lg`,sideOffset:6,align:`end`,children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:Ln(p,i)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:wt.map(e=>(0,X.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:J(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,ct.press,_(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,X.jsx)(`img`,{src:me(p,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.personaAvatar}),(0,X.jsx)(U,{agentId:t,avatar:n,size:40}),n.trim()&&!et(n.trim())&&n.trim()!==`xopc:custom`?(0,X.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}var zn={name:``,description:``,language:``,creature:``,emoji:``,avatar:``};function Bn(e){let t={...zn};if(!e.trim())return t;let n={name:`name`,description:`description`,language:`language`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-DQRqHuL-.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./circle-check-C23XjkUj.js";import{i as l}from"./theme-store-BZozwAeK.js";import{a as u,n as d,t as f}from"./fetch-CFdKBnE6.js";import{i as p,r as m}from"./gateway-startup-retry-DdngdObI.js";import{$i as h,$n as g,$o as _,$r as v,Ar as y,B as b,Bn as x,Bt as S,Ca as C,Ci as w,Da as T,Di as E,Dr as D,Ei as O,Eo as k,Er as A,F as j,Fr as M,Ft as N,G as P,Gi as F,Gr as I,Gt as L,H as R,Ht as z,I as B,It as V,Jn as H,Ki as ee,Kn as U,L as W,La as G,Lt as te,Mo as ne,Mr as re,Mt as ie,Nr as ae,Nt as oe,Oo as se,Or as ce,Pi as le,Po as ue,Pr as de,Pt as fe,Qi as pe,Qn as me,R as he,Ri as ge,Ro as _e,Rt as ve,Si as ye,Ti as be,Tn as xe,To as Se,Tr as Ce,U as we,Ua as Te,Ui as Ee,Ut as De,V as Oe,Vi as ke,Vn as Ae,Vo as je,Vr as Me,Vt as Ne,W as Pe,Wa as Fe,Wo as Ie,Wt as Le,Xn as Re,Yn as K,Yo as ze,Zi as Be,Zn as Ve,Zo as He,Zr as Ue,_i as We,_o as Ge,bo as Ke,ca as qe,ci as Je,co as Ye,da as Xe,di as Ze,do as Qe,ei as $e,er as et,es as tt,fa as nt,fi as q,ga as rt,gi as it,go as at,hi as ot,ia as st,ii as ct,in as lt,ja as ut,jr as dt,kr as ft,mi as pt,mo as mt,n as ht,ni as gt,no as _t,nr as vt,ns as yt,oo as bt,p as xt,pa as St,pi as J,qa as Ct,qn as wt,qr as Tt,ri as Et,t as Dt,tr as Ot,ts as kt,ua as At,ui as jt,uo as Mt,wn as Nt,wo as Pt,wr as Ft,xi as It,xo as Lt,yi as Rt,yo as zt,z as Bt,za as Vt,zi as Ht,zn as Ut,zt as Wt}from"./index-C_2yKRJX.js";import{n as Gt,t as Kt}from"./settings-form-section-BoYYZmJG.js";import{C as qt,D as Jt,c as Yt,m as Xt,n as Zt,o as Qt,p as $t,r as en,t as tn,v as nn}from"./settings-advanced-gate-t6v8Dwb8.js";var Y=n(),X=r();function rn(e){let t=(0,Y.c)(40),{open:n,onOpenChange:r,busy:i,deletePurge:a,deleteTarget:o,deleteConfirmText:s,onDeleteConfirmTextChange:c,onConfirm:l,onCancel:u,a:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(ce,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=J(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),t[1]=p):p=t[1];let m=a?d.purgeDisk:d.removeFromConfig,h;t[2]===m?h=t[3]:(h=(0,X.jsx)(dt,{className:`text-base font-semibold text-fg`,children:m}),t[2]=m,t[3]=h);let g=a?d.confirmDeletePurge:d.confirmDelete,_;t[4]===g?_=t[5]:(_=(0,X.jsx)(D,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:g}),t[4]=g,t[5]=_);let v;t[6]!==d.purgeConfirmHint||t[7]!==d.purgeConfirmLabel||t[8]!==d.purgeConfirmPlaceholder||t[9]!==s||t[10]!==a||t[11]!==o||t[12]!==c?(v=a&&o?(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,X.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:d.purgeConfirmLabel}),(0,X.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:J(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:d.purgeConfirmPlaceholder.replace(`{{agentId}}`,o.id),value:s,onChange:e=>c(e.target.value)}),(0,X.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:d.purgeConfirmHint.replace(`{{agentId}}`,o.id)})]}):null,t[6]=d.purgeConfirmHint,t[7]=d.purgeConfirmLabel,t[8]=d.purgeConfirmPlaceholder,t[9]=s,t[10]=a,t[11]=o,t[12]=c,t[13]=v):v=t[13];let b;t[14]!==d.createModalCancel||t[15]!==i||t[16]!==u?(b=(0,X.jsx)(q,{type:`button`,variant:`ghost`,disabled:i,onClick:u,children:d.createModalCancel}),t[14]=d.createModalCancel,t[15]=i,t[16]=u,t[17]=b):b=t[17];let x=a?`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`:void 0,S;t[18]!==i||t[19]!==s||t[20]!==a||t[21]!==o?(S=i||!o||a&&s.trim().toLowerCase()!==o.id.toLowerCase(),t[18]=i,t[19]=s,t[20]=a,t[21]=o,t[22]=S):S=t[22];let C=a?d.purgeDisk:d.removeFromConfig,w;t[23]!==l||t[24]!==S||t[25]!==C||t[26]!==x?(w=(0,X.jsx)(q,{type:`button`,variant:`secondary`,className:x,disabled:S,onClick:l,children:C}),t[23]=l,t[24]=S,t[25]=C,t[26]=x,t[27]=w):w=t[27];let T;t[28]!==w||t[29]!==b?(T=(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[b,w]}),t[28]=w,t[29]=b,t[30]=T):T=t[30];let E;t[31]!==T||t[32]!==h||t[33]!==_||t[34]!==v?(E=(0,X.jsxs)(ft,{children:[f,(0,X.jsxs)(A,{className:p,onOpenAutoFocus:an,children:[h,_,v,T]})]}),t[31]=T,t[32]=h,t[33]=_,t[34]=v,t[35]=E):E=t[35];let O;return t[36]!==r||t[37]!==n||t[38]!==E?(O=(0,X.jsx)(y,{open:n,onOpenChange:r,children:E}),t[36]=r,t[37]=n,t[38]=E,t[39]=O):O=t[39],O}function an(e){return e.preventDefault()}var on=[{id:`overview`,labelKey:`navIdentity`,icon:Rt},{id:`profile`,labelKey:`navProfile`,icon:k},{id:`models`,labelKey:`navModels`,icon:Te},{id:`tools`,labelKey:`navTools`,icon:it},{id:`skills`,labelKey:`navSkills`,icon:qe},{id:`files`,labelKey:`navCoreFiles`,icon:Ye}],sn=[{id:`channels`,labelKey:`tabChannels`,icon:Xe},{id:`cron`,labelKey:`tabCron`,icon:Lt}];function cn(e){let t=(0,Y.c)(20),{a:n,panel:r,onPanelChange:i}=e,a;t[0]!==i||t[1]!==r?(a=(e,t,n)=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:J(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors`,ct.press,r===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,X.jsx)(n,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a,s=n.editorNavAria,c;t[3]!==n||t[4]!==o?(c=on.map(e=>{let{id:t,labelKey:r,icon:i}=e;return o(t,n[r],i)}),t[3]=n,t[4]=o,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=(0,X.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:c}),t[6]=c,t[7]=l);let u;t[8]===n.navAdvanced?u=t[9]:(u=(0,X.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:n.navAdvanced}),t[8]=n.navAdvanced,t[9]=u);let d;t[10]!==n||t[11]!==o?(d=sn.map(e=>{let{id:t,labelKey:r,icon:i}=e;return o(t,n[r],i)}),t[10]=n,t[11]=o,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,X.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==n.editorNavAria||t[16]!==l||t[17]!==u||t[18]!==f?(p=(0,X.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":s,children:[l,u,f]}),t[15]=n.editorNavAria,t[16]=l,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function ln(e){let t=(0,Y.c)(49),{open:n,onOpenChange:r,a:i,title:a,subtitle:o,panel:s,onPanelChange:c,onFooterSave:l,footerSaveDisabled:u,footerSavedFlash:d,busy:f,children:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(ce,{className:J(`xopc-dialog-overlay fixed inset-0 bg-scrim`,xe)}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=J(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,Nt,`inset-4 h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] min-h-0`,`sm:inset-auto sm:left-1/2 sm:top-1/2 sm:h-[min(88vh,48rem)] sm:max-h-[min(88vh,48rem)] sm:min-h-[32rem] sm:w-[min(100%-2rem,58rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),t[1]=h):h=t[1];let g;t[2]===a?g=t[3]:(g=(0,X.jsx)(dt,{className:`text-base font-semibold leading-snug text-fg`,children:a}),t[2]=a,t[3]=g);let _;t[4]===o?_=t[5]:(_=(0,X.jsx)(D,{className:`mt-1 font-mono text-xs text-fg-muted`,children:o}),t[4]=o,t[5]=_);let v;t[6]!==g||t[7]!==_?(v=(0,X.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[g,_]}),t[6]=g,t[7]=_,t[8]=v):v=t[8];let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=J(Et,`shrink-0 p-1.5 hover:bg-surface-base`),t[9]=b):b=t[9];let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,X.jsx)(ot,{className:`size-4`,"aria-hidden":!0}),t[10]=x):x=t[10];let S;t[11]===i.closeDialogAria?S=t[12]:(S=(0,X.jsx)(Ce,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:b,"aria-label":i.closeDialogAria,children:x})}),t[11]=i.closeDialogAria,t[12]=S);let C;t[13]!==v||t[14]!==S?(C=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge-subtle px-4 pb-3 pt-4 dark:border-edge`,children:[v,S]}),t[13]=v,t[14]=S,t[15]=C):C=t[15];let w;t[16]!==i||t[17]!==c||t[18]!==s?(w=(0,X.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 dark:border-edge sm:flex sm:w-56 sm:shrink-0 sm:flex-col sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-0 sm:py-4 sm:pl-4 sm:pr-3`,children:(0,X.jsx)(cn,{a:i,panel:s,onPanelChange:c})}),t[16]=i,t[17]=c,t[18]=s,t[19]=w):w=t[19];let T;t[20]===p?T=t[21]:(T=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden p-4 sm:pl-2 sm:pr-5`,children:p}),t[20]=p,t[21]=T);let E;t[22]!==i.footerSaveNotApplicable||t[23]!==i.personaSaved||t[24]!==u||t[25]!==d?(E=d?(0,X.jsxs)(`p`,{className:`order-2 text-center text-xs font-medium text-green-600 sm:order-1 sm:mr-auto sm:text-left dark:text-green-400`,children:[`✓ `,i.personaSaved]}):u?(0,X.jsx)(`p`,{className:`order-2 text-center text-xs text-fg-muted sm:order-1 sm:mr-auto sm:text-left`,children:i.footerSaveNotApplicable}):null,t[22]=i.footerSaveNotApplicable,t[23]=i.personaSaved,t[24]=u,t[25]=d,t[26]=E):E=t[26];let O=f||u,k;t[27]===l?k=t[28]:(k=()=>void l(),t[27]=l,t[28]=k);let j;t[29]!==i.save||t[30]!==O||t[31]!==k?(j=(0,X.jsx)(q,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:O,onClick:k,children:i.save}),t[29]=i.save,t[30]=O,t[31]=k,t[32]=j):j=t[32];let M;t[33]!==E||t[34]!==j?(M=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-t border-edge-subtle px-4 py-3 dark:border-edge sm:flex-row sm:items-center sm:justify-end sm:gap-3`,children:[E,j]}),t[33]=E,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==T||t[37]!==M?(N=(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[T,M]}),t[36]=T,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==N||t[40]!==w?(P=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[w,N]}),t[39]=N,t[40]=w,t[41]=P):P=t[41];let F;t[42]!==P||t[43]!==C?(F=(0,X.jsxs)(ft,{children:[m,(0,X.jsx)(A,{className:h,onOpenAutoFocus:un,children:(0,X.jsxs)(R,{layer:`modal`,children:[C,P]})})]}),t[42]=P,t[43]=C,t[44]=F):F=t[44];let I;return t[45]!==r||t[46]!==n||t[47]!==F?(I=(0,X.jsx)(y,{open:n,onOpenChange:r,children:F}),t[45]=r,t[46]=n,t[47]=F,t[48]=I):I=t[48],I}function un(e){return e.preventDefault()}function dn(){return J(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ze,`dark:border-edge`)}function fn(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function pn(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function mn(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}var hn=J(jt,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function gn(e){let t=(0,Y.c)(62),{a:n,busy:r,bindingsLoading:i,agentBindings:a,onRemoveBinding:o,onAddBinding:s,channelStatuses:c,channelsStatusLoading:l,useManualChannel:u,newBindChannel:d,setNewBindChannel:f,bindSessionChats:p,sessionsLoading:m,newBindSessionIdx:h,setNewBindSessionIdx:g,newBindCustomPeer:_,setNewBindCustomPeer:v,onRefreshSessions:y,lastActiveLabels:b,selectRecipient:x}=e,S=!l&&(u||c.length>0),C;t[0]!==n.channelsHint||t[1]!==n.channelsTitle?(C=(0,X.jsx)(Gt,{className:`shrink-0`,icon:G,title:n.channelsTitle,subtitle:n.channelsHint}),t[0]=n.channelsHint,t[1]=n.channelsTitle,t[2]=C):C=t[2];let w;t[3]!==n.channelsLoading||t[4]!==n.channelsNone||t[5]!==n.removeBinding||t[6]!==a||t[7]!==i||t[8]!==r||t[9]!==o?(w=i?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoading}):a.length===0?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsNone}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:a.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`font-mono text-xs`,children:pn(e.match)}),(0,X.jsx)(q,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>void o(e),children:n.removeBinding})]},`${e.match.channel}-${pn(e.match)}`))}),t[3]=n.channelsLoading,t[4]=n.channelsNone,t[5]=n.removeBinding,t[6]=a,t[7]=i,t[8]=r,t[9]=o,t[10]=w):w=t[10];let T;t[11]!==n.channelLabel||t[12]!==n.channelsDisabledSuffix||t[13]!==n.channelsLoadingChannels||t[14]!==n.channelsManualChannelHint||t[15]!==c||t[16]!==l||t[17]!==d||t[18]!==f||t[19]!==v||t[20]!==g||t[21]!==u?(T=l?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoadingChannels}):u?(0,X.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,X.jsx)(`input`,{className:dn(),value:d,onChange:e=>f(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsManualChannelHint})]}):(0,X.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,X.jsx)(`select`,{className:J(dn(),`py-2`),value:d,onChange:e=>{f(e.target.value),g(null),v(``)},children:c.map(e=>(0,X.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:n.channelsDisabledSuffix]},e.name))})]}),t[11]=n.channelLabel,t[12]=n.channelsDisabledSuffix,t[13]=n.channelsLoadingChannels,t[14]=n.channelsManualChannelHint,t[15]=c,t[16]=l,t[17]=d,t[18]=f,t[19]=v,t[20]=g,t[21]=u,t[22]=T):T=t[22];let E;t[23]!==n.channelsCustomPeerHint||t[24]!==n.channelsCustomPeerPlaceholder||t[25]!==n.channelsLoadingSessions||t[26]!==n.channelsNoSessionsHint||t[27]!==n.channelsPeerAny||t[28]!==n.channelsPeerFromSessions||t[29]!==n.channelsRefreshSessions||t[30]!==n.channelsRefreshSessionsHint||t[31]!==n.channelsSessionLabel||t[32]!==n.peerIdLabel||t[33]!==p||t[34]!==r||t[35]!==b||t[36]!==d||t[37]!==_||t[38]!==h||t[39]!==y||t[40]!==x||t[41]!==m||t[42]!==v||t[43]!==g||t[44]!==S?(E=S&&d.trim()?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsSessionLabel}),(0,X.jsxs)(q,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:r||m||!d.trim(),title:n.channelsRefreshSessionsHint,onClick:()=>y(),children:[(0,X.jsx)(st,{className:J(`size-3.5`,m&&`animate-spin`),strokeWidth:1.75}),n.channelsRefreshSessions]})]}),m&&p.length===0?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsLoadingSessions}):null,(0,X.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsPeerFromSessions}),(0,X.jsxs)(`select`,{className:J(dn(),`py-2`),value:h==null?``:String(h),disabled:r||!d.trim()||!!_.trim(),onChange:e=>{let t=e.target.value;g(t===``?null:Number(t))},children:[(0,X.jsx)(`option`,{value:``,children:n.channelsPeerAny}),p.map((e,t)=>(0,X.jsx)(`option`,{value:String(t),children:qt(e,b)},`${e.channel}-${e.chatId}`))]})]}),p.length===0&&d.trim()&&!m?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsNoSessionsHint}):null,(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.peerIdLabel}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,X.jsx)(`input`,{type:`text`,className:J(dn(),`min-w-0 w-full sm:flex-1`),value:_,onChange:e=>{v(e.target.value),e.target.value.trim()&&g(null)},placeholder:n.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,X.jsxs)(`select`,{className:hn,value:_,onChange:e=>{let t=e.target.value;v(t||``),g(null)},children:[(0,X.jsx)(`option`,{value:``,children:x}),p.map(e=>(0,X.jsx)(`option`,{value:e.chatId,children:qt(e,b)},`${e.channel}-${e.chatId}`))]})]}),(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsCustomPeerHint})]})]}):null,t[23]=n.channelsCustomPeerHint,t[24]=n.channelsCustomPeerPlaceholder,t[25]=n.channelsLoadingSessions,t[26]=n.channelsNoSessionsHint,t[27]=n.channelsPeerAny,t[28]=n.channelsPeerFromSessions,t[29]=n.channelsRefreshSessions,t[30]=n.channelsRefreshSessionsHint,t[31]=n.channelsSessionLabel,t[32]=n.peerIdLabel,t[33]=p,t[34]=r,t[35]=b,t[36]=d,t[37]=_,t[38]=h,t[39]=y,t[40]=x,t[41]=m,t[42]=v,t[43]=g,t[44]=S,t[45]=E):E=t[45];let D;t[46]!==r||t[47]!==l||t[48]!==d?(D=r||!d.trim()||l,t[46]=r,t[47]=l,t[48]=d,t[49]=D):D=t[49];let O;t[50]!==n.addBinding||t[51]!==D?(O=(0,X.jsx)(`div`,{children:(0,X.jsx)(q,{type:`submit`,disabled:D,children:n.addBinding})}),t[50]=n.addBinding,t[51]=D,t[52]=O):O=t[52];let k;t[53]!==s||t[54]!==T||t[55]!==E||t[56]!==O?(k=(0,X.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:s,children:[T,E,O]}),t[53]=s,t[54]=T,t[55]=E,t[56]=O,t[57]=k):k=t[57];let A;return t[58]!==C||t[59]!==w||t[60]!==k?(A=(0,X.jsxs)(Kt,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[C,w,k]}),t[58]=C,t[59]=w,t[60]=k,t[61]=A):A=t[61],A}function _n(e){let t=(0,Y.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?Jt(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):en(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,X.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function vn(e){let t=(0,Y.c)(24),{a:n,data:r,busy:o,cronLoading:s,agentCronJobs:c,onSetCronJobAgent:l}=e,u=i(bn),d;t[0]===u?d=t[1]:(d=a(u),t[0]=u,t[1]=d);let f=d,p=u===`zh`?`zh-CN`:`en-US`,m=f.cron.scheduleBadge,h;t[2]!==n.cronHint||t[3]!==n.cronTitle?(h=(0,X.jsx)(Gt,{className:`shrink-0`,icon:ze,title:n.cronTitle,subtitle:n.cronHint}),t[2]=n.cronHint,t[3]=n.cronTitle,t[4]=h):h=t[4];let g;t[5]!==n.cronAgentClear||t[6]!==n.cronAgentDefault||t[7]!==n.cronColAgent||t[8]!==n.cronColMessage||t[9]!==n.cronColSchedule||t[10]!==n.cronColSession||t[11]!==n.cronLoading||t[12]!==n.cronNone||t[13]!==c||t[14]!==o||t[15]!==s||t[16]!==r||t[17]!==p||t[18]!==l||t[19]!==m?(g=s?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronLoading}):c.length===0?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronNone}):(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,X.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSchedule}),(0,X.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColMessage}),(0,X.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSession}),(0,X.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColAgent})]})}),(0,X.jsx)(`tbody`,{children:c.map(e=>{let t=!e.agentId?.trim(),i=t?``:e.agentId.trim().toLowerCase();return(0,X.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,X.jsx)(`td`,{className:`py-2 pr-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(_n,{kind:`cron`,expression:e.schedule,locale:p,labels:m,timezone:e.timezone,nextRun:e.next_run,className:`text-sm font-medium text-fg`}),(0,X.jsx)(`span`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:e.schedule,children:e.schedule})]})}),(0,X.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:Qt(e),children:Qt(e)}),(0,X.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,X.jsx)(`td`,{className:`py-2 pr-3`,children:(0,X.jsxs)(`select`,{className:J(dn(),`min-w-[8rem] py-1 text-xs`),value:i,disabled:o||e.sessionTarget!==`isolated`,onChange:t=>void l(e,t.target.value),children:[(0,X.jsx)(`option`,{value:``,children:t?n.cronAgentDefault:n.cronAgentClear}),r.agents.map(yn)]})})]},e.id)})})]})}),t[5]=n.cronAgentClear,t[6]=n.cronAgentDefault,t[7]=n.cronColAgent,t[8]=n.cronColMessage,t[9]=n.cronColSchedule,t[10]=n.cronColSession,t[11]=n.cronLoading,t[12]=n.cronNone,t[13]=c,t[14]=o,t[15]=s,t[16]=r,t[17]=p,t[18]=l,t[19]=m,t[20]=g):g=t[20];let _;return t[21]!==h||t[22]!==g?(_=(0,X.jsxs)(Kt,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[h,g]}),t[21]=h,t[22]=g,t[23]=_):_=t[23],_}function yn(e){return(0,X.jsx)(`option`,{value:e.id,children:e.id},e.id)}function bn(e){return e.language}function xn(e){let t=(0,Y.c)(29),{a:n,filesLoading:r,files:i,activeFile:a,setActiveFile:o,filesViewMode:s,setFilesViewMode:c,fileDraft:u,setFileDraft:d,fileSaving:f,profileFileLoading:p,profileEditorNonce:m,onTryInChat:h}=e,g=l(Sn),_;t[0]===n.filesHint?_=t[1]:(_=(0,X.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesHint}),t[0]=n.filesHint,t[1]=_);let v;t[2]!==n.filesAutoSaveHint||t[3]!==n.filesEmpty||t[4]!==n.filesLoading||t[5]!==n.filesMarkdownEdit||t[6]!==n.filesMarkdownPreview||t[7]!==n.filesSavingStatus||t[8]!==n.missing||t[9]!==n.navCoreFiles||t[10]!==n.pickFile||t[11]!==n.tryInChat||t[12]!==a||t[13]!==u||t[14]!==f||t[15]!==i||t[16]!==r||t[17]!==s||t[18]!==g||t[19]!==h||t[20]!==m||t[21]!==p||t[22]!==o||t[23]!==d||t[24]!==c?(v=r?(0,X.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesLoading}):i?(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,X.jsx)(`nav`,{className:`-mx-1 flex shrink-0 flex-wrap gap-1 px-1 pb-1`,role:`tablist`,"aria-label":n.navCoreFiles,children:i.files.map(e=>{let t=a===e.name;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:J(`inline-flex shrink-0 items-center rounded-lg px-3 py-2 font-mono text-xs font-medium whitespace-nowrap transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,ct.press,t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,e.missing&&`opacity-60`),onClick:()=>o(e.name),children:[e.name,e.missing?` (${n.missing})`:``]},e.name)})}),(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":`${n.filesMarkdownEdit} / ${n.filesMarkdownPreview}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:J(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,ct.press,s===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>c(`edit`),children:[(0,X.jsx)(Ht,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownEdit]}),(0,X.jsxs)(`button`,{type:`button`,className:J(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,ct.press,s===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>c(`preview`),children:[(0,X.jsx)(Mt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownPreview]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[f?(0,X.jsx)(`span`,{children:n.filesSavingStatus}):null,(0,X.jsx)(`span`,{children:n.filesAutoSaveHint}),h?(0,X.jsxs)(q,{type:`button`,variant:`secondary`,className:`ml-auto text-xs`,onClick:h,children:[(0,X.jsx)(T,{className:`mr-1 size-3.5`,"aria-hidden":!0}),n.tryInChat]}):null]})]}),s===`edit`?(0,X.jsx)(`div`,{className:J(dn(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,p&&`pointer-events-none opacity-60`),children:(0,X.jsx)(x,{initialContent:u,onChange:d,isDark:g,className:`min-h-0 flex-1`},`${a??`file`}-${m}`)}):(0,X.jsx)(`div`,{className:J(dn(),`min-h-0 flex-1 overflow-y-auto text-sm`,p&&`pointer-events-none opacity-60`),children:(0,X.jsx)(Ut,{content:u,className:`text-sm`})})]}):(0,X.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.pickFile})})]}):(0,X.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesEmpty}),t[2]=n.filesAutoSaveHint,t[3]=n.filesEmpty,t[4]=n.filesLoading,t[5]=n.filesMarkdownEdit,t[6]=n.filesMarkdownPreview,t[7]=n.filesSavingStatus,t[8]=n.missing,t[9]=n.navCoreFiles,t[10]=n.pickFile,t[11]=n.tryInChat,t[12]=a,t[13]=u,t[14]=f,t[15]=i,t[16]=r,t[17]=s,t[18]=g,t[19]=h,t[20]=m,t[21]=p,t[22]=o,t[23]=d,t[24]=c,t[25]=v):v=t[25];let y;return t[26]!==_||t[27]!==v?(y=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function Sn(e){return e.resolved===`dark`}function Z(){return J(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ze,`dark:border-edge`)}function Cn(){return J(jt,Je)}var wn=`h-auto shrink-0 px-2.5 py-1.5 text-xs font-medium`;function Tn(e){let t=(0,Y.c)(25),{rows:n,onChange:r,disabled:i,chat:a,labels:o}=e,s;t[0]!==r||t[1]!==n?(s=(e,t)=>{r(n.map((n,r)=>r===e?{...n,...t}:n))},t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s,l;t[3]!==a||t[4]!==i||t[5]!==o.description||t[6]!==o.descriptionPlaceholder||t[7]!==o.id||t[8]!==o.idPlaceholder||t[9]!==o.remove||t[10]!==r||t[11]!==n||t[12]!==c?(l=n.map((e,t)=>(0,X.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3 sm:grid-cols-[minmax(0,8rem)_minmax(0,1.2fr)_minmax(0,1fr)_auto] sm:items-start dark:border-edge-subtle`,children:[(0,X.jsx)(`input`,{type:`text`,className:Z(),value:e.id,disabled:i,placeholder:o.idPlaceholder,"aria-label":o.id,onChange:e=>c(t,{id:e.target.value.toLowerCase()})}),(0,X.jsx)(Oe,{value:e.model,disabled:i,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,onChange:e=>c(t,{model:e})}),(0,X.jsx)(`input`,{type:`text`,className:Z(),value:e.description,disabled:i,placeholder:o.descriptionPlaceholder,"aria-label":o.description,onChange:e=>c(t,{description:e.target.value})}),(0,X.jsx)(q,{type:`button`,variant:`secondary`,className:`shrink-0 sm:mt-0`,disabled:i,"aria-label":o.remove,onClick:()=>r(n.filter((e,n)=>n!==t)),children:(0,X.jsx)(O,{className:`size-4`,strokeWidth:1.75})})]},e.id||`typed-model-${e.model}-${e.description}`)),t[3]=a,t[4]=i,t[5]=o.description,t[6]=o.descriptionPlaceholder,t[7]=o.id,t[8]=o.idPlaceholder,t[9]=o.remove,t[10]=r,t[11]=n,t[12]=c,t[13]=l):l=t[13];let u;t[14]!==r||t[15]!==n?(u=()=>r([...n,{id:``,description:``,model:``}]),t[14]=r,t[15]=n,t[16]=u):u=t[16];let d;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,X.jsx)(At,{className:`size-4 shrink-0`,strokeWidth:1.75}),t[17]=d):d=t[17];let f;t[18]!==i||t[19]!==o.add||t[20]!==u?(f=(0,X.jsxs)(q,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,disabled:i,onClick:u,children:[d,o.add]}),t[18]=i,t[19]=o.add,t[20]=u,t[21]=f):f=t[21];let p;return t[22]!==l||t[23]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[l,f]}),t[22]=l,t[23]=f,t[24]=p):p=t[24],p}var En=/^[a-z][a-z0-9_-]{0,63}$/;function Dn(e){let t=e.trim(),n=t.indexOf(`/`);return n>0&&n<t.length-1}function On(e){let t=e&&typeof e==`object`&&!Array.isArray(e)&&`roles`in e?Object.entries(e.roles??{}).map(([e,t])=>({id:e,...t&&typeof t==`object`&&!Array.isArray(t)?t:{}})):e;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e,r=typeof t.id==`string`?t.id.trim():``,i=typeof t.model==`string`?t.model.trim():``;if(!r||!i)continue;let a=typeof t.description==`string`?t.description.trim():``;n.push({id:r,model:i,description:a})}return n}function kn(e){let t=new Map;for(let n of e){let e=n.id.trim(),r=n.model.trim();if(!e||!En.test(e)||!r||!Dn(r))continue;let i=n.description.trim();t.set(e,i?{description:i,model:r}:{model:r})}return t.size===0?null:{roles:Object.fromEntries(t.entries())}}function An(e,t){let n=new Set;for(let r of e){let e=r.id.trim(),i=r.model.trim();if(!(!e&&!i&&!r.description.trim())){if(!e||!En.test(e))return t.invalidId;if(n.has(e))return t.duplicateId;if(n.add(e),!i||!Dn(i))return t.invalidModel}}return null}function jn(e){return e.length===0?`—`:e.map(e=>`${e.id} → ${e.model}`).join(`, `)}function Mn(e){return(e??[]).map(e=>({id:e.id,model:e.model,description:e.description?.trim()??``}))}function Nn(e){let t=(0,Y.c)(52),{a:n,chat:r,selected:i,busy:a,modelRows:o,setModelRows:s,onSaveModels:c,onClearModelsEntry:l,hideInlineSave:u}=e,d;t[0]!==n.modelsTabHint||t[1]!==n.modelsTabTitle?(d=(0,X.jsx)(Gt,{className:`shrink-0`,icon:Te,title:n.modelsTabTitle,subtitle:n.modelsTabHint}),t[0]=n.modelsTabHint,t[1]=n.modelsTabTitle,t[2]=d):d=t[2];let f;t[3]===n.modelsDefaultsLabel?f=t[4]:(f=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelsDefaultsLabel}),t[3]=n.modelsDefaultsLabel,t[4]=f);let p;t[5]===i.typedModels.defaults?p=t[6]:(p=jn(i.typedModels.defaults),t[5]=i.typedModels.defaults,t[6]=p);let m;t[7]!==f||t[8]!==p?(m=(0,X.jsxs)(`div`,{children:[f,` `,p]}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]===n.modelsEffectiveLabel?h=t[11]:(h=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelsEffectiveLabel}),t[10]=n.modelsEffectiveLabel,t[11]=h);let g;t[12]===i.typedModels.effective?g=t[13]:(g=jn(i.typedModels.effective),t[12]=i.typedModels.effective,t[13]=g);let _;t[14]!==h||t[15]!==g?(_=(0,X.jsxs)(`div`,{children:[h,` `,g]}),t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==m||t[18]!==_?(v=(0,X.jsxs)(`div`,{className:`mb-4 grid gap-2 rounded-lg border border-edge-subtle bg-surface-base/60 p-3 text-xs text-fg-muted dark:border-edge`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==n.addTypedModel||t[21]!==n.removeTypedModel||t[22]!==n.typedModelDescriptionLabel||t[23]!==n.typedModelDescriptionPlaceholder||t[24]!==n.typedModelIdLabel||t[25]!==n.typedModelIdPlaceholder?(y={id:n.typedModelIdLabel,description:n.typedModelDescriptionLabel,add:n.addTypedModel,remove:n.removeTypedModel,idPlaceholder:n.typedModelIdPlaceholder,descriptionPlaceholder:n.typedModelDescriptionPlaceholder},t[20]=n.addTypedModel,t[21]=n.removeTypedModel,t[22]=n.typedModelDescriptionLabel,t[23]=n.typedModelDescriptionPlaceholder,t[24]=n.typedModelIdLabel,t[25]=n.typedModelIdPlaceholder,t[26]=y):y=t[26];let b;t[27]!==a||t[28]!==r||t[29]!==o||t[30]!==s||t[31]!==y?(b=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,X.jsx)(Tn,{rows:o,onChange:s,disabled:a,chat:r,labels:y})}),t[27]=a,t[28]=r,t[29]=o,t[30]=s,t[31]=y,t[32]=b):b=t[32];let x;t[33]!==n.modelsSave||t[34]!==a||t[35]!==u||t[36]!==c?(x=u?null:(0,X.jsx)(q,{type:`button`,disabled:a,onClick:()=>void c(),children:n.modelsSave}),t[33]=n.modelsSave,t[34]=a,t[35]=u,t[36]=c,t[37]=x):x=t[37];let S;t[38]===l?S=t[39]:(S=()=>void l(),t[38]=l,t[39]=S);let C;t[40]!==n.modelsResetInherit||t[41]!==a||t[42]!==S?(C=(0,X.jsx)(q,{type:`button`,variant:`secondary`,disabled:a,onClick:S,children:n.modelsResetInherit}),t[40]=n.modelsResetInherit,t[41]=a,t[42]=S,t[43]=C):C=t[43];let w;t[44]!==x||t[45]!==C?(w=(0,X.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[x,C]}),t[44]=x,t[45]=C,t[46]=w):w=t[46];let T;return t[47]!==d||t[48]!==w||t[49]!==v||t[50]!==b?(T=(0,X.jsxs)(Kt,{className:`flex min-h-0 flex-1 flex-col`,children:[d,v,b,w]}),t[47]=d,t[48]=w,t[49]=v,t[50]=b,t[51]=T):T=t[51],T}var Q=e(t(),1);function Pn(e){let t=(0,Y.c)(37),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,inputClassName:s,trailing:c}=e,l;t[0]!==r||t[1]!==n?(l={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=l):l=t[2];let u=Bt(l),d;t[3]===n?d=t[4]:(d=n.trim(),t[3]=n,t[4]=d);let f=d,p=f?`${f}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`,m;t[5]===s?m=t[6]:(m=J(`min-w-0 flex-1`,s),t[5]=s,t[6]=m);let h=i||u.picking,g;t[7]===r?g=t[8]:(g=e=>void r(e.target.value),t[7]=r,t[8]=g);let _=o??a.pathInputPlaceholder,v;t[9]!==m||t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==n?(v=(0,X.jsx)(`input`,{type:`text`,className:m,value:n,disabled:h,onChange:g,placeholder:_,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=n,t[14]=v):v=t[14];let y=i||u.picking,x;t[15]!==p||t[16]!==u.pick||t[17]!==y||t[18]!==n||t[19]!==a.selectWorkingDirectory?(x=(0,X.jsx)(b,{compact:!0,value:n,onPick:u.pick,disabled:y,title:p,"aria-label":a.selectWorkingDirectory}),t[15]=p,t[16]=u.pick,t[17]=y,t[18]=n,t[19]=a.selectWorkingDirectory,t[20]=x):x=t[20];let S;t[21]!==x||t[22]!==c?(S=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[x,c]}),t[21]=x,t[22]=c,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==v?(C=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[v,S]}),t[24]=S,t[25]=v,t[26]=C):C=t[26];let w;t[27]!==u.confirmPick||t[28]!==u.hasNativePicker||t[29]!==u.modalOpen||t[30]!==u.setModalOpen||t[31]!==f||t[32]!==a?(w=u.hasNativePicker?null:(0,X.jsx)(j,{open:u.modalOpen,onOpenChange:u.setModalOpen,initialAbsolutePath:f||void 0,onConfirm:u.confirmPick,wd:a}),t[27]=u.confirmPick,t[28]=u.hasNativePicker,t[29]=u.modalOpen,t[30]=u.setModalOpen,t[31]=f,t[32]=a,t[33]=w):w=t[33];let T;return t[34]!==C||t[35]!==w?(T=(0,X.jsxs)(X.Fragment,{children:[C,w]}),t[34]=C,t[35]=w,t[36]=T):T=t[36],T}function Fn(e){let t=(0,Y.c)(19),{label:n,mode:r,value:i,inheritedFrom:a,inheritLabel:o,overrideLabel:s}=e,c;t[0]===n?c=t[1]:(c=(0,X.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=c);let l=i||`—`,u;t[2]===l?u=t[3]:(u=(0,X.jsx)(`p`,{className:`mt-1 truncate text-sm font-medium text-fg`,children:l}),t[2]=l,t[3]=u);let d;t[4]!==a||t[5]!==r?(d=r===`inherit`&&a?(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:a}):null,t[4]=a,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==c||t[8]!==u||t[9]!==d?(f=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[c,u,d]}),t[7]=c,t[8]=u,t[9]=d,t[10]=f):f=t[10];let p=r===`inherit`?`bg-surface-hover text-fg-muted`:`bg-accent-soft text-accent-fg`,m;t[11]===p?m=t[12]:(m=J(`mt-2 inline-flex shrink-0 self-start rounded-full px-2.5 py-0.5 text-xs font-medium sm:mt-0`,p),t[11]=p,t[12]=m);let h=r===`inherit`?o:s,g;t[13]!==m||t[14]!==h?(g=(0,X.jsx)(`span`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==f||t[17]!==g?(_=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[f,g]}),t[16]=f,t[17]=g,t[18]=_):_=t[18],_}function In(e){let t=(0,Y.c)(41),{a:n,defaultModel:r,defaultWorkspace:i,agentModel:a,agentWorkspace:o,settingsPath:s,settingsState:c}=e,l=s===void 0?`/settings/agent-defaults`:s,u=n.inheritance,d;t[0]===a?d=t[1]:(d=a.trim(),t[0]=a,t[1]=d);let f=!d,p;t[2]!==o||t[3]!==i?(p=!o.trim()||i.trim().length>0&&o.trim()===i.trim(),t[2]=o,t[3]=i,t[4]=p):p=t[4];let m=p,h=f?r||u.unset:a,g=m?i||u.unset:o,_;t[5]!==u.editDefaultsLink||t[6]!==l||t[7]!==c?(_=(0,X.jsx)(He,{to:l,state:c,className:`text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:u.editDefaultsLink}),t[5]=u.editDefaultsLink,t[6]=l,t[7]=c,t[8]=_):_=t[8];let v;t[9]!==u.subtitle||t[10]!==u.title||t[11]!==_?(v=(0,X.jsx)(Gt,{icon:G,title:u.title,subtitle:u.subtitle,trailing:_}),t[9]=u.subtitle,t[10]=u.title,t[11]=_,t[12]=v):v=t[12];let y=f?`inherit`:`override`,b;t[13]!==r||t[14]!==u.inheritsValue||t[15]!==f?(b=f&&r?u.inheritsValue.replace(`{{value}}`,r):void 0,t[13]=r,t[14]=u.inheritsValue,t[15]=f,t[16]=b):b=t[16];let x;t[17]!==h||t[18]!==u.badgeInherit||t[19]!==u.badgeOverride||t[20]!==u.modelLabel||t[21]!==y||t[22]!==b?(x=(0,X.jsx)(Fn,{label:u.modelLabel,mode:y,value:h,inheritedFrom:b,inheritLabel:u.badgeInherit,overrideLabel:u.badgeOverride}),t[17]=h,t[18]=u.badgeInherit,t[19]=u.badgeOverride,t[20]=u.modelLabel,t[21]=y,t[22]=b,t[23]=x):x=t[23];let S=m?`inherit`:`override`,C;t[24]!==i||t[25]!==u.inheritsValue||t[26]!==m?(C=m&&i?u.inheritsValue.replace(`{{value}}`,i):void 0,t[24]=i,t[25]=u.inheritsValue,t[26]=m,t[27]=C):C=t[27];let w;t[28]!==g||t[29]!==u.badgeInherit||t[30]!==u.badgeOverride||t[31]!==u.workspaceLabel||t[32]!==S||t[33]!==C?(w=(0,X.jsx)(Fn,{label:u.workspaceLabel,mode:S,value:g,inheritedFrom:C,inheritLabel:u.badgeInherit,overrideLabel:u.badgeOverride}),t[28]=g,t[29]=u.badgeInherit,t[30]=u.badgeOverride,t[31]=u.workspaceLabel,t[32]=S,t[33]=C,t[34]=w):w=t[34];let T;t[35]!==w||t[36]!==x?(T=(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[x,w]}),t[35]=w,t[36]=x,t[37]=T):T=t[37];let E;return t[38]!==T||t[39]!==v?(E=(0,X.jsxs)(Kt,{children:[v,T]}),t[38]=T,t[39]=v,t[40]=E):E=t[40],E}function Ln(e,t){switch(e){case`adventurer`:return t.avatarStyleAdventurer;case`bottts`:return t.avatarStyleRobot;case`lorelei`:return t.avatarStyleLorelei;case`thumbs`:return t.avatarStyleThumbs;case`fun-emoji`:return t.avatarStyleFunEmoji;default:return e}}function Rn(e){let{agentId:t,value:n,onChange:r,a:i,id:a}=e,o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),p=(0,Q.useMemo)(()=>{let e=et(n.trim());return e&&g(e.styleId)?e.styleId:K[0]??`adventurer`},[n]),m=(0,Q.useCallback)(async(e,n)=>{try{await N(t)}catch{}r(Ve(e,n)),f(!1)},[t,r]),h=(0,Q.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){u(null),c(!0);try{await L(t,n),Ot(t),r(Re)}catch(e){let t=e instanceof Error?e.message:``;u(t===`avatar_too_large`?i.avatarTooLarge:t===`unsupported_image_type`||t===`empty_file`?i.avatarInvalidImage:i.avatarUploadFailed)}finally{c(!1)}}},[i,t,r]),_=(e,t)=>{let r=et(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,X.jsxs)(`div`,{...a?{id:a}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.avatarPickerTitle}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{ref:o,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void h(e)}),(0,X.jsxs)(q,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:s,onClick:()=>o.current?.click(),children:[(0,X.jsx)(ye,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s?i.avatarUploading:i.avatarUploadCustom]})]})]}),l?(0,X.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):null,(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:K.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>void m(e,H[0]??t),className:J(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,ct.press,p===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:Ln(e,i)},e))}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[H.map(e=>(0,X.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:J(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,ct.press,_(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,X.jsx)(`img`,{src:me(p,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,X.jsxs)(de,{open:d,onOpenChange:f,children:[(0,X.jsx)(M,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:J(`flex size-12 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-xs font-medium text-fg-muted hover:border-edge hover:text-fg`,ct.press),children:i.avatarMore})}),(0,X.jsx)(ae,{children:(0,X.jsxs)(re,{className:`z-[80] max-h-72 w-[min(22rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border border-edge-subtle bg-surface-panel p-3 shadow-lg`,sideOffset:6,align:`end`,children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:Ln(p,i)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:wt.map(e=>(0,X.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:J(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,ct.press,_(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,X.jsx)(`img`,{src:me(p,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.personaAvatar}),(0,X.jsx)(U,{agentId:t,avatar:n,size:40}),n.trim()&&!et(n.trim())&&n.trim()!==`xopc:custom`?(0,X.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}var zn={name:``,description:``,language:``,creature:``,emoji:``,avatar:``};function Bn(e){let t={...zn};if(!e.trim())return t;let n={name:`name`,description:`description`,language:`language`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
|
|
2
2
|
`)){let e=r.match(/^[-*]\s+\*\*(\w+):\*\*\s*(.*)/i);if(!e)continue;let i=n[e[1].toLowerCase()];if(!i)continue;let a=e[2].trim();/^_\(.*\)_$/.test(a)&&(a=``),t[i]=a}return t}function Vn(e){return[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${e.name}`,`- **Description:** ${e.description}`,`- **Language:** ${e.language}`,`- **Creature:** ${e.creature}`,`- **Emoji:** ${e.emoji}`,`- **Avatar:** ${e.avatar}`,``].join(`
|
|
3
3
|
`)}var Hn={callName:``,pronouns:``,timezone:``,notes:``};function Un(e){let t={...Hn};if(!e.trim())return t;let n={name:`callName`,"what to call them":`callName`,pronouns:`pronouns`,timezone:`timezone`,notes:`notes`},r=e.split(`
|
|
4
4
|
`),i=-1;for(let e=0;e<r.length;e++){let a=r[e];if(/^##\s+Context/i.test(a)){i=e+1;continue}let o=a.match(/^[-*]\s+\*\*(.+?):\*\*\s*(.*)/i);if(!o)continue;let s=n[o[1].toLowerCase().trim()];if(!s)continue;let c=o[2].trim();/^_\(.*\)_$/.test(c)&&(c=``),t[s]=c}if(i>0){let e=r.slice(i).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-DQRqHuL-.js";import{a as s,i as c}from"./vendor-swr-BIWyz7Rc.js";import{a as l,n as u,t as d}from"./fetch-CFdKBnE6.js";import{Ar as f,Cr as p,Dr as m,Ei as h,Er as g,Fo as _,Go as v,Or as y,R as b,Sr as x,Vr as S,Zi as C,Zo as w,br as T,do as E,fi as D,hi as O,ja as k,jr as A,jt as j,ko as M,kr as N,ns as P,pi as F,qi as I,ua as L,va as R,xr as z,yr as B,zn as ee}from"./index-slwUkhxH.js";var V=e(t(),1),H=n();function U(e){return e===`builtin`||e===`user`?e:`marketplace`}async function W(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function te(e){let t=await d(o(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function G(e){let t=await d(o(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function K(e){let t=await d(o(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function q(e){let t=await d(o(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var J=r();function Y(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var X={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function ne({className:e}){let t=a(i(e=>e.language)).appsPage,n=l(e=>!!e.token),r=T(),{mutate:d}=s(),[f,p]=(0,V.useReducer)(b,X),{q:m,debounced:g,detailPkg:_,rowBusy:v,actionError:y,restartHint:x}=f,S=n?`marketplace-${g}`:null;(0,V.useEffect)(()=>{let e=window.setTimeout(()=>p({type:`patch`,patch:{debounced:m.trim()}}),300);return()=>window.clearTimeout(e)},[m]);let{data:w,isLoading:E,error:D}=c(S,async()=>u(g.length>0?o(`/api/marketplace?q=${encodeURIComponent(g)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),O=(0,V.useCallback)(()=>{d(`gateway-extensions-list`),j()},[d]),A=(0,V.useCallback)(async(e,n)=>{p({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await G({name:e,overwrite:n});O(),r.requiresGatewayRestart&&p({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw p({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{p({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,O]),N=(0,V.useCallback)(async e=>{p({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await q(e);O(),n.requiresGatewayRestart&&p({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw p({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{p({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,O]),P=w?.extensions??[];return(0,J.jsxs)(`div`,{className:F(`flex flex-col gap-4`,e),children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(C,{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,J.jsx)(`input`,{type:`search`,value:m,onChange:e=>p({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,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`})]}),D?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:D instanceof Error?D.message:t.marketplaceLoadFailed}):null,y?(0,J.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null,x?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:x}):null,E&&!w?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:P.length===0?(0,J.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):P.map(e=>{let n=Y(r,e.id),i=v===e.id;return(0,J.jsx)(`li`,{className:`list-none`,children:(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>p({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),p({type:`patch`,patch:{detailPkg:e.id}}))},className:F(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,J.jsx)(M,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,J.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,J.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,J.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,J.jsx)(R,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,J.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,J.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,J.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&N(e.id).catch(()=>{})},className:F(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,J.jsx)(k,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(h,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,J.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{A(e.id,!1).catch(()=>{})},className:F(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,J.jsx)(k,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),_?(0,J.jsx)(re,{packageName:_,copy:t,extensions:r,onClose:()=>p({type:`patch`,patch:{detailPkg:null}}),onInstall:A,onUninstall:N}):null]})}function re(e){let t=(0,H.c)(61),{packageName:n,copy:r,extensions:i,onClose:a,onInstall:o,onUninstall:s}=e,[u,d]=(0,V.useState)(!1),p=l(se)?`ext-mp-detail-${n}`:null,m;t[0]===n?m=t[1]:(m=async()=>te(n),t[0]=n,t[1]=m);let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},t[2]=_):_=t[2];let{data:b,error:x,isLoading:S}=c(p,m,_),C;t[3]!==i||t[4]!==n?(C=Y(i,n),t[3]=i,t[4]=n,t[5]=C):C=t[5];let T=C,E=T===`user`,D;t[6]!==r.marketplaceNoReadme||t[7]!==b?(D=b?.readme?.trim()||(b?.description?.trim()?`### ${b.name}\n\n${b.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=b,t[8]=D):D=t[8];let j=D,M;t[9]===a?M=t[10]:(M=e=>!e&&a(),t[9]=a,t[10]=M);let P;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,J.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=P):P=t[11];let I;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,J.jsx)(v,{className:`size-5`}),t[12]=I):I=t[12];let L;t[13]!==r.detailBack||t[14]!==a?(L=(0,J.jsx)(`button`,{type:`button`,onClick:a,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":r.detailBack,children:I}),t[13]=r.detailBack,t[14]=a,t[15]=L):L=t[15];let R;t[16]===r.marketplaceDetailTitle?R=t[17]:(R=(0,J.jsx)(A,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=R);let z;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,J.jsx)(O,{className:`size-5`}),t[18]=z):z=t[18];let B;t[19]!==r.detailClose||t[20]!==a?(B=(0,J.jsx)(`button`,{type:`button`,onClick:a,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":r.detailClose,children:z}),t[19]=r.detailClose,t[20]=a,t[21]=B):B=t[21];let U;t[22]!==B||t[23]!==L||t[24]!==R?(U=(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[L,R,B]}),t[22]=B,t[23]=L,t[24]=R,t[25]=U):U=t[25];let W;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==b||t[32]!==x||t[33]!==S||t[34]!==j?(W=S&&!b?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):x?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):b?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:b.name}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:b.id})}),(0,J.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,J.jsx)(`dd`,{children:b.author.username})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,J.jsx)(`dd`,{children:b.latestVersion.version})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,J.jsx)(`dd`,{children:b.downloads})]})]}),b.readme?.trim()?(0,J.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,J.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,J.jsx)(ee,{content:j})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=b,t[32]=x,t[33]=S,t[34]=j,t[35]=W):W=t[35];let G;t[36]===W?G=t[37]:(G=(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:W}),t[36]=W,t[37]=G);let K;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==b||t[47]!==T||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==E?(K=b?(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:T===`bundled`?(0,J.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,J.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,J.jsx)(w,{to:`/apps?tab=builtin`,onClick:a,className:`inline-flex w-fit items-center justify-center 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:r.marketplaceBuiltinGoBuiltin})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{E&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),o(n,E).catch(ae).finally(()=>d(!1)))},className:F(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,J.jsx)(k,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,E?r.marketplaceReinstall:r.marketplaceInstall]}),E?(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),s(n).then(()=>a()).catch(ie).finally(()=>d(!1)))},className:F(`inline-flex items-center justify-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`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,J.jsx)(h,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=b,t[47]=T,t[48]=a,t[49]=o,t[50]=s,t[51]=n,t[52]=E,t[53]=K):K=t[53];let q;t[54]!==U||t[55]!==G||t[56]!==K?(q=(0,J.jsxs)(N,{children:[P,(0,J.jsxs)(g,{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:oe,children:[U,G,K]})]}),t[54]=U,t[55]=G,t[56]=K,t[57]=q):q=t[57];let X;return t[58]!==q||t[59]!==M?(X=(0,J.jsx)(f,{defaultOpen:!0,onOpenChange:M,children:q}),t[58]=q,t[59]=M,t[60]=X):X=t[60],X}function ie(){}function ae(){}function oe(e){return e.preventDefault()}function se(e){return!!e.token}function ce(){let e=i(e=>e.language),t=a(e),n=S(e=>e.setPageHeader),r=S(e=>e.clearPageHeader),o=T(),s=z(),[c,l]=P(),u=U(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,V.useState)(u),[m,h]=(0,V.useState)(d),[g,_]=(0,V.useState)(null),v=c.toString(),y=(0,V.useRef)(v);if(y.current!==v){y.current=v;let e=U(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,V.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let b=(0,V.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),x=(0,V.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),w=f===`builtin`?b:x,E=(0,V.useMemo)(()=>{let t=m.trim().toLowerCase(),n=w;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[w,m,e]);if((0,V.useEffect)(()=>{_(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?Z(e)===Z(t)&&e.active===t.active?e:t:null})},[o]),(0,V.useLayoutEffect)(()=>(n({startExtra:null,main:(0,J.jsx)(`div`,{className:`min-w-0`,children:(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,J.jsx)(pe,{});let D=f!==`marketplace`&&w.length>0;return(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,J.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.appsPage.appsNavAria,children:[(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`marketplace`,className:F(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,f===`marketplace`?`text-fg`:`text-fg-muted hover:text-fg`,f===`marketplace`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`marketplace`),children:t.appsPage.tabMarketplace}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`builtin`,className:F(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`builtin`?`text-fg`:`text-fg-muted hover:text-fg`,f===`builtin`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`builtin`),children:[t.appsPage.tabBuiltin,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,b.length,`)`]})]}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`user`,className:F(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`user`?`text-fg`:`text-fg-muted hover:text-fg`,f===`user`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`user`),children:[t.appsPage.tabUser,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,x.length,`)`]})]})]}),D?(0,J.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,J.jsx)(C,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(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]}),f===`marketplace`?(0,J.jsx)(ne,{}):f===`builtin`&&b.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&x.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyUser}):E.length===0?(0,J.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,J.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:E.map(e=>(0,J.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,J.jsx)(fe,{extension:g,copy:t.appsPage,onClose:()=>_(null)},g.id):null]})}function Z(e){return e.activationEligible??e.active}function Q(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function le(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function ue(e,t){let n=Z(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function de(e){let t=(0,H.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=Z(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=F(`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`),t[2]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let f;t[5]===d?f=t[6]:(f=(0,J.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:d}),t[5]=d,t[6]=f);let p;t[7]===n.name?p=t[8]:(p=(0,J.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=p);let m;t[9]===n.version?m=t[10]:(m=n.version?(0,J.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=m);let h;t[11]!==p||t[12]!==m?(h=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==r.statusEnabled||t[15]!==s?(g=s?(0,J.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,J.jsx)(_,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,J.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,J.jsx)(L,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=g):g=t[16];let v;t[17]!==h||t[18]!==g?(v=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=v):v=t[19];let y;t[20]!==r.cardNoDescription||t[21]!==n.description?(y=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=y):y=t[22];let b;t[23]===y?b=t[24]:(b=(0,J.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:y}),t[23]=y,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==c?(S=(0,J.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=c,t[27]=S):S=t[27];let C;t[28]!==r||t[29]!==n||t[30]!==i?(C=n.source===`bundled`?(0,J.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:r.badgeBundled}):i?(0,J.jsx)(`span`,{title:Q(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:le(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=C):C=t[31];let w;t[32]!==S||t[33]!==C?(w=(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[S,C]}),t[32]=S,t[33]=C,t[34]=w):w=t[34];let T;t[35]!==v||t[36]!==b||t[37]!==w?(T=(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b,w]}),t[35]=v,t[36]=b,t[37]=w,t[38]=T):T=t[38];let E;t[39]!==T||t[40]!==f?(E=(0,J.jsxs)(`div`,{className:`flex gap-3`,children:[f,T]}),t[39]=T,t[40]=f,t[41]=E):E=t[41];let D;return t[42]!==a||t[43]!==E?(D=(0,J.jsx)(`button`,{type:`button`,onClick:a,className:l,children:E}),t[42]=a,t[43]=E,t[44]=D):D=t[44],D}function fe({extension:e,copy:t,onClose:n}){let{mutate:r}=s(),[i,a]=(0,V.useState)(!1),[o,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=e.activationEligible===!0,h=(0,V.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),a(!0);try{let{requiresGatewayRestart:t}=await K({extensionId:e.id,enabled:!d});await r(`gateway-extensions-list`),j(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[d,t.builtinToggleFailed,e.id,e.source,r]),_=e.ui?.contributions?.pages??[],b=e.ui?.contributions?.settingsPanels??[],S=e.ui?.contributions?.chatWidgets??[],C=e.ui?.contributions?.sidebarPanels??[],T=_.find(e=>e.showInNav)??_[0],M=b[0],P=T?B(e.id,T):null,L=M?`/settings/ext/${e.id}/${M.id}`:e.hasConfigSchema||x(e)?`/settings/ext/${e.id}`:null;return(0,J.jsx)(f,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,J.jsxs)(N,{children:[(0,J.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,J.jsxs)(g,{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,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,J.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,J.jsx)(v,{className:`size-5`})}),(0,J.jsx)(A,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,J.jsxs)(m,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,J.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,J.jsx)(O,{className:`size-5`})})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,J.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,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,J.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,Q(e,t)]}),e.version?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,J.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,J.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:ue(e,t)}),e.source===`bundled`?(0,J.jsxs)(J.Fragment,{children:[(0,J.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.builtinConfigHint}),(0,J.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 dark:bg-surface-hover/20`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,J.jsx)(D,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void h(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(k,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):d?t.builtinToggleDisable:t.builtinToggleEnable})]}),o?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:o}):null,l?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,J.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&&(_.length>0||b.length>0||S.length>0)?(0,J.jsxs)(`section`,{className:`mt-8`,children:[(0,J.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,J.jsx)($,{template:t.badgePages,count:_.length,hidden:_.length===0}),(0,J.jsx)($,{template:t.badgeSettings,count:b.length,hidden:b.length===0}),(0,J.jsx)($,{template:t.badgeWidgets,count:S.length,hidden:S.length===0}),(0,J.jsx)($,{template:t.badgeSidebar,count:C.length,hidden:C.length===0})]})]}):null,p(e)&&(P||L)?(0,J.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[P?(0,J.jsxs)(w,{to:P,onClick:n,className:F(`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,J.jsx)(E,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,L?(0,J.jsxs)(w,{to:L,onClick:n,className:F(`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,J.jsx)(I,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,J.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,H.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,J.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:a}),t[4]=a,t[5]=o),o}function pe(){let e=(0,H.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,J.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,J.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,J.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[t,n,r,(0,J.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(me)})]})}),e[4]=a):a=e[4],a}function me(e){return(0,J.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function he(e){let t=(0,H.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,J.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,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ce as AppsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-DQRqHuL-.js";import{a as s,i as c}from"./vendor-swr-BIWyz7Rc.js";import{a as l,n as u,t as d}from"./fetch-CFdKBnE6.js";import{Ar as f,Cr as p,Dr as m,Ei as h,Er as g,Fo as _,Go as v,Or as y,R as b,Sr as x,Vr as S,Zi as C,Zo as w,br as T,do as E,fi as D,hi as O,ja as k,jr as A,jt as j,ko as M,kr as N,ns as P,pi as F,qi as I,ua as L,va as R,xr as z,yr as B,zn as ee}from"./index-C_2yKRJX.js";var V=e(t(),1),H=n();function U(e){return e===`builtin`||e===`user`?e:`marketplace`}async function W(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function te(e){let t=await d(o(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function G(e){let t=await d(o(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function K(e){let t=await d(o(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function q(e){let t=await d(o(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var J=r();function Y(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var X={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function ne({className:e}){let t=a(i(e=>e.language)).appsPage,n=l(e=>!!e.token),r=T(),{mutate:d}=s(),[f,p]=(0,V.useReducer)(b,X),{q:m,debounced:g,detailPkg:_,rowBusy:v,actionError:y,restartHint:x}=f,S=n?`marketplace-${g}`:null;(0,V.useEffect)(()=>{let e=window.setTimeout(()=>p({type:`patch`,patch:{debounced:m.trim()}}),300);return()=>window.clearTimeout(e)},[m]);let{data:w,isLoading:E,error:D}=c(S,async()=>u(g.length>0?o(`/api/marketplace?q=${encodeURIComponent(g)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),O=(0,V.useCallback)(()=>{d(`gateway-extensions-list`),j()},[d]),A=(0,V.useCallback)(async(e,n)=>{p({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await G({name:e,overwrite:n});O(),r.requiresGatewayRestart&&p({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw p({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{p({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,O]),N=(0,V.useCallback)(async e=>{p({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await q(e);O(),n.requiresGatewayRestart&&p({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw p({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{p({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,O]),P=w?.extensions??[];return(0,J.jsxs)(`div`,{className:F(`flex flex-col gap-4`,e),children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(C,{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,J.jsx)(`input`,{type:`search`,value:m,onChange:e=>p({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,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`})]}),D?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:D instanceof Error?D.message:t.marketplaceLoadFailed}):null,y?(0,J.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null,x?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:x}):null,E&&!w?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:P.length===0?(0,J.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):P.map(e=>{let n=Y(r,e.id),i=v===e.id;return(0,J.jsx)(`li`,{className:`list-none`,children:(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>p({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),p({type:`patch`,patch:{detailPkg:e.id}}))},className:F(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,J.jsx)(M,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,J.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,J.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,J.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,J.jsx)(R,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,J.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,J.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,J.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&N(e.id).catch(()=>{})},className:F(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,J.jsx)(k,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(h,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,J.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{A(e.id,!1).catch(()=>{})},className:F(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,J.jsx)(k,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),_?(0,J.jsx)(re,{packageName:_,copy:t,extensions:r,onClose:()=>p({type:`patch`,patch:{detailPkg:null}}),onInstall:A,onUninstall:N}):null]})}function re(e){let t=(0,H.c)(61),{packageName:n,copy:r,extensions:i,onClose:a,onInstall:o,onUninstall:s}=e,[u,d]=(0,V.useState)(!1),p=l(se)?`ext-mp-detail-${n}`:null,m;t[0]===n?m=t[1]:(m=async()=>te(n),t[0]=n,t[1]=m);let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},t[2]=_):_=t[2];let{data:b,error:x,isLoading:S}=c(p,m,_),C;t[3]!==i||t[4]!==n?(C=Y(i,n),t[3]=i,t[4]=n,t[5]=C):C=t[5];let T=C,E=T===`user`,D;t[6]!==r.marketplaceNoReadme||t[7]!==b?(D=b?.readme?.trim()||(b?.description?.trim()?`### ${b.name}\n\n${b.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=b,t[8]=D):D=t[8];let j=D,M;t[9]===a?M=t[10]:(M=e=>!e&&a(),t[9]=a,t[10]=M);let P;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,J.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=P):P=t[11];let I;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,J.jsx)(v,{className:`size-5`}),t[12]=I):I=t[12];let L;t[13]!==r.detailBack||t[14]!==a?(L=(0,J.jsx)(`button`,{type:`button`,onClick:a,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":r.detailBack,children:I}),t[13]=r.detailBack,t[14]=a,t[15]=L):L=t[15];let R;t[16]===r.marketplaceDetailTitle?R=t[17]:(R=(0,J.jsx)(A,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=R);let z;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,J.jsx)(O,{className:`size-5`}),t[18]=z):z=t[18];let B;t[19]!==r.detailClose||t[20]!==a?(B=(0,J.jsx)(`button`,{type:`button`,onClick:a,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":r.detailClose,children:z}),t[19]=r.detailClose,t[20]=a,t[21]=B):B=t[21];let U;t[22]!==B||t[23]!==L||t[24]!==R?(U=(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[L,R,B]}),t[22]=B,t[23]=L,t[24]=R,t[25]=U):U=t[25];let W;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==b||t[32]!==x||t[33]!==S||t[34]!==j?(W=S&&!b?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):x?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):b?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:b.name}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:b.id})}),(0,J.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,J.jsx)(`dd`,{children:b.author.username})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,J.jsx)(`dd`,{children:b.latestVersion.version})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,J.jsx)(`dd`,{children:b.downloads})]})]}),b.readme?.trim()?(0,J.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,J.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,J.jsx)(ee,{content:j})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=b,t[32]=x,t[33]=S,t[34]=j,t[35]=W):W=t[35];let G;t[36]===W?G=t[37]:(G=(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:W}),t[36]=W,t[37]=G);let K;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==b||t[47]!==T||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==E?(K=b?(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:T===`bundled`?(0,J.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,J.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,J.jsx)(w,{to:`/apps?tab=builtin`,onClick:a,className:`inline-flex w-fit items-center justify-center 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:r.marketplaceBuiltinGoBuiltin})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{E&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),o(n,E).catch(ae).finally(()=>d(!1)))},className:F(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,J.jsx)(k,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,E?r.marketplaceReinstall:r.marketplaceInstall]}),E?(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),s(n).then(()=>a()).catch(ie).finally(()=>d(!1)))},className:F(`inline-flex items-center justify-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`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,J.jsx)(h,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=b,t[47]=T,t[48]=a,t[49]=o,t[50]=s,t[51]=n,t[52]=E,t[53]=K):K=t[53];let q;t[54]!==U||t[55]!==G||t[56]!==K?(q=(0,J.jsxs)(N,{children:[P,(0,J.jsxs)(g,{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:oe,children:[U,G,K]})]}),t[54]=U,t[55]=G,t[56]=K,t[57]=q):q=t[57];let X;return t[58]!==q||t[59]!==M?(X=(0,J.jsx)(f,{defaultOpen:!0,onOpenChange:M,children:q}),t[58]=q,t[59]=M,t[60]=X):X=t[60],X}function ie(){}function ae(){}function oe(e){return e.preventDefault()}function se(e){return!!e.token}function ce(){let e=i(e=>e.language),t=a(e),n=S(e=>e.setPageHeader),r=S(e=>e.clearPageHeader),o=T(),s=z(),[c,l]=P(),u=U(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,V.useState)(u),[m,h]=(0,V.useState)(d),[g,_]=(0,V.useState)(null),v=c.toString(),y=(0,V.useRef)(v);if(y.current!==v){y.current=v;let e=U(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,V.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let b=(0,V.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),x=(0,V.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),w=f===`builtin`?b:x,E=(0,V.useMemo)(()=>{let t=m.trim().toLowerCase(),n=w;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[w,m,e]);if((0,V.useEffect)(()=>{_(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?Z(e)===Z(t)&&e.active===t.active?e:t:null})},[o]),(0,V.useLayoutEffect)(()=>(n({startExtra:null,main:(0,J.jsx)(`div`,{className:`min-w-0`,children:(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,J.jsx)(pe,{});let D=f!==`marketplace`&&w.length>0;return(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,J.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.appsPage.appsNavAria,children:[(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`marketplace`,className:F(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,f===`marketplace`?`text-fg`:`text-fg-muted hover:text-fg`,f===`marketplace`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`marketplace`),children:t.appsPage.tabMarketplace}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`builtin`,className:F(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`builtin`?`text-fg`:`text-fg-muted hover:text-fg`,f===`builtin`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`builtin`),children:[t.appsPage.tabBuiltin,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,b.length,`)`]})]}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`user`,className:F(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`user`?`text-fg`:`text-fg-muted hover:text-fg`,f===`user`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`user`),children:[t.appsPage.tabUser,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,x.length,`)`]})]})]}),D?(0,J.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,J.jsx)(C,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(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]}),f===`marketplace`?(0,J.jsx)(ne,{}):f===`builtin`&&b.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&x.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyUser}):E.length===0?(0,J.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,J.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:E.map(e=>(0,J.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,J.jsx)(fe,{extension:g,copy:t.appsPage,onClose:()=>_(null)},g.id):null]})}function Z(e){return e.activationEligible??e.active}function Q(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function le(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function ue(e,t){let n=Z(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function de(e){let t=(0,H.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=Z(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=F(`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`),t[2]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let f;t[5]===d?f=t[6]:(f=(0,J.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:d}),t[5]=d,t[6]=f);let p;t[7]===n.name?p=t[8]:(p=(0,J.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=p);let m;t[9]===n.version?m=t[10]:(m=n.version?(0,J.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=m);let h;t[11]!==p||t[12]!==m?(h=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==r.statusEnabled||t[15]!==s?(g=s?(0,J.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,J.jsx)(_,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,J.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,J.jsx)(L,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=g):g=t[16];let v;t[17]!==h||t[18]!==g?(v=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=v):v=t[19];let y;t[20]!==r.cardNoDescription||t[21]!==n.description?(y=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=y):y=t[22];let b;t[23]===y?b=t[24]:(b=(0,J.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:y}),t[23]=y,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==c?(S=(0,J.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=c,t[27]=S):S=t[27];let C;t[28]!==r||t[29]!==n||t[30]!==i?(C=n.source===`bundled`?(0,J.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:r.badgeBundled}):i?(0,J.jsx)(`span`,{title:Q(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:le(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=C):C=t[31];let w;t[32]!==S||t[33]!==C?(w=(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[S,C]}),t[32]=S,t[33]=C,t[34]=w):w=t[34];let T;t[35]!==v||t[36]!==b||t[37]!==w?(T=(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b,w]}),t[35]=v,t[36]=b,t[37]=w,t[38]=T):T=t[38];let E;t[39]!==T||t[40]!==f?(E=(0,J.jsxs)(`div`,{className:`flex gap-3`,children:[f,T]}),t[39]=T,t[40]=f,t[41]=E):E=t[41];let D;return t[42]!==a||t[43]!==E?(D=(0,J.jsx)(`button`,{type:`button`,onClick:a,className:l,children:E}),t[42]=a,t[43]=E,t[44]=D):D=t[44],D}function fe({extension:e,copy:t,onClose:n}){let{mutate:r}=s(),[i,a]=(0,V.useState)(!1),[o,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=e.activationEligible===!0,h=(0,V.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),a(!0);try{let{requiresGatewayRestart:t}=await K({extensionId:e.id,enabled:!d});await r(`gateway-extensions-list`),j(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[d,t.builtinToggleFailed,e.id,e.source,r]),_=e.ui?.contributions?.pages??[],b=e.ui?.contributions?.settingsPanels??[],S=e.ui?.contributions?.chatWidgets??[],C=e.ui?.contributions?.sidebarPanels??[],T=_.find(e=>e.showInNav)??_[0],M=b[0],P=T?B(e.id,T):null,L=M?`/settings/ext/${e.id}/${M.id}`:e.hasConfigSchema||x(e)?`/settings/ext/${e.id}`:null;return(0,J.jsx)(f,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,J.jsxs)(N,{children:[(0,J.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,J.jsxs)(g,{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,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,J.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,J.jsx)(v,{className:`size-5`})}),(0,J.jsx)(A,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,J.jsxs)(m,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,J.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,J.jsx)(O,{className:`size-5`})})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,J.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,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,J.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,Q(e,t)]}),e.version?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,J.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,J.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:ue(e,t)}),e.source===`bundled`?(0,J.jsxs)(J.Fragment,{children:[(0,J.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.builtinConfigHint}),(0,J.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 dark:bg-surface-hover/20`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,J.jsx)(D,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void h(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(k,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):d?t.builtinToggleDisable:t.builtinToggleEnable})]}),o?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:o}):null,l?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,J.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&&(_.length>0||b.length>0||S.length>0)?(0,J.jsxs)(`section`,{className:`mt-8`,children:[(0,J.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,J.jsx)($,{template:t.badgePages,count:_.length,hidden:_.length===0}),(0,J.jsx)($,{template:t.badgeSettings,count:b.length,hidden:b.length===0}),(0,J.jsx)($,{template:t.badgeWidgets,count:S.length,hidden:S.length===0}),(0,J.jsx)($,{template:t.badgeSidebar,count:C.length,hidden:C.length===0})]})]}):null,p(e)&&(P||L)?(0,J.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[P?(0,J.jsxs)(w,{to:P,onClick:n,className:F(`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,J.jsx)(E,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,L?(0,J.jsxs)(w,{to:L,onClick:n,className:F(`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,J.jsx)(I,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,J.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,H.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,J.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:a}),t[4]=a,t[5]=o),o}function pe(){let e=(0,H.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,J.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,J.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,J.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[t,n,r,(0,J.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(me)})]})}),e[4]=a):a=e[4],a}function me(e){return(0,J.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function he(e){let t=(0,H.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,J.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,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ce as AppsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-DQRqHuL-.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./circle-check-C23XjkUj.js";import{a as l,n as u,t as d}from"./fetch-CFdKBnE6.js";import{Ar as f,Dr as p,Er as m,Ii as h,Ji as g,N as _,Or as v,Tn as y,Tr as b,Vr as x,cn as S,do as C,es as w,fi as T,hi as E,ia as D,ja as O,jr as k,kr as A,on as j,pi as M,ri as N,sa as P,sn as F,ts as I,vr as L,wn as R}from"./index-slwUkhxH.js";import{t as z}from"./schema-form-a6UJCK55.js";import{t as B}from"./browser-BLJWD7WI.js";var V=n(),H=e(B(),1),U=e(t(),1),W=r();function G(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}async function K(e){let t=await d(o(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function q(e){return e?.type===`poll`&&e.phase===`done`}function J(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function Y(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function X(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ee({entry:e,locale:t,messages:n,onChanged:r,autoStartPrimary:i=!1,compact:a=!1}){let o=(0,U.useMemo)(()=>G(e),[e]),s=(0,U.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[l,u]=(0,U.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,U.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,U.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await K({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,U.useEffect)(()=>{!i||!o||o[1].result!==`qr`||l.payload||l.busy||l.error||d(o[0])},[i,o,d,l.busy,l.error,l.payload]),(0,U.useEffect)(()=>{let t=Y(l.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),H.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,l.payload]),(0,U.useEffect)(()=>{let n=l.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||K({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:q(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),q(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,l.poll]);let f=o?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=J(l.payload),g=Y(l.payload,e.id),_=g?l.generatedQr:X(l.payload),v=l.payload?.type===`form`?l.payload:null,y=l.payload?.type===`diagnostics`?l.payload.checks:null;return(0,W.jsxs)(`div`,{className:a?`space-y-3`:`rounded-lg border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsxs)(`div`,{className:M(`flex flex-wrap items-start gap-3`,a?`justify-end`:`justify-between`),children:[a?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,W.jsxs)(T,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(o[0]),children:[l.busy?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(P,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(T,{type:`button`,variant:`secondary`,disabled:l.busy,onClick:()=>void d(`doctor.run`),children:[(0,W.jsx)(h,{className:`size-4`}),p]}):null]})]}),m?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,l.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:l.error}):null,_?(0,W.jsxs)(`div`,{className:M(`flex flex-wrap items-start gap-4`,a?`justify-center`:`mt-4`),children:[(0,W.jsx)(`div`,{className:`rounded-lg border border-edge bg-white p-3`,children:(0,W.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`h-52 w-52 object-contain`})}),(0,W.jsxs)(`div`,{className:M(`max-w-sm text-sm text-fg-muted`,a&&`w-full text-center`),children:[(0,W.jsx)(`p`,{children:n.waitingConfirmation}),g?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(C,{className:`size-3.5`})]}):null]})]}):null,l.payload?.type===`poll`&&l.payload.phase===`done`?(0,W.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-sm`,children:[(0,W.jsx)(c,{className:l.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:l.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:l.payload.message??(l.payload.ok?n.complete:n.failed)})]}):null,v?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(z,{schema:v.schema,values:l.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:l.busy,labels:s}),(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(v.submitAction,l.formDraft),children:n.saveSetup})]}):null,y?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}function te(e,t=!1){return e===`drawer`?M(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,R):M(`fixed left-1/2 top-1/2 flex max-h-[min(90vh,52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`max-h-[min(90vh,48rem)] w-[min(calc(100%-2rem),36rem)]`,R,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ne(e){let t=(0,V.c)(30),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:d,wide:h,headerExtra:g}=e,_=h===void 0?!1:h,x=n===`drawer`,S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,W.jsx)(v,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,y)}),t[0]=S):S=t[0];let C;t[1]!==n||t[2]!==_?(C=te(n,_),t[1]=n,t[2]=_,t[3]=C):C=t[3];let w;t[4]===s?w=t[5]:(w=s?(0,W.jsx)(k,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=w);let D;t[6]===c?D=t[7]:(D=c?(0,W.jsx)(p,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=D);let O;t[8]!==l||t[9]!==o||t[10]!==g||t[11]!==x||t[12]!==a?(O=x?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,W.jsx)(E,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:M(N,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,W.jsx)(E,{className:`size-4`})})}),g]}),t[8]=l,t[9]=o,t[10]=g,t[11]=x,t[12]=a,t[13]=O):O=t[13];let j=x?`px-4 py-4`:`p-6`,P;t[14]===j?P=t[15]:(P=M(`min-h-0 flex-1 overflow-y-auto`,j),t[14]=j,t[15]=P);let F;t[16]!==u||t[17]!==P?(F=(0,W.jsx)(`div`,{className:P,children:u}),t[16]=u,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==d||t[20]!==C||t[21]!==w||t[22]!==D||t[23]!==O||t[24]!==F?(I=(0,W.jsxs)(A,{children:[S,(0,W.jsxs)(m,{className:C,onOpenAutoFocus:re,children:[w,D,O,F,d]})]}),t[19]=d,t[20]=C,t[21]=w,t[22]=D,t[23]=O,t[24]=F,t[25]=I):I=t[25];let L;return t[26]!==i||t[27]!==r||t[28]!==I?(L=(0,W.jsx)(f,{open:r,onOpenChange:i,children:I}),t[26]=i,t[27]=r,t[28]=I,t[29]=L):L=t[29],L}function re(e){return e.preventDefault()}var ie=(0,U.memo)(function(e){let t=(0,V.c)(15),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s=n.refresh,c=n.refresh,l=r&&`animate-spin`,u;t[3]===l?u=t[4]:(u=M(`size-4`,l),t[3]=l,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,W.jsx)(D,{className:u,"aria-hidden":!0}),t[5]=u,t[6]=d);let f;t[7]!==n.refresh||t[8]!==a||t[9]!==r||t[10]!==d?(f=(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:s,"aria-label":c,onClick:a,children:d}),t[7]=n.refresh,t[8]=a,t[9]=r,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==o||t[13]!==f?(p=(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,f]}),t[12]=o,t[13]=f,t[14]=p):p=t[14],p});function ae(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,W.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,W.jsx)(T,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,W.jsx)(T,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,W.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function oe(e){return o(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function se(e){return(await u(oe(e))).payload?.channels??[]}function ce(e,t){let n=(0,V.c)(14),r;n[0]!==e||n[1]!==t?(r=e?oe(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>se(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:c,isLoading:l,isValidating:u,mutate:d}=s(r,i,a),f;n[6]===o?f=n[7]:(f=o??[],n[6]=o,n[7]=f);let p;return n[8]!==c||n[9]!==l||n[10]!==u||n[11]!==d||n[12]!==f?(p={entries:f,isLoading:l,isValidating:u,error:c,mutate:d},n[8]=c,n[9]=l,n[10]=u,n[11]=d,n[12]=f,n[13]=p):p=n[13],p}function le(e){return e?o(`/api/channels/${encodeURIComponent(e)}/config`):null}async function ue(e){return(await u(o(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}async function de(){return(await u(o(`/api/config`))).payload?.config?.channels??{}}function Z(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function fe(e,t){return e.enabled&&e.runtime===`loaded`?t.hubStatusRunning:e.enabled?t.hubStatusEnabled:e.configured?t.hubStatusConfigured:t.hubStatusNotConfigured}function pe(e){return e.enabled&&e.runtime===`loaded`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e.enabled||e.configured?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`}function me(e){if(!e)return[`enabled`];let t=e.uiHints??{},n=Object.entries(t).filter(([,e])=>!Q(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e);return n.length>0?n:[`enabled`]}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function he(e,t){let n={...$(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Q(r)||!Q(r[n]))break;let o=Q(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...$(r[n]),properties:{}}),e===t.length-1){o[n]=$(r[n]);break}i=r[n],a=o[n]}}return n}function ge(e){let t=e.properties;if(!Q(t))return!1;for(let[e,n]of Object.entries(t))Q(n)&&n.type===`object`&&ge(n)&&delete t[e];return Object.keys(t).length===0}function _e(e,t){let n=$(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Q(i))break;if(e===t.length-1){delete i[n];break}if(!Q(i[n]))break;r=i[n]}}return ge(n),n}function ve(e){return e.type===`object`&&Q(e.properties)&&Object.keys(e.properties).length>0}function ye(e,t){let n=e;for(let e of t.split(`.`)){if(!Q(n))return;n=n[e]}return n}function be(e){let t=e.accounts;return Q(t)?Object.values(t).filter(e=>Q(e)&&e.enabled!==!1).length:+(e.configured===!0)}function xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Se(e,t,n){let r=[];if(t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=xe(e,ye(t,e),n);i&&r.push(i)}let a=be(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,3):e.configured?[n.hubStatusConfigured]:[]}function Ce(e,t){let n=G(e);return n?.[1].label?n[1].label:e.configured?t.manageChannel:t.startConfiguration}function we({entry:e}){let t=l(e=>e.token),[n,r]=(0,U.useState)(!1),i=(0,U.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(o(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Z(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(L,{sourceChannel:e.id,className:`size-7`})})}function Te(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=M(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=M(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,W.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function Ee(e){let t=(0,V.c)(64),{entry:n,config:r,busy:i,ch:a,onOpen:o,onToggle:s}=e,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==o||t[5]!==s){let e=Se(n,r,a);p=`flex min-h-[15.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-surface transition-colors hover:border-edge`;let h;t[13]===n?h=t[14]:(h=(0,W.jsx)(we,{entry:n}),t[13]=n,t[14]=h);let g;t[15]===n.label?g=t[16]:(g=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[15]=n.label,t[16]=g);let _;t[17]===n?_=t[18]:(_=M(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,pe(n)),t[17]=n,t[18]=_);let v;t[19]!==a||t[20]!==n?(v=fe(n,a),t[19]=a,t[20]=n,t[21]=v):v=t[21];let y;t[22]!==_||t[23]!==v?(y=(0,W.jsx)(`span`,{className:_,children:v}),t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;t[28]!==b||t[29]!==h?(x=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,b]}),t[28]=b,t[29]=h,t[30]=x):x=t[30];let S=n.enabled===!0,C;t[31]!==a.toggleChannel||t[32]!==n.label?(C=a.toggleChannel.replace(`{{channel}}`,n.label),t[31]=a.toggleChannel,t[32]=n.label,t[33]=C):C=t[33];let w;t[34]!==i||t[35]!==s||t[36]!==S||t[37]!==C?(w=(0,W.jsx)(Te,{checked:S,disabled:i,label:C,onToggle:s}),t[34]=i,t[35]=s,t[36]=S,t[37]=C,t[38]=w):w=t[38],t[39]!==x||t[40]!==w?(m=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[x,w]}),t[39]=x,t[40]=w,t[41]=m):m=t[41],c=`button`,l=o,u=`mt-5 min-h-[4.5rem] text-left`;let T=n.description??n.id;t[42]===T?d=t[43]:(d=(0,W.jsx)(`p`,{className:`line-clamp-3 text-sm leading-6 text-fg-muted`,children:T}),t[42]=T,t[43]=d),f=e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(De)}):null,t[0]=i,t[1]=a,t[2]=r,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];let h;t[44]!==c||t[45]!==l||t[46]!==u||t[47]!==d||t[48]!==f?(h=(0,W.jsxs)(`button`,{type:c,onClick:l,className:u,children:[d,f]}),t[44]=c,t[45]=l,t[46]=u,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]===i?g=t[51]:(g=i?(0,W.jsx)(O,{className:`size-4 animate-spin`}):null,t[50]=i,t[51]=g);let _;t[52]!==a||t[53]!==n?(_=Ce(n,a),t[52]=a,t[53]=n,t[54]=_):_=t[54];let v;t[55]!==o||t[56]!==_||t[57]!==g?(v=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(T,{type:`button`,variant:`primary`,className:`w-full rounded-2xl py-2.5`,onClick:o,children:[g,_]})}),t[55]=o,t[56]=_,t[57]=g,t[58]=v):v=t[58];let y;return t[59]!==v||t[60]!==p||t[61]!==m||t[62]!==h?(y=(0,W.jsxs)(`article`,{className:p,children:[m,h,v]}),t[59]=v,t[60]=p,t[61]=m,t[62]=h,t[63]=y):y=t[63],y}function De(e){return(0,W.jsx)(`p`,{children:e},e)}function Oe(){let e=i(e=>e.language),t=a(e),n=l(e=>!!e.token),r=w(),{channelId:c}=I(),u=S(c),f=ce(n,e),p=f.entries,{data:m={},mutate:h}=s(n?`channels-config-map`:null,de,{revalidateOnFocus:!1}),v=x(e=>e.setPageHeader),y=x(e=>e.clearPageHeader),b=(0,U.useMemo)(()=>p.find(e=>e.id===u),[u,p]),{data:T,mutate:E}=s(n&&b?le(b.id):null,()=>ue(b.id)),[D,O]=(0,U.useState)(null),[k,A]=(0,U.useState)(!1),[N,P]=(0,U.useState)(null),[L,R]=(0,U.useState)(null),B=D??T??{},V=t.channelsSettings,H=(0,U.useMemo)(()=>b?.configSchema??{type:`object`,properties:{}},[b?.configSchema]),K=(0,U.useMemo)(()=>me(b),[b]),q=(0,U.useMemo)(()=>he(H,K),[K,H]),J=(0,U.useMemo)(()=>_e(H,K),[K,H]),Y=(0,U.useMemo)(()=>({defaultBooleanLabel:V.schemaBooleanDefault,unsupportedArrayType:V.schemaUnsupportedArrayType,arrayAddPlaceholder:V.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>V.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[V]),X=(0,U.useMemo)(()=>n?(0,W.jsx)(ie,{ch:V,refreshing:f.isValidating,saveOk:!1,onRefresh:()=>void f.mutate()}):null,[f,V,n]);(0,U.useLayoutEffect)(()=>(v({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:X}),()=>y()),[y,X,t.settingsSections.channels,v]);let te=(0,U.useCallback)(e=>{r(F(e)),O(null),R(null)},[r]),re=(0,U.useCallback)(()=>{r(j),O(null),R(null)},[r]),oe=(0,U.useCallback)(async()=>{if(!b||!D)return!1;A(!0),R(null);try{let e=await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[b.id]:D}})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error?.message??e.statusText)}return await E(D,!1),await h(),await f.mutate(),O(null),!0}catch(e){return R(e instanceof Error?e.message:String(e)),!1}finally{A(!1)}},[b,f,D,h,E]),se=(0,U.useCallback)(async e=>{P(e.id),R(null);try{let t=await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[e.id]:{enabled:e.enabled!==!0}}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await f.mutate(),await h(),b?.id===e.id&&await E()}catch(e){R(e instanceof Error?e.message:String(e))}finally{P(null)}},[b?.id,f,h,E]),Z=b?.ui?.modal,Q=Z?.placement!==`replace-config`;return n?(0,W.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-6`,children:[f.isLoading?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V.loadingChannels}):f.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(f.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:p.map(e=>(0,W.jsx)(Ee,{entry:e,config:m[e.id]?.config,busy:N===e.id,ch:V,onOpen:()=>te(e.id),onToggle:()=>void se(e)},e.id))}),L?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:L}):null,(0,W.jsx)(ne,{presentation:`modal`,open:!!b,onOpenChange:e=>{e||re()},closeAriaLabel:V.close,srTitle:b?.label??V.selectChannel,srDescription:b?.description,wide:!0,footer:b?(0,W.jsx)(ae,{ch:V,dirty:!!D,saving:k,onCancel:re,onDiscard:()=>O(null),onSave:oe}):null,children:b?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)(we,{entry:b}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:b.label}),(0,W.jsx)(`span`,{className:M(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,pe(b)),children:fe(b,V)})]}),(0,W.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,children:G(b)?.[1].result===`qr`?V.scanLoginHint.replace(`{{channel}}`,b.label):b.description}),b.docsPath?(0,W.jsxs)(`a`,{href:b.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[V.docs,(0,W.jsx)(C,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:V.enabledLabel}),(0,W.jsx)(Te,{checked:b.enabled===!0,disabled:N===b.id,label:V.toggleChannel.replace(`{{channel}}`,b.label),onToggle:()=>void se(b)})]})]})}),Z?.entrypoint&&Z.placement===`before-config`?(0,W.jsx)(_,{extensionId:b.extensionId,extensionName:b.label,entrypoint:Z.entrypoint,permissions:Z.permissions,minHeight:Z.minHeight,maxHeight:Z.maxHeight,initialData:{channelId:b.id,entry:b,config:B}}):null,Z?.placement===`replace-config`?null:(0,W.jsx)(ee,{entry:b,locale:e,messages:V,autoStartPrimary:!0,compact:!0,onChanged:async()=>{await E(),await f.mutate(),await h()}},b.id),Z?.entrypoint&&Z.placement!==`before-config`?(0,W.jsx)(_,{extensionId:b.extensionId,extensionName:b.label,entrypoint:Z.entrypoint,permissions:Z.permissions,minHeight:Z.minHeight,maxHeight:Z.maxHeight,initialData:{channelId:b.id,entry:b,config:B}}):null,Q?(0,W.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:V.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:V.basicConfigurationHint})]}),(0,W.jsx)(z,{schema:q,values:B,onChange:e=>O(e),disabled:k,labels:Y})]}):null,Q&&ve(J)?(0,W.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(g,{className:`size-4 text-fg-muted`}),V.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`border-t border-edge-subtle p-4`,children:(0,W.jsx)(z,{schema:J,values:B,onChange:e=>O(e),disabled:k,labels:Y})})]}):null,L?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:L}):null]}):null})]}):(0,W.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V.tokenRequired})})}export{Oe as ChannelsSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-DQRqHuL-.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./circle-check-C23XjkUj.js";import{a as l,n as u,t as d}from"./fetch-CFdKBnE6.js";import{Ar as f,Dr as p,Er as m,Ii as h,Ji as g,N as _,Or as v,Tn as y,Tr as b,Vr as x,cn as S,do as C,es as w,fi as T,hi as E,ia as D,ja as O,jr as k,kr as A,on as j,pi as M,ri as N,sa as P,sn as F,ts as I,vr as L,wn as R}from"./index-C_2yKRJX.js";import{t as z}from"./schema-form-DEvdni_r.js";import{t as B}from"./browser-BLJWD7WI.js";var V=n(),H=e(B(),1),U=e(t(),1),W=r();function G(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}async function K(e){let t=await d(o(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function q(e){return e?.type===`poll`&&e.phase===`done`}function J(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function Y(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function X(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ee({entry:e,locale:t,messages:n,onChanged:r,autoStartPrimary:i=!1,compact:a=!1}){let o=(0,U.useMemo)(()=>G(e),[e]),s=(0,U.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[l,u]=(0,U.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,U.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,U.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await K({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,U.useEffect)(()=>{!i||!o||o[1].result!==`qr`||l.payload||l.busy||l.error||d(o[0])},[i,o,d,l.busy,l.error,l.payload]),(0,U.useEffect)(()=>{let t=Y(l.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),H.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,l.payload]),(0,U.useEffect)(()=>{let n=l.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||K({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:q(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),q(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,l.poll]);let f=o?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=J(l.payload),g=Y(l.payload,e.id),_=g?l.generatedQr:X(l.payload),v=l.payload?.type===`form`?l.payload:null,y=l.payload?.type===`diagnostics`?l.payload.checks:null;return(0,W.jsxs)(`div`,{className:a?`space-y-3`:`rounded-lg border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsxs)(`div`,{className:M(`flex flex-wrap items-start gap-3`,a?`justify-end`:`justify-between`),children:[a?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,W.jsxs)(T,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(o[0]),children:[l.busy?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(P,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(T,{type:`button`,variant:`secondary`,disabled:l.busy,onClick:()=>void d(`doctor.run`),children:[(0,W.jsx)(h,{className:`size-4`}),p]}):null]})]}),m?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,l.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:l.error}):null,_?(0,W.jsxs)(`div`,{className:M(`flex flex-wrap items-start gap-4`,a?`justify-center`:`mt-4`),children:[(0,W.jsx)(`div`,{className:`rounded-lg border border-edge bg-white p-3`,children:(0,W.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`h-52 w-52 object-contain`})}),(0,W.jsxs)(`div`,{className:M(`max-w-sm text-sm text-fg-muted`,a&&`w-full text-center`),children:[(0,W.jsx)(`p`,{children:n.waitingConfirmation}),g?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(C,{className:`size-3.5`})]}):null]})]}):null,l.payload?.type===`poll`&&l.payload.phase===`done`?(0,W.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-sm`,children:[(0,W.jsx)(c,{className:l.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:l.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:l.payload.message??(l.payload.ok?n.complete:n.failed)})]}):null,v?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(z,{schema:v.schema,values:l.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:l.busy,labels:s}),(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(v.submitAction,l.formDraft),children:n.saveSetup})]}):null,y?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}function te(e,t=!1){return e===`drawer`?M(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,R):M(`fixed left-1/2 top-1/2 flex max-h-[min(90vh,52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`max-h-[min(90vh,48rem)] w-[min(calc(100%-2rem),36rem)]`,R,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ne(e){let t=(0,V.c)(30),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:d,wide:h,headerExtra:g}=e,_=h===void 0?!1:h,x=n===`drawer`,S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,W.jsx)(v,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,y)}),t[0]=S):S=t[0];let C;t[1]!==n||t[2]!==_?(C=te(n,_),t[1]=n,t[2]=_,t[3]=C):C=t[3];let w;t[4]===s?w=t[5]:(w=s?(0,W.jsx)(k,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=w);let D;t[6]===c?D=t[7]:(D=c?(0,W.jsx)(p,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=D);let O;t[8]!==l||t[9]!==o||t[10]!==g||t[11]!==x||t[12]!==a?(O=x?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,W.jsx)(E,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:M(N,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,W.jsx)(E,{className:`size-4`})})}),g]}),t[8]=l,t[9]=o,t[10]=g,t[11]=x,t[12]=a,t[13]=O):O=t[13];let j=x?`px-4 py-4`:`p-6`,P;t[14]===j?P=t[15]:(P=M(`min-h-0 flex-1 overflow-y-auto`,j),t[14]=j,t[15]=P);let F;t[16]!==u||t[17]!==P?(F=(0,W.jsx)(`div`,{className:P,children:u}),t[16]=u,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==d||t[20]!==C||t[21]!==w||t[22]!==D||t[23]!==O||t[24]!==F?(I=(0,W.jsxs)(A,{children:[S,(0,W.jsxs)(m,{className:C,onOpenAutoFocus:re,children:[w,D,O,F,d]})]}),t[19]=d,t[20]=C,t[21]=w,t[22]=D,t[23]=O,t[24]=F,t[25]=I):I=t[25];let L;return t[26]!==i||t[27]!==r||t[28]!==I?(L=(0,W.jsx)(f,{open:r,onOpenChange:i,children:I}),t[26]=i,t[27]=r,t[28]=I,t[29]=L):L=t[29],L}function re(e){return e.preventDefault()}var ie=(0,U.memo)(function(e){let t=(0,V.c)(15),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s=n.refresh,c=n.refresh,l=r&&`animate-spin`,u;t[3]===l?u=t[4]:(u=M(`size-4`,l),t[3]=l,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,W.jsx)(D,{className:u,"aria-hidden":!0}),t[5]=u,t[6]=d);let f;t[7]!==n.refresh||t[8]!==a||t[9]!==r||t[10]!==d?(f=(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:s,"aria-label":c,onClick:a,children:d}),t[7]=n.refresh,t[8]=a,t[9]=r,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==o||t[13]!==f?(p=(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,f]}),t[12]=o,t[13]=f,t[14]=p):p=t[14],p});function ae(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,W.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,W.jsx)(T,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,W.jsx)(T,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,W.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function oe(e){return o(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function se(e){return(await u(oe(e))).payload?.channels??[]}function ce(e,t){let n=(0,V.c)(14),r;n[0]!==e||n[1]!==t?(r=e?oe(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>se(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:c,isLoading:l,isValidating:u,mutate:d}=s(r,i,a),f;n[6]===o?f=n[7]:(f=o??[],n[6]=o,n[7]=f);let p;return n[8]!==c||n[9]!==l||n[10]!==u||n[11]!==d||n[12]!==f?(p={entries:f,isLoading:l,isValidating:u,error:c,mutate:d},n[8]=c,n[9]=l,n[10]=u,n[11]=d,n[12]=f,n[13]=p):p=n[13],p}function le(e){return e?o(`/api/channels/${encodeURIComponent(e)}/config`):null}async function ue(e){return(await u(o(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}async function de(){return(await u(o(`/api/config`))).payload?.config?.channels??{}}function Z(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function fe(e,t){return e.enabled&&e.runtime===`loaded`?t.hubStatusRunning:e.enabled?t.hubStatusEnabled:e.configured?t.hubStatusConfigured:t.hubStatusNotConfigured}function pe(e){return e.enabled&&e.runtime===`loaded`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e.enabled||e.configured?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`}function me(e){if(!e)return[`enabled`];let t=e.uiHints??{},n=Object.entries(t).filter(([,e])=>!Q(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e);return n.length>0?n:[`enabled`]}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function he(e,t){let n={...$(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Q(r)||!Q(r[n]))break;let o=Q(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...$(r[n]),properties:{}}),e===t.length-1){o[n]=$(r[n]);break}i=r[n],a=o[n]}}return n}function ge(e){let t=e.properties;if(!Q(t))return!1;for(let[e,n]of Object.entries(t))Q(n)&&n.type===`object`&&ge(n)&&delete t[e];return Object.keys(t).length===0}function _e(e,t){let n=$(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Q(i))break;if(e===t.length-1){delete i[n];break}if(!Q(i[n]))break;r=i[n]}}return ge(n),n}function ve(e){return e.type===`object`&&Q(e.properties)&&Object.keys(e.properties).length>0}function ye(e,t){let n=e;for(let e of t.split(`.`)){if(!Q(n))return;n=n[e]}return n}function be(e){let t=e.accounts;return Q(t)?Object.values(t).filter(e=>Q(e)&&e.enabled!==!1).length:+(e.configured===!0)}function xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Se(e,t,n){let r=[];if(t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=xe(e,ye(t,e),n);i&&r.push(i)}let a=be(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,3):e.configured?[n.hubStatusConfigured]:[]}function Ce(e,t){let n=G(e);return n?.[1].label?n[1].label:e.configured?t.manageChannel:t.startConfiguration}function we({entry:e}){let t=l(e=>e.token),[n,r]=(0,U.useState)(!1),i=(0,U.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(o(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Z(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(L,{sourceChannel:e.id,className:`size-7`})})}function Te(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=M(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=M(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,W.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function Ee(e){let t=(0,V.c)(64),{entry:n,config:r,busy:i,ch:a,onOpen:o,onToggle:s}=e,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==o||t[5]!==s){let e=Se(n,r,a);p=`flex min-h-[15.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-surface transition-colors hover:border-edge`;let h;t[13]===n?h=t[14]:(h=(0,W.jsx)(we,{entry:n}),t[13]=n,t[14]=h);let g;t[15]===n.label?g=t[16]:(g=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[15]=n.label,t[16]=g);let _;t[17]===n?_=t[18]:(_=M(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,pe(n)),t[17]=n,t[18]=_);let v;t[19]!==a||t[20]!==n?(v=fe(n,a),t[19]=a,t[20]=n,t[21]=v):v=t[21];let y;t[22]!==_||t[23]!==v?(y=(0,W.jsx)(`span`,{className:_,children:v}),t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;t[28]!==b||t[29]!==h?(x=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,b]}),t[28]=b,t[29]=h,t[30]=x):x=t[30];let S=n.enabled===!0,C;t[31]!==a.toggleChannel||t[32]!==n.label?(C=a.toggleChannel.replace(`{{channel}}`,n.label),t[31]=a.toggleChannel,t[32]=n.label,t[33]=C):C=t[33];let w;t[34]!==i||t[35]!==s||t[36]!==S||t[37]!==C?(w=(0,W.jsx)(Te,{checked:S,disabled:i,label:C,onToggle:s}),t[34]=i,t[35]=s,t[36]=S,t[37]=C,t[38]=w):w=t[38],t[39]!==x||t[40]!==w?(m=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[x,w]}),t[39]=x,t[40]=w,t[41]=m):m=t[41],c=`button`,l=o,u=`mt-5 min-h-[4.5rem] text-left`;let T=n.description??n.id;t[42]===T?d=t[43]:(d=(0,W.jsx)(`p`,{className:`line-clamp-3 text-sm leading-6 text-fg-muted`,children:T}),t[42]=T,t[43]=d),f=e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(De)}):null,t[0]=i,t[1]=a,t[2]=r,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];let h;t[44]!==c||t[45]!==l||t[46]!==u||t[47]!==d||t[48]!==f?(h=(0,W.jsxs)(`button`,{type:c,onClick:l,className:u,children:[d,f]}),t[44]=c,t[45]=l,t[46]=u,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]===i?g=t[51]:(g=i?(0,W.jsx)(O,{className:`size-4 animate-spin`}):null,t[50]=i,t[51]=g);let _;t[52]!==a||t[53]!==n?(_=Ce(n,a),t[52]=a,t[53]=n,t[54]=_):_=t[54];let v;t[55]!==o||t[56]!==_||t[57]!==g?(v=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(T,{type:`button`,variant:`primary`,className:`w-full rounded-2xl py-2.5`,onClick:o,children:[g,_]})}),t[55]=o,t[56]=_,t[57]=g,t[58]=v):v=t[58];let y;return t[59]!==v||t[60]!==p||t[61]!==m||t[62]!==h?(y=(0,W.jsxs)(`article`,{className:p,children:[m,h,v]}),t[59]=v,t[60]=p,t[61]=m,t[62]=h,t[63]=y):y=t[63],y}function De(e){return(0,W.jsx)(`p`,{children:e},e)}function Oe(){let e=i(e=>e.language),t=a(e),n=l(e=>!!e.token),r=w(),{channelId:c}=I(),u=S(c),f=ce(n,e),p=f.entries,{data:m={},mutate:h}=s(n?`channels-config-map`:null,de,{revalidateOnFocus:!1}),v=x(e=>e.setPageHeader),y=x(e=>e.clearPageHeader),b=(0,U.useMemo)(()=>p.find(e=>e.id===u),[u,p]),{data:T,mutate:E}=s(n&&b?le(b.id):null,()=>ue(b.id)),[D,O]=(0,U.useState)(null),[k,A]=(0,U.useState)(!1),[N,P]=(0,U.useState)(null),[L,R]=(0,U.useState)(null),B=D??T??{},V=t.channelsSettings,H=(0,U.useMemo)(()=>b?.configSchema??{type:`object`,properties:{}},[b?.configSchema]),K=(0,U.useMemo)(()=>me(b),[b]),q=(0,U.useMemo)(()=>he(H,K),[K,H]),J=(0,U.useMemo)(()=>_e(H,K),[K,H]),Y=(0,U.useMemo)(()=>({defaultBooleanLabel:V.schemaBooleanDefault,unsupportedArrayType:V.schemaUnsupportedArrayType,arrayAddPlaceholder:V.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>V.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[V]),X=(0,U.useMemo)(()=>n?(0,W.jsx)(ie,{ch:V,refreshing:f.isValidating,saveOk:!1,onRefresh:()=>void f.mutate()}):null,[f,V,n]);(0,U.useLayoutEffect)(()=>(v({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:X}),()=>y()),[y,X,t.settingsSections.channels,v]);let te=(0,U.useCallback)(e=>{r(F(e)),O(null),R(null)},[r]),re=(0,U.useCallback)(()=>{r(j),O(null),R(null)},[r]),oe=(0,U.useCallback)(async()=>{if(!b||!D)return!1;A(!0),R(null);try{let e=await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[b.id]:D}})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error?.message??e.statusText)}return await E(D,!1),await h(),await f.mutate(),O(null),!0}catch(e){return R(e instanceof Error?e.message:String(e)),!1}finally{A(!1)}},[b,f,D,h,E]),se=(0,U.useCallback)(async e=>{P(e.id),R(null);try{let t=await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[e.id]:{enabled:e.enabled!==!0}}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await f.mutate(),await h(),b?.id===e.id&&await E()}catch(e){R(e instanceof Error?e.message:String(e))}finally{P(null)}},[b?.id,f,h,E]),Z=b?.ui?.modal,Q=Z?.placement!==`replace-config`;return n?(0,W.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-6`,children:[f.isLoading?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V.loadingChannels}):f.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(f.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:p.map(e=>(0,W.jsx)(Ee,{entry:e,config:m[e.id]?.config,busy:N===e.id,ch:V,onOpen:()=>te(e.id),onToggle:()=>void se(e)},e.id))}),L?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:L}):null,(0,W.jsx)(ne,{presentation:`modal`,open:!!b,onOpenChange:e=>{e||re()},closeAriaLabel:V.close,srTitle:b?.label??V.selectChannel,srDescription:b?.description,wide:!0,footer:b?(0,W.jsx)(ae,{ch:V,dirty:!!D,saving:k,onCancel:re,onDiscard:()=>O(null),onSave:oe}):null,children:b?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)(we,{entry:b}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:b.label}),(0,W.jsx)(`span`,{className:M(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,pe(b)),children:fe(b,V)})]}),(0,W.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,children:G(b)?.[1].result===`qr`?V.scanLoginHint.replace(`{{channel}}`,b.label):b.description}),b.docsPath?(0,W.jsxs)(`a`,{href:b.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[V.docs,(0,W.jsx)(C,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:V.enabledLabel}),(0,W.jsx)(Te,{checked:b.enabled===!0,disabled:N===b.id,label:V.toggleChannel.replace(`{{channel}}`,b.label),onToggle:()=>void se(b)})]})]})}),Z?.entrypoint&&Z.placement===`before-config`?(0,W.jsx)(_,{extensionId:b.extensionId,extensionName:b.label,entrypoint:Z.entrypoint,permissions:Z.permissions,minHeight:Z.minHeight,maxHeight:Z.maxHeight,initialData:{channelId:b.id,entry:b,config:B}}):null,Z?.placement===`replace-config`?null:(0,W.jsx)(ee,{entry:b,locale:e,messages:V,autoStartPrimary:!0,compact:!0,onChanged:async()=>{await E(),await f.mutate(),await h()}},b.id),Z?.entrypoint&&Z.placement!==`before-config`?(0,W.jsx)(_,{extensionId:b.extensionId,extensionName:b.label,entrypoint:Z.entrypoint,permissions:Z.permissions,minHeight:Z.minHeight,maxHeight:Z.maxHeight,initialData:{channelId:b.id,entry:b,config:B}}):null,Q?(0,W.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:V.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:V.basicConfigurationHint})]}),(0,W.jsx)(z,{schema:q,values:B,onChange:e=>O(e),disabled:k,labels:Y})]}):null,Q&&ve(J)?(0,W.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(g,{className:`size-4 text-fg-muted`}),V.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`border-t border-edge-subtle p-4`,children:(0,W.jsx)(z,{schema:J,values:B,onChange:e=>O(e),disabled:k,labels:Y})})]}):null,L?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:L}):null]}):null})]}):(0,W.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V.tokenRequired})})}export{Oe as ChannelsSettingsPanel};
|