@xopcai/xopc 0.0.308 → 0.0.309
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/_locales/en/messages.json +8 -0
- package/dist/browser-ext/_locales/zh_CN/messages.json +8 -0
- package/dist/browser-ext/dist/assets/{sidepanel-BbSQr-6P.css → sidepanel-DD6GEMvc.css} +16 -0
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +537 -96
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-wgSB2HYK.js → activity-store-XKNYlFUI.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-dUotwUO6.js → agent-avatar-dicebear-1S2TFECE.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-C6LflMXr.js → agent-defaults-settings-panel-f0-YFMUz.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-VPDIGRSS.js → agents-CPqUMtCL.js} +1 -1
- package/dist/gateway/static/root/assets/{api-BKHmTb0w.js → api-BEUEE4f2.js} +1 -1
- package/dist/gateway/static/root/assets/api-CN4id43t.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-zPz0rOND.js → app-management-settings-panel-CgVBSqzu.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DhvhR43G.js → appearance-settings-CoWdCokb.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Pmslbzzr.js → apps-page-CexHOcWg.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BQVZMreT.js → archive-plugin-C3ZA6LRS.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CPE-TMPf.js → attachment-load-CdgS6_zy.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-C4IAy_zF.js → automations-page-BtHL2hpg.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-Fx5VUJRu.js → automations-workspace-onJPfmO6.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-DgTl7diZ.js → binary-plugins-CiDhtq_H.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CcOVA-Gw.js → block-editor-Br00T83w.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BzkJog8e.js → browser-automation-inputs-D2tILykA.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page--zKAgj1k.js → browser-automations-page-BVuEmryB.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-DBms6d35.js → browser-settings-page-BgVTyPFY.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-epdDWIZy.js → capabilities-settings-panel-Dra8wj1S.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-B0bsDtmP.js → channels-settings-CkxiMDJ4.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-B2JwuTjG.js → channels-status-swr-Dtder4G_.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BfLd2rIJ.js → chat-terminal-dock-JsMtzDao.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-Ckgc0Py-.js → computer-settings-page-DHerePwo.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-BlC1OXX4.js → connector-service-page-DZFNUTiN.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-By33-bF1.js → connectors-page-cl9ZrV4D.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-expression-CqNE-nf6.js → cron-expression-DAhdv_Xv.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-BS9ZjzYJ.js → date-picker-PacO1m3a.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-CF_zYzxX.js → dependency-picker-B-BcuG1y.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CDwtLR7Z.js → desktop-pet-CdBBhhdY.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-C0djIc1J.js → desktop-pet-settings-Gy03NgMI.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-CDKj9LQj.js → device-pairing-wizard-aV25nKag.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CX5OXxEU.js → extension-debug-page-BFp5eKtY.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BytR1PaY.js → extension-page-DL3vyyH6.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CkaMJA5F.js → extension-settings-page-BXtvdAsY.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-B6wHa6ZI.js → gateway-config-swr-xAOGtenO.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-B53R0CA4.js → gateway-realtime-BuaTsMSi.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BG95uGVW.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-_YU-1p0z.js → gateway-settings-Dcr2Ikeh.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DRzGnEV-.js → gateway-startup-retry-BwDxKHd4.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CVIvvm4x.js → heartbeat-settings-DOy3alvT.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-COCHelcL.js → home-page-CDm3dGVy.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-Ck_pyDom.js → image-generation-api-wGMeI_yW.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-DrtbjL8O.js → imports-page-zexFT5Rq.js} +1 -1
- package/dist/gateway/static/root/assets/index-D-vczw_0.css +1 -0
- package/dist/gateway/static/root/assets/{index-CDfcPiPb.js → index-DJo4DimT.js} +47 -47
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BlZh41Xq.js → keyboard-shortcuts-settings-CutG9zLh.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-D7_Raxjw.js → local-app-workbench-page-CwLvTwjn.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-DbP7wWuh.js → local-apps-page-CJy6I7Dt.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-msTfRK8P.js → locale-store-DPZ79W1-.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-C0n66FiO.js → logs-page-egGcPHNi.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-i6GhxpGV.js → management-settings-BQhIOELc.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-BInabSKf.js → markdown-view-p2P5hP1U.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CnWChQ3Y.js → media-plugins-CsBylqlN.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BiYTyLJr.js +3 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-C59d8vDW.js → note-detail-panel-c2k5Uz6X.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-C1GBPrVI.js → notes-page-BLQWJMhf.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-BWitjb3e.js → page-tabs-ChQ4jJFs.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-UaCWCxZv.js → preview-open-alternatives-9B5W7nVE.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-page-CtSFJxoM.js → proactive-page-iOjI0d_e.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-gmi5LLwM.js → product-open-page-BADxWEdP.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-ILTmQ1YN.js → project-detail-page-BcxbQn2M.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-snl4rOQZ.js → projects-page-BuSvld0O.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-BSWtko7U.js → registry-api-B_e_nZSN.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BbaAcEN3.js → remote-access-hub-CFS8LQKW.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CtOjKGWg.js → runtime-tools-settings-panel-D-pwiIyp.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DkyyDcl2.js → schema-form-IWmb05DX.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-DrWL71O8.js → sessions-page-DZjc__ok.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C1SM5B93.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-C0JDGN_V.js → settings-form-section-B0veRBZs.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DiIyMQ52.js → settings-page-CxRWyWYe.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-EPazhoZO.js → setup-status-panel-D9Rl7Tec.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-Bt1K657Y.js → share-preview-page-CirpgkfD.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-g2MdRXSZ.js → shares-settings-CwCThBs0.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DG6VGbOX.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-Wd0uYSPG.js → skills-page-BdRJ2vnL.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-vq5Ujm03.js → skills-page.utils-B42mpWKV.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Cz1P-HDH.js → system-settings-panel-DXIZpAvU.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BG3A5gPZ.js → task-detail-page-QXo9LJly.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-1SZ-HFHX.js → theme-store-BFbj_2Tu.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-DQGoFuZO.js → tunnel-api-Db2guRdW.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-DVDlBb95.js → use-autosave-DDY9qoXZ.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-qM5UiTGx.js → user-model-page-CzPmMkaO.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-B2pZCcxY.js → voice-api-key-field-BZbKQ8HT.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-DgJML_uM.js → voice-config-api-SKCeQLrH.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-Bptv7bEY.js → work-discovery-overlay-BRVTTXNG.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BijCrNc4.js → workflow-run-setup-panel-D2kuwv5e.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DRy1RAYH.js → workflows-page-CQXtiYtq.js} +1 -1
- package/dist/gateway/static/root/index.html +12 -12
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/sessions.js +6 -1
- package/dist/src/agent/agent-manager.js +29 -4
- package/dist/src/agent/child-agent-factory.d.ts +1 -0
- package/dist/src/agent/child-agent-factory.js +18 -4
- package/dist/src/agent/coding/repository-instructions.d.ts +4 -0
- package/dist/src/agent/coding/repository-instructions.js +46 -2
- package/dist/src/agent/data-acquisition/git.d.ts +17 -0
- package/dist/src/agent/data-acquisition/git.js +100 -0
- package/dist/src/agent/data-acquisition/render.d.ts +7 -0
- package/dist/src/agent/data-acquisition/render.js +79 -0
- package/dist/src/agent/data-acquisition/scheduler.d.ts +12 -0
- package/dist/src/agent/data-acquisition/scheduler.js +53 -0
- package/dist/src/agent/data-acquisition/schema.d.ts +75 -0
- package/dist/src/agent/data-acquisition/schema.js +206 -0
- package/dist/src/agent/data-acquisition/service.d.ts +10 -0
- package/dist/src/agent/data-acquisition/service.js +292 -0
- package/dist/src/agent/data-acquisition/types.d.ts +37 -0
- package/dist/src/agent/data-acquisition/types.js +5 -0
- package/dist/src/agent/embedded/run-turn.js +16 -4
- package/dist/src/agent/embedded/session-runner.d.ts +1 -0
- package/dist/src/agent/embedded/session-runner.js +3 -0
- package/dist/src/agent/embedded/tool-result-truncation.js +11 -0
- package/dist/src/agent/embedded/xopc-tools-bridge.js +2 -1
- package/dist/src/agent/external-tools/composio-provider.js +12 -1
- package/dist/src/agent/external-tools/gateway-tools.js +2 -1
- package/dist/src/agent/external-tools/index.js +8 -1
- package/dist/src/agent/external-tools/read-policy.d.ts +6 -0
- package/dist/src/agent/external-tools/read-policy.js +21 -0
- package/dist/src/agent/external-tools/service.d.ts +1 -0
- package/dist/src/agent/external-tools/service.js +4 -1
- package/dist/src/agent/external-tools/types.d.ts +2 -0
- package/dist/src/agent/orchestration/agent-turn-policy.js +25 -10
- package/dist/src/agent/orchestration/delegation-scope.d.ts +9 -0
- package/dist/src/agent/orchestration/delegation-scope.js +11 -0
- package/dist/src/agent/prompt/sections/tooling.js +3 -1
- package/dist/src/agent/prompt/subagent-context.js +4 -2
- package/dist/src/agent/sandbox/fileAccess.d.ts +2 -0
- package/dist/src/agent/sandbox/fileAccess.js +31 -2
- package/dist/src/agent/tools/dataBatch.d.ts +4 -0
- package/dist/src/agent/tools/dataBatch.js +50 -0
- package/dist/src/agent/tools/delegate-tool.d.ts +6 -3
- package/dist/src/agent/tools/delegate-tool.js +65 -48
- package/dist/src/agent/tools/delegation-parent-policy.d.ts +7 -0
- package/dist/src/agent/tools/delegation-parent-policy.js +41 -0
- package/dist/src/agent/tools/delegation-policy.d.ts +16 -0
- package/dist/src/agent/tools/delegation-policy.js +93 -0
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +42 -3
- package/dist/src/agent/tools/fetch-text.d.ts +7 -0
- package/dist/src/agent/tools/fetch-text.js +86 -0
- package/dist/src/agent/tools/find.js +1 -1
- package/dist/src/agent/tools/grep.js +11 -23
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/knowledge-memory-tool.js +10 -2
- package/dist/src/agent/tools/read.js +7 -5
- package/dist/src/agent/tools/repository-search.d.ts +12 -2
- package/dist/src/agent/tools/repository-search.js +127 -74
- package/dist/src/agent/tools/web.js +19 -28
- package/dist/src/agent/workflow/subagent-runner.js +25 -3
- package/dist/src/agent/workflow/workflow-child-tools.js +13 -8
- package/dist/src/agent-config/schema.d.ts +7 -0
- package/dist/src/agent-config/schema.js +2 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/schema.d.ts +4 -0
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/heartbeat/service.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.d.ts +2 -0
- package/dist/src/gateway/hono/routes/sessions.js +141 -13
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/storage/sqlite/index.d.ts +1 -0
- package/dist/src/storage/sqlite/index.js +2 -1
- package/dist/src/storage/sqlite/migrations/186_sidebar_layout.sql +16 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/sidebar-layout-repository.d.ts +12 -0
- package/dist/src/storage/sqlite/sidebar-layout-repository.js +53 -0
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/api-DFOlahZv.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BLDgrJ30.js +0 -1
- package/dist/gateway/static/root/assets/index-CRu1p38D.css +0 -1
- package/dist/gateway/static/root/assets/messages-F74LVAiU.js +0 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-BG0kl4HT.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B1DPzu98.js +0 -1
package/dist/gateway/static/root/assets/{sessions-page-DrWL71O8.js → sessions-page-DZjc__ok.js}
RENAMED
|
@@ -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{h as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as a,r as o}from"./popover-select-9i-ZtHXL.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-JdwAhgNB.js";import{a as d,c as f,n as p,r as m}from"./locale-store-msTfRK8P.js";import{t as h}from"./messages-F74LVAiU.js";import{a as g,n as _,o as v,r as y,s as ee,t as b}from"./dist-BGTk37IG.js";import{i as te}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-CS04eWY9.js";import{n as S,r as C}from"./gateway-config-swr-B6wHa6ZI.js";import{t as w}from"./skeleton-BwbyijEw.js";import{i as ne,o as T}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as E,t as D}from"./registry-api-BSWtko7U.js";import{$i as O,Cc as k,Dc as A,Dl as j,Eo as M,F as re,Gs as N,Hc as P,Jl as F,Nt as I,Pt as L,Qi as R,Qu as z,Sa as B,Tl as V,Uc as H,Zu as ie,_a as U,ai as ae,al as W,bs as oe,ca as se,cu as G,da as ce,ea as le,fa as ue,ga as de,ha as fe,ma as pe,nc as me,pa as he,rl as K,va as ge,wl as _e,xa as ve,xs as q,xu as ye,ya as be}from"./index-CDfcPiPb.js";import{n as xe,r as Se}from"./settings-page-layout-X1x-2Cp9.js";import{n as Ce,t as J}from"./settings-form-section-C0JDGN_V.js";import{n as Y,t as we}from"./use-autosave-DVDlBb95.js";import{t as Te}from"./page-tabs-BWitjb3e.js";import{t as Ee}from"./settings-advanced-gate-BG0kl4HT.js";var X=e(t(),1),De=n(),Z=r();function Oe(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function ke(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ae(e){let t=(0,De.c)(113),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,d;t[0]!==i.unnamedSession||t[1]!==n.name?(d=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=d):d=t[2];let f=d,m=p(Pe),g;t[3]!==m||t[4]!==n?(g=ue(n,h(m).sidebar.sessionFilters),t[3]=m,t[4]=n,t[5]=g):g=t[5];let _=g,v;t[6]===n.name?v=t[7]:(v=n.name?.trim(),t[6]=n.name,t[7]=v);let y=!!v,ee=n.status===`archived`,b=n.status===`pinned`,te=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,x;t[8]===te?x=t[9]:(x=u(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,te),t[8]=te,t[9]=x);let S;t[10]===c?S=t[11]:(S=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[10]=c,t[11]=S);let C=r===`list`&&`sm:py-3`,w;t[12]===C?w=t[13]:(w=u(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,C),t[12]=C,t[13]=w);let ne;t[14]===n?ne=t[15]:(ne=(0,Z.jsx)(ce,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[14]=n,t[15]=ne);let T;t[16]===_?T=t[17]:(T=(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:_}),t[16]=_,t[17]=T);let E;t[18]!==T||t[19]!==ne?(E=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[ne,T]}),t[18]=T,t[19]=ne,t[20]=E):E=t[20];let D;t[21]===b?D=t[22]:(D=b?(0,Z.jsx)(H,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[21]=b,t[22]=D);let O;t[23]===n.updatedAt?O=t[24]:(O=Oe(n.updatedAt),t[23]=n.updatedAt,t[24]=O);let k;t[25]===O?k=t[26]:(k=(0,Z.jsx)(`span`,{children:O}),t[25]=O,t[26]=k);let A;t[27]!==D||t[28]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[D,k]}),t[27]=D,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==E||t[31]!==A||t[32]!==w?(j=(0,Z.jsxs)(`div`,{className:w,children:[E,A]}),t[30]=E,t[31]=A,t[32]=w,t[33]=j):j=t[33];let M=r===`list`&&`sm:py-3`,F;t[34]===M?F=t[35]:(F=u(`min-w-0 flex-1 px-3 py-2`,M),t[34]=M,t[35]=F);let I=r===`list`&&`sm:items-start`,L;t[36]===I?L=t[37]:(L=u(`flex gap-3`,I),t[36]=I,t[37]=L);let R;t[38]!==o||t[39]!==a?(R=(0,Z.jsx)(re,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[38]=o,t[39]=a,t[40]=R):R=t[40];let B;t[41]===f?B=t[42]:(B=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[41]=f,t[42]=B);let V;t[43]!==n.key||t[44]!==y?(V=y?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[43]=n.key,t[44]=y,t[45]=V):V=t[45];let U;t[46]!==B||t[47]!==V?(U=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[B,V]}),t[46]=B,t[47]=V,t[48]=U):U=t[48];let ae;t[49]!==L||t[50]!==R||t[51]!==U?(ae=(0,Z.jsxs)(`div`,{className:L,children:[R,U]}),t[49]=L,t[50]=R,t[51]=U,t[52]=ae):ae=t[52];let se;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(W,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[53]=se):se=t[53];let G;t[54]===n.messageCount?G=t[55]:(G=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[se,n.messageCount]}),t[54]=n.messageCount,t[55]=G);let le;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(N,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[56]=le):le=t[56];let de;t[57]===n.estimatedTokens?de=t[58]:(de=ke(n.estimatedTokens),t[57]=n.estimatedTokens,t[58]=de);let fe;t[59]===de?fe=t[60]:(fe=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[le,de]}),t[59]=de,t[60]=fe);let pe;t[61]!==G||t[62]!==fe?(pe=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[G,fe]}),t[61]=G,t[62]=fe,t[63]=pe):pe=t[63];let he;t[64]===n.tags?he=t[65]:(he=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Ne),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[64]=n.tags,t[65]=he);let K;t[66]!==F||t[67]!==ae||t[68]!==pe||t[69]!==he?(K=(0,Z.jsxs)(`div`,{className:F,children:[ae,pe,he]}),t[66]=F,t[67]=ae,t[68]=pe,t[69]=he,t[70]=K):K=t[70];let ge;t[71]===l?ge=t[72]:(ge=()=>l(`continue`),t[71]=l,t[72]=ge);let _e;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(W,{className:`size-4`,strokeWidth:1.75}),t[73]=_e):_e=t[73];let ve;t[74]!==i.continueChat||t[75]!==ge?(ve=(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.continueChat,"aria-label":i.continueChat,onClick:ge,children:_e}),t[74]=i.continueChat,t[75]=ge,t[76]=ve):ve=t[76];let q;t[77]!==ee||t[78]!==i.archive||t[79]!==i.unarchive||t[80]!==l?(q=ee?(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(z,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75})}),t[77]=ee,t[78]=i.archive,t[79]=i.unarchive,t[80]=l,t[81]=q):q=t[81];let ye;t[82]!==b||t[83]!==i.pin||t[84]!==i.unpin||t[85]!==l?(ye=b?(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(P,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(H,{className:`size-4`,strokeWidth:1.75})}),t[82]=b,t[83]=i.pin,t[84]=i.unpin,t[85]=l,t[86]=ye):ye=t[86];let be;t[87]===l?be=t[88]:(be=()=>l(`export`),t[87]=l,t[88]=be);let xe;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[89]=xe):xe=t[89];let Se;t[90]!==i.export||t[91]!==be?(Se=(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.export,"aria-label":i.export,onClick:be,children:xe}),t[90]=i.export,t[91]=be,t[92]=Se):Se=t[92];let Ce;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=u(oe,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[93]=Ce):Ce=t[93];let J;t[94]===l?J=t[95]:(J=()=>l(`delete`),t[94]=l,t[95]=J);let Y;t[96]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Z.jsx)(me,{className:`size-4`,strokeWidth:1.75}),t[96]=Y):Y=t[96];let we;t[97]!==i.delete||t[98]!==J?(we=(0,Z.jsx)(`button`,{type:`button`,className:Ce,title:i.delete,"aria-label":i.delete,onClick:J,children:Y}),t[97]=i.delete,t[98]=J,t[99]=we):we=t[99];let Te;t[100]!==ve||t[101]!==q||t[102]!==ye||t[103]!==Se||t[104]!==we?(Te=(0,Z.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Me,onKeyDown:je,children:[ve,q,ye,Se,we]}),t[100]=ve,t[101]=q,t[102]=ye,t[103]=Se,t[104]=we,t[105]=Te):Te=t[105];let Ee;return t[106]!==c||t[107]!==j||t[108]!==K||t[109]!==Te||t[110]!==x||t[111]!==S?(Ee=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:x,onClick:c,onKeyDown:S,children:[j,K,Te]}),t[106]=c,t[107]=j,t[108]=K,t[109]=Te,t[110]=x,t[111]=S,t[112]=Ee):Ee=t[112],Ee}function je(e){return e.stopPropagation()}function Me(e){return e.stopPropagation()}function Ne(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Pe(e){return e.language}function Fe(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Ie(e,t){return t.find(t=>t.id===e)?.avatar}var Le={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ze(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Be(e){let t=Re(e)?e:{},n=Re(t.userContext)?t.userContext:{},r=Re(n.contextPlanning)?n.contextPlanning:{},i=Re(r.compaction)?r.compaction:{},a=Le,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:ze(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ve(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function He(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function Ue(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify(He(e))}),await S()}var We=128e3,Ge={balanced:Le,preserve:{...Le,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Le,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ke=R();function qe(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,M,`dark:border-edge`)}function Je(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function Ye(e){let t=Je(e);for(let[e,n]of Object.entries(Ge))if(t===Je(n))return e;return`custom`}function Xe(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,De.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=qe(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ze(e){let t=(0,De.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=u(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[d,m]}),t[15]=c,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function Qe({hasToken:e}){let t=h(p(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=C(e),{data:i=[],isLoading:a}=te(e?D:null,E,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Be(n.payload.config),[n]),[s,d]=(0,X.useReducer)(Ke,{form:null,baseline:null}),[f,m]=(0,X.useState)(``),g=(0,X.useRef)(!1),_=(0,X.useRef)(s.form);_.current=s.form;let v=(0,X.useRef)(null);O({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:v,dispatch:d,onResetDirty:()=>{g.current=!1}});let y=s.form,ee=s.baseline,b=!!(y&&ee&&JSON.stringify(y)!==JSON.stringify(ee)),S=(0,X.useCallback)(e=>{g.current=!0,d({type:`patch`,patch:e})},[]),ne=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),T=we({value:y,dirty:b,onSave:(0,X.useCallback)(async e=>{try{await Ue(e),d({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ve(e);return n?t.invalidValue.replace(`{{field}}`,ne(n)):null}});if(!e||!y)return r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(w,{className:`h-5 w-48`}),(0,Z.jsx)(w,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(w,{className:`h-36 w-full rounded-xl`})]})}):null;let k=Ye(y),A=Math.max(0,We-y.reserveTokens),j=Math.min(Math.floor(We*y.triggerThreshold),A),M=Math.min(100,j/We*100),re=Math.min(100,A/We*100),N=y.model?i.find(e=>e.id===y.model):void 0,P=N?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>N.contextWindow,F=y.keepRecentTokens+y.reserveTokens>j,I=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),L=e=>{let t=Ge[e];S({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},R={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},z=()=>{let e=f.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(S({postCompactionSections:[...y.postCompactionSections,e]}),m(``))};return(0,Z.jsxs)(J,{onBlurCapture:T.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:K,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Y,{status:T.status,error:T.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>S({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),T.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:T.error}):null,y.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!y.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),k===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":k===e,className:u(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,q.transition,q.focusRingPanel,k===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>L(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:R[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:R[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Xe(j)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${M}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Xe(A)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${re}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>S({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Xe(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>S({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>S({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Xe(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>S({keepRecentTokens:Math.floor(e)})})]}),F?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(ae,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>S({model:e})}),y.model?(0,Z.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>S({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ze,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>S({qualityGuard:e})}),(0,Z.jsx)(Ze,{label:t.gapAudit,hint:t.gapAuditHint,checked:y.gapAudit,onChange:e=>S({gapAudit:e})})]}),y.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(Ee,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:y.minMessagesBeforeCompact,min:2,onChange:e=>S({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>S({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>S({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>S({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(I)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>S({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>S({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>S({minToolResultKeepChars:Math.floor(e)})})]}),P?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),y.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:u(`text-fg-muted hover:text-fg`,q.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>S({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(l,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:qe(),value:f,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())}}),(0,Z.jsxs)(x,{type:`button`,variant:`secondary`,disabled:!f.trim()||y.postCompactionSections.length>=12,onClick:z,children:[(0,Z.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function $e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function et(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function tt(e){let t=$e(e)?e:{},n=$e(t.session)?t.session:{},r=$e(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:et(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function nt(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),S()}function rt(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,M,`dark:border-edge`)}var it=R();function at({hasToken:e}){let t=h(p(e=>e.language)).sessions.config,{data:n,isLoading:r}=C(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:tt(n.payload.config),[n]),[s,c]=(0,X.useReducer)(it,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),f=(0,X.useRef)(l);f.current=l;let m=(0,X.useRef)(null);O({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:m,dispatch:c,onResetDirty:()=>{d.current=!1}});let g=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),_=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=we({value:l,dirty:g,onSave:(0,X.useCallback)(async e=>{try{await nt(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(w,{className:`h-5 w-40`}),(0,Z.jsx)(w,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(J,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:G,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(Y,{status:v.status,error:v.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(a,{className:rt(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Z.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:rt(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:rt(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function ot(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function st(e){let t=(0,De.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:d,onUnarchive:f,onPin:p,onUnpin:m,onExport:h,onDelete:te}=e,S=i?.status===`archived`,C=i?.status===`pinned`,w;t[0]===c?w=t[1]:(w=e=>!e&&c(),t[0]=c,t[1]=w);let E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(g,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,T)}),t[2]=E):E=t[2];let D;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D=u(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,ne,`dark:border-edge`),t[3]=D):D=t[3];let O;t[4]!==i||t[5]!==o||t[6]!==a?(O=i&&a?(0,Z.jsx)(re,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=O):O=t[7];let k;t[8]!==s.unnamedSession||t[9]!==i?.name?(k=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=k):k=t[10];let A;t[11]===k?A=t[12]:(A=(0,Z.jsx)(ee,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:k}),t[11]=k,t[12]=A);let j;t[13]!==O||t[14]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[O,A]}),t[13]=O,t[14]=A,t[15]=j):j=t[15];let M;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(l,{className:`size-5`,strokeWidth:1.75}),t[16]=M):M=t[16];let N;t[17]===s.close?N=t[18]:(N=(0,Z.jsx)(_,{asChild:!0,children:(0,Z.jsx)(x,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:M})}),t[17]=s.close,t[18]=N);let P;t[19]!==j||t[20]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[j,N]}),t[19]=j,t[20]=N,t[21]=P):P=t[21];let F;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(F=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(ct)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=F):F=t[26];let I;t[27]===F?I=t[28]:(I=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:F}),t[27]=F,t[28]=I);let L;t[29]!==s.detailExport||t[30]!==h?(L=(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.detailExport}),t[29]=s.detailExport,t[30]=h,t[31]=L):L=t[31];let R;t[32]!==S||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==d||t[36]!==f?(R=S?(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unarchive}):(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.archive}),t[32]=S,t[33]=s.archive,t[34]=s.unarchive,t[35]=d,t[36]=f,t[37]=R):R=t[37];let z;t[38]!==C||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==p||t[42]!==m?(z=C?(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.unpin}):(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.pin}),t[38]=C,t[39]=s.pin,t[40]=s.unpin,t[41]=p,t[42]=m,t[43]=z):z=t[43];let B;t[44]!==s.delete||t[45]!==te?(B=(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:te,children:s.delete}),t[44]=s.delete,t[45]=te,t[46]=B):B=t[46];let V;t[47]!==L||t[48]!==R||t[49]!==z||t[50]!==B?(V=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[L,R,z,B]})}),t[47]=L,t[48]=R,t[49]=z,t[50]=B,t[51]=V):V=t[51];let H;t[52]!==P||t[53]!==I||t[54]!==V?(H=(0,Z.jsxs)(v,{children:[E,(0,Z.jsxs)(y,{className:D,"aria-describedby":void 0,children:[P,I,V]})]}),t[52]=P,t[53]=I,t[54]=V,t[55]=H):H=t[55];let ie;return t[56]!==n||t[57]!==w||t[58]!==H?(ie=(0,Z.jsx)(b,{open:n,onOpenChange:w,children:H}),t[56]=n,t[57]=w,t[58]=H,t[59]=ie):ie=t[59],ie}function ct(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ot(e.content)})]},`${e.timestamp??``}-${e.role}-${ot(e.content).slice(0,24)}`)}var lt=20;function ut(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var dt=new Set([`all`,`active`,`pinned`,`archived`]),ft=new Set([`grid`,`list`]),pt=[`sessions`,`settings`];function mt(e){return e&&pt.includes(e)?e:`sessions`}function ht(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function gt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function _t(e){let t=(0,De.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=pt.map(e=>({id:e,label:ht(n,e),icon:e===`sessions`?j:k})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(Te,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function vt(e){let t=(0,De.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ht(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:gt(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function yt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:dt.has(t)?t:`all`,viewMode:ft.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function bt(){let e=h(p(e=>e.language)),t=e.sessions,n=f(e=>e.conversationId),r=!!n,{data:a,mutate:o}=te(r?[`gateway-chat-agents`,n]:null,se,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,c=a?.items??[],[l,d]=i(),m=mt(l.get(`tab`)),_=(0,X.useCallback)(e=>{let t=new URLSearchParams(l);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),d(t,{replace:!0})},[l,d]),[S,C]=(0,X.useReducer)(le,l,yt),{searchInput:w,debouncedSearch:E,statusFilter:D,viewMode:O,channelFilter:k,sessions:M,loading:re,error:N,hasMore:P,stats:R,detailOpen:z,detailLoading:ae,detailSession:W,confirmOpen:oe,confirmKey:G}=S;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=w.trim();E!==e&&C({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[w,E]);let ce=l.toString(),ue=(0,X.useRef)(ce);if(ue.current!==ce){ue.current=ce;let e=l.get(`q`)??``,t=l.get(`status`),n=l.get(`view`),r=(l.get(`channel`)??``).trim(),i=dt.has(t)?t:`all`,a=ft.has(n)?n:`grid`,o=e.trim();C({type:`patch`,patch:{...w===e?{}:{searchInput:e},...E===o?{}:{debouncedSearch:o},...D===i?{}:{statusFilter:i},...O===a?{}:{viewMode:a},...k===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(l),t=E.trim();t?e.set(`q`,t):e.delete(`q`),D===`all`?e.delete(`status`):e.set(`status`,D),O===`grid`?e.delete(`view`):e.set(`view`,O),k?e.set(`channel`,k):e.delete(`channel`),e.toString()!==l.toString()&&d(e,{replace:!0})},[E,l,d,D,O,k]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=!1;return(async()=>{C({type:`patch`,patch:{loading:!0,error:null}});try{let t=await ge({limit:lt,offset:0,...E?{search:E}:{},...D===`all`?{}:{status:D},...k?{channel:k}:{}});if(e)return;C({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||C({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||C({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,m,E,D,k,t.loadError]),(0,X.useEffect)(()=>{!r||m!==`sessions`||U().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,m]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,m,o]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||C({type:`patch`,patch:{sessions:M.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:W&&W.key===t.key?{...W,name:t.name}:W}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,m,M,W]);let me=(0,X.useCallback)(async()=>{if(!(!r||re||!P)){C({type:`patch`,patch:{loading:!0,error:null}});try{let e=await ge({limit:lt,offset:M.length,...E?{search:E}:{},...D===`all`?{}:{status:D},...k?{channel:k}:{}});C({type:`patch`,patch:{sessions:[...M,...e.items],hasMore:e.hasMore}})}catch(e){C({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{C({type:`patch`,patch:{loading:!1}})}}},[r,re,P,M.length,E,D,k,t.loadError]),K=(0,X.useCallback)((e,t)=>{C({type:`patch`,patch:{sessions:M.map(n=>n.key===e?{...n,status:t}:n),detailSession:W&&W.key===e?{...W,status:t}:W}})},[M,W]),Ce=(0,X.useCallback)(async e=>{C({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{C({type:`patch`,patch:{detailSession:await de(e)}})}catch{C({type:`patch`,patch:{detailOpen:!1}})}finally{C({type:`patch`,patch:{detailLoading:!1}})}},[]),J=e=>{Ce(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){C({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await he(e),K(e,`archived`);break;case`unarchive`:await ve(e),K(e,`active`);break;case`pin`:await be(e),K(e,`pinned`);break;case`unpin`:await B(e),K(e,`active`);break;case`export`:{let t=await fe(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}U().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await pe(e),C({type:`patch`,patch:{sessions:M.filter(t=>t.key!==e),detailSession:W?.key===e?null:W,...W?.key===e?{detailOpen:!1}:{}}}),U().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Ee={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},De=[{key:`all`,label:t.filterAll,icon:j},{key:`active`,label:t.filterActive,icon:ye},{key:`pinned`,label:t.filterPinned,icon:H},{key:`archived`,label:t.filterArchived,icon:ie}],Oe=(()=>{let e=Object.entries(R?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(Se,{gap:`gap-6`,children:[(0,Z.jsx)(xe,{title:t.title}),(0,Z.jsx)(_t,{s:t,activeTab:m,onChange:_}),(0,Z.jsx)(vt,{s:t,id:`settings`,activeTab:m,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Qe,{hasToken:r}),(0,Z.jsx)(at,{hasToken:r})]})}),(0,Z.jsxs)(vt,{s:t,id:`sessions`,activeTab:m,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:De.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":D===e,onClick:()=>C({type:`patch`,patch:{statusFilter:e}}),className:u(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,D===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(A,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:w,onChange:e=>C({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":E||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!k,onClick:()=>C({type:`patch`,patch:{channelFilter:``}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,k?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Oe.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":k===e,onClick:()=>C({type:`patch`,patch:{channelFilter:e}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,k===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,R?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:R.byChannel[e]})]},e))]}),R?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[R.totalSessions,t.totalSessions],[R.activeSessions,t.activeSessions],[R.pinnedSessions,t.pinnedSessions],[R.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,N?(0,Z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:N}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ut(t.sessionCount,{count:M.length})}),(0,Z.jsxs)(`div`,{className:L,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(x,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":O===`grid`,onClick:()=>C({type:`patch`,patch:{viewMode:`grid`}}),className:u(I,`size-7 p-0`,O===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,O===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(V,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(x,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":O===`list`,onClick:()=>C({type:`patch`,patch:{viewMode:`list`}}),className:u(I,`size-9 p-0`,O===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,O===`list`&&`text-accent-fg`),children:(0,Z.jsx)(_e,{className:`size-3.5`,strokeWidth:1.5})})]})]}),re&&M.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):M.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(F,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(x,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:u(`grid min-w-0 gap-3`,O===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":E||void 0,children:M.map(e=>{let t=Fe(e,s);return(0,Z.jsx)(Ae,{session:e,variant:O,labels:Te,sessionAgentId:t,sessionAgentAvatar:Ie(t,c),onOpen:()=>J(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),P?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(x,{type:`button`,variant:`secondary`,disabled:re,onClick:()=>void me(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(st,{open:z,loading:ae,session:W,sessionAgentId:W?Fe(W,s):void 0,sessionAgentAvatar:W?Ie(Fe(W,s),c):void 0,labels:Ee,onClose:()=>{C({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>W&&void Y(W.key,`archive`),onUnarchive:()=>W&&void Y(W.key,`unarchive`),onPin:()=>W&&void Y(W.key,`pin`),onUnpin:()=>W&&void Y(W.key,`unpin`),onExport:()=>W&&void Y(W.key,`export`),onDelete:()=>W&&C({type:`patch`,patch:{confirmKey:W.key,confirmOpen:!0}})}),(0,Z.jsx)(b,{open:oe,onOpenChange:e=>C({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(v,{children:[(0,Z.jsx)(g,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,T)}),(0,Z.jsxs)(y,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,ne),children:[(0,Z.jsx)(ee,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:G?ut(t.deleteSessionMessage,{name:M.find(e=>e.key===G)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>C({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(x,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{G&&we(G),C({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{bt as SessionsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as a,r as o}from"./popover-select-9i-ZtHXL.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-JdwAhgNB.js";import{a as d,c as f,n as p,r as m}from"./locale-store-DPZ79W1-.js";import{t as h}from"./messages-BiYTyLJr.js";import{a as g,n as _,o as v,r as y,s as ee,t as b}from"./dist-BGTk37IG.js";import{i as te}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-CS04eWY9.js";import{n as S,r as C}from"./gateway-config-swr-xAOGtenO.js";import{t as w}from"./skeleton-BwbyijEw.js";import{i as ne,o as T}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as E,t as D}from"./registry-api-B_e_nZSN.js";import{$i as O,Cc as k,Dc as A,Dl as j,Eo as M,F as re,Gs as N,Hc as P,Jl as F,Nt as I,Pt as L,Qi as R,Qu as z,Sa as B,Tl as V,Uc as H,Zu as ie,_a as U,ai as ae,al as W,bs as oe,ca as se,cu as G,da as ce,ea as le,fa as ue,ga as de,ha as fe,ma as pe,nc as me,pa as he,rl as K,va as ge,wl as _e,xa as ve,xs as q,xu as ye,ya as be}from"./index-DJo4DimT.js";import{n as xe,r as Se}from"./settings-page-layout-X1x-2Cp9.js";import{n as Ce,t as J}from"./settings-form-section-B0veRBZs.js";import{n as Y,t as we}from"./use-autosave-DDY9qoXZ.js";import{t as Te}from"./page-tabs-ChQ4jJFs.js";import{t as Ee}from"./settings-advanced-gate-C1SM5B93.js";var X=e(t(),1),De=n(),Z=r();function Oe(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function ke(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ae(e){let t=(0,De.c)(113),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,d;t[0]!==i.unnamedSession||t[1]!==n.name?(d=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=d):d=t[2];let f=d,m=p(Pe),g;t[3]!==m||t[4]!==n?(g=ue(n,h(m).sidebar.sessionFilters),t[3]=m,t[4]=n,t[5]=g):g=t[5];let _=g,v;t[6]===n.name?v=t[7]:(v=n.name?.trim(),t[6]=n.name,t[7]=v);let y=!!v,ee=n.status===`archived`,b=n.status===`pinned`,te=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,x;t[8]===te?x=t[9]:(x=u(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,te),t[8]=te,t[9]=x);let S;t[10]===c?S=t[11]:(S=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[10]=c,t[11]=S);let C=r===`list`&&`sm:py-3`,w;t[12]===C?w=t[13]:(w=u(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,C),t[12]=C,t[13]=w);let ne;t[14]===n?ne=t[15]:(ne=(0,Z.jsx)(ce,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[14]=n,t[15]=ne);let T;t[16]===_?T=t[17]:(T=(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:_}),t[16]=_,t[17]=T);let E;t[18]!==T||t[19]!==ne?(E=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[ne,T]}),t[18]=T,t[19]=ne,t[20]=E):E=t[20];let D;t[21]===b?D=t[22]:(D=b?(0,Z.jsx)(H,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[21]=b,t[22]=D);let O;t[23]===n.updatedAt?O=t[24]:(O=Oe(n.updatedAt),t[23]=n.updatedAt,t[24]=O);let k;t[25]===O?k=t[26]:(k=(0,Z.jsx)(`span`,{children:O}),t[25]=O,t[26]=k);let A;t[27]!==D||t[28]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[D,k]}),t[27]=D,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==E||t[31]!==A||t[32]!==w?(j=(0,Z.jsxs)(`div`,{className:w,children:[E,A]}),t[30]=E,t[31]=A,t[32]=w,t[33]=j):j=t[33];let M=r===`list`&&`sm:py-3`,F;t[34]===M?F=t[35]:(F=u(`min-w-0 flex-1 px-3 py-2`,M),t[34]=M,t[35]=F);let I=r===`list`&&`sm:items-start`,L;t[36]===I?L=t[37]:(L=u(`flex gap-3`,I),t[36]=I,t[37]=L);let R;t[38]!==o||t[39]!==a?(R=(0,Z.jsx)(re,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[38]=o,t[39]=a,t[40]=R):R=t[40];let B;t[41]===f?B=t[42]:(B=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[41]=f,t[42]=B);let V;t[43]!==n.key||t[44]!==y?(V=y?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[43]=n.key,t[44]=y,t[45]=V):V=t[45];let U;t[46]!==B||t[47]!==V?(U=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[B,V]}),t[46]=B,t[47]=V,t[48]=U):U=t[48];let ae;t[49]!==L||t[50]!==R||t[51]!==U?(ae=(0,Z.jsxs)(`div`,{className:L,children:[R,U]}),t[49]=L,t[50]=R,t[51]=U,t[52]=ae):ae=t[52];let se;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(W,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[53]=se):se=t[53];let G;t[54]===n.messageCount?G=t[55]:(G=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[se,n.messageCount]}),t[54]=n.messageCount,t[55]=G);let le;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(N,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[56]=le):le=t[56];let de;t[57]===n.estimatedTokens?de=t[58]:(de=ke(n.estimatedTokens),t[57]=n.estimatedTokens,t[58]=de);let fe;t[59]===de?fe=t[60]:(fe=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[le,de]}),t[59]=de,t[60]=fe);let pe;t[61]!==G||t[62]!==fe?(pe=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[G,fe]}),t[61]=G,t[62]=fe,t[63]=pe):pe=t[63];let he;t[64]===n.tags?he=t[65]:(he=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Ne),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[64]=n.tags,t[65]=he);let K;t[66]!==F||t[67]!==ae||t[68]!==pe||t[69]!==he?(K=(0,Z.jsxs)(`div`,{className:F,children:[ae,pe,he]}),t[66]=F,t[67]=ae,t[68]=pe,t[69]=he,t[70]=K):K=t[70];let ge;t[71]===l?ge=t[72]:(ge=()=>l(`continue`),t[71]=l,t[72]=ge);let _e;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(W,{className:`size-4`,strokeWidth:1.75}),t[73]=_e):_e=t[73];let ve;t[74]!==i.continueChat||t[75]!==ge?(ve=(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.continueChat,"aria-label":i.continueChat,onClick:ge,children:_e}),t[74]=i.continueChat,t[75]=ge,t[76]=ve):ve=t[76];let q;t[77]!==ee||t[78]!==i.archive||t[79]!==i.unarchive||t[80]!==l?(q=ee?(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(z,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75})}),t[77]=ee,t[78]=i.archive,t[79]=i.unarchive,t[80]=l,t[81]=q):q=t[81];let ye;t[82]!==b||t[83]!==i.pin||t[84]!==i.unpin||t[85]!==l?(ye=b?(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(P,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(H,{className:`size-4`,strokeWidth:1.75})}),t[82]=b,t[83]=i.pin,t[84]=i.unpin,t[85]=l,t[86]=ye):ye=t[86];let be;t[87]===l?be=t[88]:(be=()=>l(`export`),t[87]=l,t[88]=be);let xe;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[89]=xe):xe=t[89];let Se;t[90]!==i.export||t[91]!==be?(Se=(0,Z.jsx)(`button`,{type:`button`,className:oe,title:i.export,"aria-label":i.export,onClick:be,children:xe}),t[90]=i.export,t[91]=be,t[92]=Se):Se=t[92];let Ce;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=u(oe,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[93]=Ce):Ce=t[93];let J;t[94]===l?J=t[95]:(J=()=>l(`delete`),t[94]=l,t[95]=J);let Y;t[96]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Z.jsx)(me,{className:`size-4`,strokeWidth:1.75}),t[96]=Y):Y=t[96];let we;t[97]!==i.delete||t[98]!==J?(we=(0,Z.jsx)(`button`,{type:`button`,className:Ce,title:i.delete,"aria-label":i.delete,onClick:J,children:Y}),t[97]=i.delete,t[98]=J,t[99]=we):we=t[99];let Te;t[100]!==ve||t[101]!==q||t[102]!==ye||t[103]!==Se||t[104]!==we?(Te=(0,Z.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Me,onKeyDown:je,children:[ve,q,ye,Se,we]}),t[100]=ve,t[101]=q,t[102]=ye,t[103]=Se,t[104]=we,t[105]=Te):Te=t[105];let Ee;return t[106]!==c||t[107]!==j||t[108]!==K||t[109]!==Te||t[110]!==x||t[111]!==S?(Ee=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:x,onClick:c,onKeyDown:S,children:[j,K,Te]}),t[106]=c,t[107]=j,t[108]=K,t[109]=Te,t[110]=x,t[111]=S,t[112]=Ee):Ee=t[112],Ee}function je(e){return e.stopPropagation()}function Me(e){return e.stopPropagation()}function Ne(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Pe(e){return e.language}function Fe(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Ie(e,t){return t.find(t=>t.id===e)?.avatar}var Le={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ze(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Be(e){let t=Re(e)?e:{},n=Re(t.userContext)?t.userContext:{},r=Re(n.contextPlanning)?n.contextPlanning:{},i=Re(r.compaction)?r.compaction:{},a=Le,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:ze(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ve(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function He(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function Ue(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify(He(e))}),await S()}var We=128e3,Ge={balanced:Le,preserve:{...Le,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Le,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ke=R();function qe(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,M,`dark:border-edge`)}function Je(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function Ye(e){let t=Je(e);for(let[e,n]of Object.entries(Ge))if(t===Je(n))return e;return`custom`}function Xe(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,De.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=qe(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ze(e){let t=(0,De.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=u(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[d,m]}),t[15]=c,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function Qe({hasToken:e}){let t=h(p(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=C(e),{data:i=[],isLoading:a}=te(e?D:null,E,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Be(n.payload.config),[n]),[s,d]=(0,X.useReducer)(Ke,{form:null,baseline:null}),[f,m]=(0,X.useState)(``),g=(0,X.useRef)(!1),_=(0,X.useRef)(s.form);_.current=s.form;let v=(0,X.useRef)(null);O({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:v,dispatch:d,onResetDirty:()=>{g.current=!1}});let y=s.form,ee=s.baseline,b=!!(y&&ee&&JSON.stringify(y)!==JSON.stringify(ee)),S=(0,X.useCallback)(e=>{g.current=!0,d({type:`patch`,patch:e})},[]),ne=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),T=we({value:y,dirty:b,onSave:(0,X.useCallback)(async e=>{try{await Ue(e),d({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ve(e);return n?t.invalidValue.replace(`{{field}}`,ne(n)):null}});if(!e||!y)return r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(w,{className:`h-5 w-48`}),(0,Z.jsx)(w,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(w,{className:`h-36 w-full rounded-xl`})]})}):null;let k=Ye(y),A=Math.max(0,We-y.reserveTokens),j=Math.min(Math.floor(We*y.triggerThreshold),A),M=Math.min(100,j/We*100),re=Math.min(100,A/We*100),N=y.model?i.find(e=>e.id===y.model):void 0,P=N?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>N.contextWindow,F=y.keepRecentTokens+y.reserveTokens>j,I=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),L=e=>{let t=Ge[e];S({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},R={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},z=()=>{let e=f.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(S({postCompactionSections:[...y.postCompactionSections,e]}),m(``))};return(0,Z.jsxs)(J,{onBlurCapture:T.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:K,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Y,{status:T.status,error:T.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>S({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),T.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:T.error}):null,y.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!y.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),k===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":k===e,className:u(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,q.transition,q.focusRingPanel,k===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>L(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:R[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:R[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Xe(j)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${M}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Xe(A)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${re}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>S({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Xe(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>S({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>S({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Xe(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>S({keepRecentTokens:Math.floor(e)})})]}),F?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(ae,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>S({model:e})}),y.model?(0,Z.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>S({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ze,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>S({qualityGuard:e})}),(0,Z.jsx)(Ze,{label:t.gapAudit,hint:t.gapAuditHint,checked:y.gapAudit,onChange:e=>S({gapAudit:e})})]}),y.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(Ee,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:y.minMessagesBeforeCompact,min:2,onChange:e=>S({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>S({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>S({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>S({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(I)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>S({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>S({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>S({minToolResultKeepChars:Math.floor(e)})})]}),P?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),y.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:u(`text-fg-muted hover:text-fg`,q.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>S({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(l,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:qe(),value:f,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())}}),(0,Z.jsxs)(x,{type:`button`,variant:`secondary`,disabled:!f.trim()||y.postCompactionSections.length>=12,onClick:z,children:[(0,Z.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function $e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function et(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function tt(e){let t=$e(e)?e:{},n=$e(t.session)?t.session:{},r=$e(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:et(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function nt(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),S()}function rt(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,M,`dark:border-edge`)}var it=R();function at({hasToken:e}){let t=h(p(e=>e.language)).sessions.config,{data:n,isLoading:r}=C(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:tt(n.payload.config),[n]),[s,c]=(0,X.useReducer)(it,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),f=(0,X.useRef)(l);f.current=l;let m=(0,X.useRef)(null);O({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:m,dispatch:c,onResetDirty:()=>{d.current=!1}});let g=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),_=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=we({value:l,dirty:g,onSave:(0,X.useCallback)(async e=>{try{await nt(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(w,{className:`h-5 w-40`}),(0,Z.jsx)(w,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(J,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:G,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(Y,{status:v.status,error:v.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(a,{className:rt(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Z.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:rt(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:rt(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function ot(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function st(e){let t=(0,De.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:d,onUnarchive:f,onPin:p,onUnpin:m,onExport:h,onDelete:te}=e,S=i?.status===`archived`,C=i?.status===`pinned`,w;t[0]===c?w=t[1]:(w=e=>!e&&c(),t[0]=c,t[1]=w);let E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(g,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,T)}),t[2]=E):E=t[2];let D;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D=u(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,ne,`dark:border-edge`),t[3]=D):D=t[3];let O;t[4]!==i||t[5]!==o||t[6]!==a?(O=i&&a?(0,Z.jsx)(re,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=O):O=t[7];let k;t[8]!==s.unnamedSession||t[9]!==i?.name?(k=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=k):k=t[10];let A;t[11]===k?A=t[12]:(A=(0,Z.jsx)(ee,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:k}),t[11]=k,t[12]=A);let j;t[13]!==O||t[14]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[O,A]}),t[13]=O,t[14]=A,t[15]=j):j=t[15];let M;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(l,{className:`size-5`,strokeWidth:1.75}),t[16]=M):M=t[16];let N;t[17]===s.close?N=t[18]:(N=(0,Z.jsx)(_,{asChild:!0,children:(0,Z.jsx)(x,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:M})}),t[17]=s.close,t[18]=N);let P;t[19]!==j||t[20]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[j,N]}),t[19]=j,t[20]=N,t[21]=P):P=t[21];let F;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(F=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(ct)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=F):F=t[26];let I;t[27]===F?I=t[28]:(I=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:F}),t[27]=F,t[28]=I);let L;t[29]!==s.detailExport||t[30]!==h?(L=(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.detailExport}),t[29]=s.detailExport,t[30]=h,t[31]=L):L=t[31];let R;t[32]!==S||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==d||t[36]!==f?(R=S?(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unarchive}):(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.archive}),t[32]=S,t[33]=s.archive,t[34]=s.unarchive,t[35]=d,t[36]=f,t[37]=R):R=t[37];let z;t[38]!==C||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==p||t[42]!==m?(z=C?(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.unpin}):(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.pin}),t[38]=C,t[39]=s.pin,t[40]=s.unpin,t[41]=p,t[42]=m,t[43]=z):z=t[43];let B;t[44]!==s.delete||t[45]!==te?(B=(0,Z.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:te,children:s.delete}),t[44]=s.delete,t[45]=te,t[46]=B):B=t[46];let V;t[47]!==L||t[48]!==R||t[49]!==z||t[50]!==B?(V=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[L,R,z,B]})}),t[47]=L,t[48]=R,t[49]=z,t[50]=B,t[51]=V):V=t[51];let H;t[52]!==P||t[53]!==I||t[54]!==V?(H=(0,Z.jsxs)(v,{children:[E,(0,Z.jsxs)(y,{className:D,"aria-describedby":void 0,children:[P,I,V]})]}),t[52]=P,t[53]=I,t[54]=V,t[55]=H):H=t[55];let ie;return t[56]!==n||t[57]!==w||t[58]!==H?(ie=(0,Z.jsx)(b,{open:n,onOpenChange:w,children:H}),t[56]=n,t[57]=w,t[58]=H,t[59]=ie):ie=t[59],ie}function ct(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ot(e.content)})]},`${e.timestamp??``}-${e.role}-${ot(e.content).slice(0,24)}`)}var lt=20;function ut(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var dt=new Set([`all`,`active`,`pinned`,`archived`]),ft=new Set([`grid`,`list`]),pt=[`sessions`,`settings`];function mt(e){return e&&pt.includes(e)?e:`sessions`}function ht(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function gt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function _t(e){let t=(0,De.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=pt.map(e=>({id:e,label:ht(n,e),icon:e===`sessions`?j:k})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(Te,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function vt(e){let t=(0,De.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ht(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:gt(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function yt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:dt.has(t)?t:`all`,viewMode:ft.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function bt(){let e=h(p(e=>e.language)),t=e.sessions,n=f(e=>e.conversationId),r=!!n,{data:a,mutate:o}=te(r?[`gateway-chat-agents`,n]:null,se,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,c=a?.items??[],[l,d]=i(),m=mt(l.get(`tab`)),_=(0,X.useCallback)(e=>{let t=new URLSearchParams(l);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),d(t,{replace:!0})},[l,d]),[S,C]=(0,X.useReducer)(le,l,yt),{searchInput:w,debouncedSearch:E,statusFilter:D,viewMode:O,channelFilter:k,sessions:M,loading:re,error:N,hasMore:P,stats:R,detailOpen:z,detailLoading:ae,detailSession:W,confirmOpen:oe,confirmKey:G}=S;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=w.trim();E!==e&&C({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[w,E]);let ce=l.toString(),ue=(0,X.useRef)(ce);if(ue.current!==ce){ue.current=ce;let e=l.get(`q`)??``,t=l.get(`status`),n=l.get(`view`),r=(l.get(`channel`)??``).trim(),i=dt.has(t)?t:`all`,a=ft.has(n)?n:`grid`,o=e.trim();C({type:`patch`,patch:{...w===e?{}:{searchInput:e},...E===o?{}:{debouncedSearch:o},...D===i?{}:{statusFilter:i},...O===a?{}:{viewMode:a},...k===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(l),t=E.trim();t?e.set(`q`,t):e.delete(`q`),D===`all`?e.delete(`status`):e.set(`status`,D),O===`grid`?e.delete(`view`):e.set(`view`,O),k?e.set(`channel`,k):e.delete(`channel`),e.toString()!==l.toString()&&d(e,{replace:!0})},[E,l,d,D,O,k]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=!1;return(async()=>{C({type:`patch`,patch:{loading:!0,error:null}});try{let t=await ge({limit:lt,offset:0,...E?{search:E}:{},...D===`all`?{}:{status:D},...k?{channel:k}:{}});if(e)return;C({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||C({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||C({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,m,E,D,k,t.loadError]),(0,X.useEffect)(()=>{!r||m!==`sessions`||U().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,m]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,m,o]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||C({type:`patch`,patch:{sessions:M.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:W&&W.key===t.key?{...W,name:t.name}:W}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,m,M,W]);let me=(0,X.useCallback)(async()=>{if(!(!r||re||!P)){C({type:`patch`,patch:{loading:!0,error:null}});try{let e=await ge({limit:lt,offset:M.length,...E?{search:E}:{},...D===`all`?{}:{status:D},...k?{channel:k}:{}});C({type:`patch`,patch:{sessions:[...M,...e.items],hasMore:e.hasMore}})}catch(e){C({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{C({type:`patch`,patch:{loading:!1}})}}},[r,re,P,M.length,E,D,k,t.loadError]),K=(0,X.useCallback)((e,t)=>{C({type:`patch`,patch:{sessions:M.map(n=>n.key===e?{...n,status:t}:n),detailSession:W&&W.key===e?{...W,status:t}:W}})},[M,W]),Ce=(0,X.useCallback)(async e=>{C({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{C({type:`patch`,patch:{detailSession:await de(e)}})}catch{C({type:`patch`,patch:{detailOpen:!1}})}finally{C({type:`patch`,patch:{detailLoading:!1}})}},[]),J=e=>{Ce(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){C({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await he(e),K(e,`archived`);break;case`unarchive`:await ve(e),K(e,`active`);break;case`pin`:await be(e),K(e,`pinned`);break;case`unpin`:await B(e),K(e,`active`);break;case`export`:{let t=await fe(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}U().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await pe(e),C({type:`patch`,patch:{sessions:M.filter(t=>t.key!==e),detailSession:W?.key===e?null:W,...W?.key===e?{detailOpen:!1}:{}}}),U().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Ee={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},De=[{key:`all`,label:t.filterAll,icon:j},{key:`active`,label:t.filterActive,icon:ye},{key:`pinned`,label:t.filterPinned,icon:H},{key:`archived`,label:t.filterArchived,icon:ie}],Oe=(()=>{let e=Object.entries(R?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(Se,{gap:`gap-6`,children:[(0,Z.jsx)(xe,{title:t.title}),(0,Z.jsx)(_t,{s:t,activeTab:m,onChange:_}),(0,Z.jsx)(vt,{s:t,id:`settings`,activeTab:m,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Qe,{hasToken:r}),(0,Z.jsx)(at,{hasToken:r})]})}),(0,Z.jsxs)(vt,{s:t,id:`sessions`,activeTab:m,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:De.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":D===e,onClick:()=>C({type:`patch`,patch:{statusFilter:e}}),className:u(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,D===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(A,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:w,onChange:e=>C({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":E||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!k,onClick:()=>C({type:`patch`,patch:{channelFilter:``}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,k?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Oe.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":k===e,onClick:()=>C({type:`patch`,patch:{channelFilter:e}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,k===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,R?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:R.byChannel[e]})]},e))]}),R?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[R.totalSessions,t.totalSessions],[R.activeSessions,t.activeSessions],[R.pinnedSessions,t.pinnedSessions],[R.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,N?(0,Z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:N}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ut(t.sessionCount,{count:M.length})}),(0,Z.jsxs)(`div`,{className:L,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(x,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":O===`grid`,onClick:()=>C({type:`patch`,patch:{viewMode:`grid`}}),className:u(I,`size-7 p-0`,O===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,O===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(V,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(x,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":O===`list`,onClick:()=>C({type:`patch`,patch:{viewMode:`list`}}),className:u(I,`size-9 p-0`,O===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,O===`list`&&`text-accent-fg`),children:(0,Z.jsx)(_e,{className:`size-3.5`,strokeWidth:1.5})})]})]}),re&&M.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):M.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(F,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(x,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:u(`grid min-w-0 gap-3`,O===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":E||void 0,children:M.map(e=>{let t=Fe(e,s);return(0,Z.jsx)(Ae,{session:e,variant:O,labels:Te,sessionAgentId:t,sessionAgentAvatar:Ie(t,c),onOpen:()=>J(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),P?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(x,{type:`button`,variant:`secondary`,disabled:re,onClick:()=>void me(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(st,{open:z,loading:ae,session:W,sessionAgentId:W?Fe(W,s):void 0,sessionAgentAvatar:W?Ie(Fe(W,s),c):void 0,labels:Ee,onClose:()=>{C({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>W&&void Y(W.key,`archive`),onUnarchive:()=>W&&void Y(W.key,`unarchive`),onPin:()=>W&&void Y(W.key,`pin`),onUnpin:()=>W&&void Y(W.key,`unpin`),onExport:()=>W&&void Y(W.key,`export`),onDelete:()=>W&&C({type:`patch`,patch:{confirmKey:W.key,confirmOpen:!0}})}),(0,Z.jsx)(b,{open:oe,onOpenChange:e=>C({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(v,{children:[(0,Z.jsx)(g,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,T)}),(0,Z.jsxs)(y,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,ne),children:[(0,Z.jsx)(ee,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:G?ut(t.deleteSessionMessage,{name:M.find(e=>e.key===G)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>C({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(x,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{G&&we(G),C({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{bt as SessionsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fn as e}from"./index-DJo4DimT.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Wc as r,xs as i}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Wc as r,xs as i}from"./index-DJo4DimT.js";var a=e();function o(){return`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(7),{children:r,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=n(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==r||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}var l=`mt-0.5 flex size-7 shrink-0 items-center justify-center text-fg-muted transition-colors`;function u(e){let t=(0,a.c)(27),{icon:o,title:c,subtitle:u,trailing:d,titleAccessory:f,className:p,iconInteractive:m,iconLeading:h}=e,g;t[0]===o?g=t[1]:(g=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=g);let _=h??g,v,y;if(t[2]!==p||t[3]!==m||t[4]!==h||t[5]!==_){let e=h?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press),a=!!(m&&h);t[8]===p?v=t[9]:(v=n(`mb-4 flex items-start gap-2.5`,p),t[8]=p,t[9]=v),y=m?a?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:n(`touch-target`,e),children:_}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(r,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:n(`touch-target`,e),children:_}):(0,s.jsx)(`div`,{className:n(h?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!h,children:_}),t[2]=p,t[3]=m,t[4]=h,t[5]=_,t[6]=v,t[7]=y}else v=t[6],y=t[7];let b;t[10]===c?b=t[11]:(b=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[10]=c,t[11]=b);let x;t[12]!==b||t[13]!==f?(x=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[b,f]}),t[12]=b,t[13]=f,t[14]=x):x=t[14];let S;t[15]===u?S=t[16]:(S=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[15]=u,t[16]=S);let C;t[17]!==x||t[18]!==S?(C=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S]}),t[17]=x,t[18]=S,t[19]=C):C=t[19];let w;t[20]===d?w=t[21]:(w=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[20]=d,t[21]=w);let T;return t[22]!==v||t[23]!==y||t[24]!==C||t[25]!==w?(T=(0,s.jsxs)(`div`,{className:v,children:[y,C,w]}),t[22]=v,t[23]=y,t[24]=C,t[25]=w,t[26]=T):T=t[26],T}export{u as n,o as r,c as t};
|
package/dist/gateway/static/root/assets/{settings-page-DiIyMQ52.js → settings-page-CxRWyWYe.js}
RENAMED
|
@@ -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{p as i,r as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as o}from"./locale-store-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i,r as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as o}from"./locale-store-DPZ79W1-.js";import{t as s}from"./messages-BiYTyLJr.js";import{$a as c,Qa as l,Xa as u,Za as d,ao as f,co as p,eo as m,io as h,no as g,oo as _,ro as v,so as y,to as b}from"./index-DJo4DimT.js";var x=n(),S=e(t(),1),C=r(),w=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`agent-defaults`,`gateway`,`runtimes`,`devices`,`heartbeat`,`remote-access`,`shares`],T=(0,S.lazy)(()=>_().then(e=>({default:e.SetupStatusPanel}))),E=(0,S.lazy)(()=>l().then(e=>({default:e.AppearanceSettingsPanel}))),D=(0,S.lazy)(()=>v().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),O=(0,S.lazy)(()=>p().then(e=>({default:e.SystemSettingsPanel}))),k=(0,S.lazy)(()=>c().then(e=>({default:e.DesktopPetSettings}))),A=(0,S.lazy)(()=>d().then(e=>({default:e.AppManagementSettingsPanel}))),j=(0,S.lazy)(()=>b().then(e=>({default:e.GatewaySettingsPanel}))),M=(0,S.lazy)(()=>f().then(e=>({default:e.RuntimeToolsSettingsPanel}))),N=(0,S.lazy)(()=>g().then(e=>({default:e.HeartbeatSettingsPanel}))),P=(0,S.lazy)(()=>h().then(e=>({default:e.RemoteAccessHub}))),F=(0,S.lazy)(()=>y().then(e=>({default:e.SharesSettingsPanel}))),I=(0,S.lazy)(()=>u().then(e=>({default:e.AgentDefaultsSettingsPanel}))),L=(0,S.lazy)(()=>m().then(e=>({default:e.EndpointToolsManagementSettings})));function R(){let e=(0,x.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,C.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function z(e){return(0,C.jsx)(S.Suspense,{fallback:(0,C.jsx)(R,{}),children:(0,C.jsx)(e,{})})}function B(){let e=(0,x.c)(28),{section:t}=i(),n=o(V),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=s(n);if(!t||!w.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let o=t;if(o===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(T),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[o];if(o===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(E),e[9]=t):t=e[9],d=t;break bb0}if(o===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(D),e[10]=t):t=e[10],d=t;break bb0}if(o===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(O),e[11]=t):t=e[11],d=t;break bb0}if(o===`desktop-pet`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(k),e[12]=t):t=e[12],d=t;break bb0}if(o===`desktop-app`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(A),e[13]=t):t=e[13],d=t;break bb0}if(o===`agent-defaults`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(I),e[14]=t):t=e[14],d=t;break bb0}if(o===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(j),e[15]=t):t=e[15],d=t;break bb0}if(o===`runtimes`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(M),e[16]=t):t=e[16],d=t;break bb0}if(o===`devices`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(L),e[17]=t):t=e[17],d=t;break bb0}if(o===`heartbeat`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(N),e[18]=t):t=e[18],d=t;break bb0}if(o===`remote-access`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(P),e[19]=t):t=e[19],d=t;break bb0}if(o===`shares`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(F),e[20]=t):t=e[20],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,C.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[21]!==r||e[22]!==c?(f=(0,C.jsx)(`p`,{className:r,children:c}),e[21]=r,e[22]=c,e[23]=f):f=e[23];let p;return e[24]!==l||e[25]!==u||e[26]!==f?(p=(0,C.jsxs)(`div`,{className:l,children:[u,f]}),e[24]=l,e[25]=u,e[26]=f,e[27]=p):p=e[27],p}function V(e){return e.language}export{B as SettingsPage};
|
|
@@ -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{t as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./cn-JdwAhgNB.js";import{a as c,c as l,n as u,r as d}from"./locale-store-msTfRK8P.js";import{t as f}from"./messages-F74LVAiU.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-B6wHa6ZI.js";import{n as h}from"./electron-env-Dit0bHgy.js";import{n as g}from"./gateway-realtime-store-BLDgrJ30.js";import{n as _,t as v}from"./registry-api-BSWtko7U.js";import{$u as y,Au as b,Mc as x,Ml as S,Su as C,Tt as w,li as T,tc as E,uc as D,xo as O,xs as ee,xu as k}from"./index-CDfcPiPb.js";import{n as A,r as j}from"./settings-page-layout-X1x-2Cp9.js";import{n as M,t as N}from"./settings-form-section-C0JDGN_V.js";import{n as P}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as F}from"./settings-advanced-gate-BG0kl4HT.js";var I=e(t(),1),L=n();function R(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&O(e)).length}function z(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function B(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function te(e){if(!e||typeof e!=`object`)return{enabled:!1,driverKind:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,driverKind:`extension`};let n=t,r=n.driver&&typeof n.driver==`object`&&!Array.isArray(n.driver)?n.driver:void 0;return{enabled:n.enabled===!0,driverKind:typeof r?.kind==`string`&&r.kind.trim()?r.kind.trim():`extension`}}function V(e){return e?`pass`:`fail`}function H(e){if(e===`tool-runtimes`)return`/settings/runtimes`;if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function U(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function W(e,t){let n=e.match(/^Run(?::|\s)(.*)$/i);if(n?.[1])return t.runCommand(n[1].trim());let r=e.match(/^Install(?::|\s)(.*)$/i);if(r?.[1])return t.installCommand(r[1].trim());let i=e.match(/^Start(?::|\s)(.*)$/i);return i?.[1]?t.startCommand(i[1].trim()):e}function G(e,t){if(!t)return e;let n=e.message;if(e.id===`tool-runtimes`){let r=e.message.match(/^(.*) runtime is not installed\.$/),i=e.message.match(/^(.*) runtime installation is invalid\.$/);r?.[1]?n=t.runtimeMissing(r[1]):i?.[1]&&(n=t.runtimeInvalid(i[1]))}else if(e.id===`gateway-service`)if(e.message===`Gateway is not installed as a system service.`)n=t.gatewayNotInstalled;else{let r=e.message.match(/^Service backend unavailable: (.*)$/),i=e.message.match(/^Gateway service is installed but not running \(status: (.*)\)\.$/);r?.[1]?n=t.gatewayUnavailable(r[1]):i?.[1]&&(n=t.gatewayNotRunning(i[1]))}else e.id===`provider-auth`&&e.message===`No API keys detected for configured providers.`&&(n=t.providerAuthMissing);return{...e,label:t.labels[e.id]??e.label,message:n,hints:e.hints.map(e=>W(e,t))}}function K(e,t){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>{let n=G(e,t);return{id:n.id,label:n.label,status:n.status,message:n.message,hints:n.hints,path:H(n.id),source:`doctor`}}).toSorted((e,t)=>U(t.status)-U(e.status)||e.label.localeCompare(t.label))}function ne(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let r of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let i=t.get(r);if(i){let t=G(i,e.copy);n.push({id:t.id,label:t.label,status:t.status,message:t.message,path:H(t.id)})}}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:e.copy?.labels[`logs-health`]??`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.copy?e.logsHealth.shuttingDown?e.copy.logsShuttingDown:t>0?e.copy.logsErrors(t):e.copy.logsHealthy:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[]){let r=t.message;if(e.copy){r={"Local Chromium is installed.":e.copy.chromiumInstalled,"Local Chromium is not installed.":e.copy.chromiumNotInstalled,"Chrome extension bridge is connected.":e.copy.extensionConnected,"Chrome extension needs refresh.":e.copy.extensionNeedsRefresh,"Chrome extension is installed but not connected.":e.copy.extensionNotConnected,"Chrome extension is not installed.":e.copy.extensionNotInstalled}[t.message]??t.message;let n=t.message.match(/^Browser driver "(.*)" is configured\.$/);n?.[1]&&(r=e.copy.browserDriverConfigured(n[1]))}n.push({...t,label:e.copy?.labels[t.id]??t.label,message:r})}return n}function re(e){let t=R(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=z(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=B(e.config),l=e.skillCount>0,u=(e.doctorChecks??[]).filter(t=>!e.isElectron||t.id!==`gateway-service`),d=K(u,e.labels.diagnostics),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:V(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:V(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:V(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=ne({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics,copy:e.labels.diagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function ie(e){return te(e)}function ae(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function oe(){return d(`/api/doctor`)}async function se(){return((await c(oe())).checks??[]).map(ae).filter(e=>e!==null)}function ce(){return d(`/api/logs/health`)}async function le(){return c(ce())}function q(e){return e?`pass`:`warn`}function ue(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function J(e){if(!e.enabled)return[];if(e.driverKind===`playwright`){let e=await c(d(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:q(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser`}]}if(e.driverKind===`extension`){let e=await c(d(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:`/settings/agent-browser`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser driver "${e.driverKind}" is configured.`,path:`/settings/agent-browser`}]}function Y(){let e=(0,L.c)(95),t=l(ge),n=u(he),r;e[0]===n?r=e[1]:(r=f(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=i.setupStatus.diagnostics,s=g(me),{data:c,error:d,isLoading:y,mutate:b}=m(!!t),x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!1},e[2]=x):x=e[2];let{data:S,error:C,isLoading:T,mutate:E}=p(t?`setup-checklist-skills`:null,pe,x),D;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(D={revalidateOnFocus:!1},e[3]=D):D=e[3];let{data:O,error:ee,isLoading:k,mutate:A}=p(t?`setup-checklist-provider-meta`:null,w,D),j;e[4]===t?j=e[5]:(j=t?oe():null,e[4]=t,e[5]=j);let M;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(M={revalidateOnFocus:!1},e[6]=M):M=e[6];let{data:N,error:P,isLoading:F,mutate:I}=p(j,se,M),R;e[7]===t?R=e[8]:(R=t?ce():null,e[7]=t,e[8]=R);let z;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(z={revalidateOnFocus:!1},e[9]=z):z=e[9];let{data:B,isLoading:te,mutate:V}=p(R,le,z);c?.payload?.config;let H=c?.payload?.config,U;e[10]===H?U=e[11]:(U=ie(H),e[10]=H,e[11]=U);let W=t?U:null,G;e[12]===W?G=e[13]:(G=ue(W),e[12]=W,e[13]=G);let K;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(K={revalidateOnFocus:!1},e[14]=K):K=e[14];let{data:ne,isLoading:ae,mutate:q}=p(G,fe,K),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?v:null,_,J);let Y=!t||!y&&!T&&!k&&!F&&!te&&!ae,X=!!(d||C||ee||P),_e;bb0:{if(!t||!Y){_e=null;break bb0}let n=S?.catalog?.length??0,r;if(e[16]!==ne||e[17]!==c?.payload?.config||e[18]!==o.browserDriverConfigured||e[19]!==o.chromiumInstalled||e[20]!==o.chromiumNotInstalled||e[21]!==o.extensionConnected||e[22]!==o.extensionNeedsRefresh||e[23]!==o.extensionNotConnected||e[24]!==o.extensionNotInstalled||e[25]!==o.gatewayNotInstalled||e[26]!==o.gatewayNotRunning||e[27]!==o.gatewayUnavailable||e[28]!==o.installCommand||e[29]!==o.labels||e[30]!==o.logsErrors||e[31]!==o.logsHealthy||e[32]!==o.logsShuttingDown||e[33]!==o.providerAuthMissing||e[34]!==o.runCommand||e[35]!==o.runtimeInvalid||e[36]!==o.runtimeMissing||e[37]!==o.startCommand||e[38]!==N||e[39]!==a.channelConfigured||e[40]!==a.channelMissing||e[41]!==a.gatewayOffline||e[42]!==a.gatewayOnline||e[43]!==a.modelConfigured||e[44]!==a.modelMissing||e[45]!==a.providersConfigured||e[46]!==a.providersMetaReady||e[47]!==a.providersMissing||e[48]!==a.skillsConfigured||e[49]!==a.skillsMissing||e[50]!==B||e[51]!==i.setupStatus.requiredCompleteMessage||e[52]!==O||e[53]!==s||e[54]!==n||e[55]!==t){let l=O?.filter(de).length??0,u=O?.length??0,d;e[57]===a.providersConfigured?d=e[58]:(d=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[57]=a.providersConfigured,e[58]=d);let f;e[59]===a.providersMetaReady?f=e[60]:(f=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[59]=a.providersMetaReady,e[60]=f);let p;e[61]===a.modelConfigured?p=e[62]:(p=e=>a.modelConfigured.replace(`{{model}}`,e),e[61]=a.modelConfigured,e[62]=p);let m;e[63]===a.skillsConfigured?m=e[64]:(m=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[63]=a.skillsConfigured,e[64]=m);let g;e[65]===o.runtimeMissing?g=e[66]:(g=e=>o.runtimeMissing.replace(`{{runtimes}}`,e),e[65]=o.runtimeMissing,e[66]=g);let _;e[67]===o.runtimeInvalid?_=e[68]:(_=e=>o.runtimeInvalid.replace(`{{runtimes}}`,e),e[67]=o.runtimeInvalid,e[68]=_);let v;e[69]===o.gatewayUnavailable?v=e[70]:(v=e=>o.gatewayUnavailable.replace(`{{detail}}`,e),e[69]=o.gatewayUnavailable,e[70]=v);let y;e[71]===o.gatewayNotRunning?y=e[72]:(y=e=>o.gatewayNotRunning.replace(`{{status}}`,e),e[71]=o.gatewayNotRunning,e[72]=y);let b;e[73]===o.runCommand?b=e[74]:(b=e=>o.runCommand.replace(`{{command}}`,e),e[73]=o.runCommand,e[74]=b);let x;e[75]===o.installCommand?x=e[76]:(x=e=>o.installCommand.replace(`{{command}}`,e),e[75]=o.installCommand,e[76]=x);let S;e[77]===o.startCommand?S=e[78]:(S=e=>o.startCommand.replace(`{{command}}`,e),e[77]=o.startCommand,e[78]=S);let C;e[79]===o.logsErrors?C=e[80]:(C=e=>o.logsErrors.replace(`{{count}}`,String(e)),e[79]=o.logsErrors,e[80]=C);let w;e[81]===o.browserDriverConfigured?w=e[82]:(w=e=>o.browserDriverConfigured.replace(`{{driver}}`,e),e[81]=o.browserDriverConfigured,e[82]=w),r=re({isElectron:h(),hasToken:!!t,realtimeConnected:s,config:c?.payload?.config,skillCount:n,providerMeta:u>0?{configured:l,total:u}:null,doctorChecks:N,logsHealth:B,browserDiagnostics:ne,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:d,providersMetaReady:f,providersMissing:a.providersMissing,modelConfigured:p,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:m,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage,diagnostics:{labels:o.labels,runtimeMissing:g,runtimeInvalid:_,gatewayNotInstalled:o.gatewayNotInstalled,gatewayUnavailable:v,gatewayNotRunning:y,providerAuthMissing:o.providerAuthMissing,runCommand:b,installCommand:x,startCommand:S,logsHealthy:o.logsHealthy,logsShuttingDown:o.logsShuttingDown,logsErrors:C,chromiumInstalled:o.chromiumInstalled,chromiumNotInstalled:o.chromiumNotInstalled,extensionConnected:o.extensionConnected,extensionNeedsRefresh:o.extensionNeedsRefresh,extensionNotConnected:o.extensionNotConnected,extensionNotInstalled:o.extensionNotInstalled,browserDriverConfigured:w}}}),e[16]=ne,e[17]=c?.payload?.config,e[18]=o.browserDriverConfigured,e[19]=o.chromiumInstalled,e[20]=o.chromiumNotInstalled,e[21]=o.extensionConnected,e[22]=o.extensionNeedsRefresh,e[23]=o.extensionNotConnected,e[24]=o.extensionNotInstalled,e[25]=o.gatewayNotInstalled,e[26]=o.gatewayNotRunning,e[27]=o.gatewayUnavailable,e[28]=o.installCommand,e[29]=o.labels,e[30]=o.logsErrors,e[31]=o.logsHealthy,e[32]=o.logsShuttingDown,e[33]=o.providerAuthMissing,e[34]=o.runCommand,e[35]=o.runtimeInvalid,e[36]=o.runtimeMissing,e[37]=o.startCommand,e[38]=N,e[39]=a.channelConfigured,e[40]=a.channelMissing,e[41]=a.gatewayOffline,e[42]=a.gatewayOnline,e[43]=a.modelConfigured,e[44]=a.modelMissing,e[45]=a.providersConfigured,e[46]=a.providersMetaReady,e[47]=a.providersMissing,e[48]=a.skillsConfigured,e[49]=a.skillsMissing,e[50]=B,e[51]=i.setupStatus.requiredCompleteMessage,e[52]=O,e[53]=s,e[54]=n,e[55]=t,e[56]=r}else r=e[56];_e=r}let Z=_e,Q;e[83]!==q||e[84]!==b||e[85]!==I||e[86]!==V||e[87]!==A||e[88]!==E?(Q=async()=>{await Promise.all([b(),E(),A(),I(),V(),q()])},e[83]=q,e[84]=b,e[85]=I,e[86]=V,e[87]=A,e[88]=E,e[89]=Q):Q=e[89];let ve=Q,$;return e[90]!==X||e[91]!==Y||e[92]!==ve||e[93]!==Z?($={ready:Y,error:X,snapshot:Z,refresh:ve},e[90]=X,e[91]=Y,e[92]=ve,e[93]=Z,e[94]=$):$=e[94],$}function de(e){return e.configured}function fe(e){let[,t]=e;return J(t)}function pe(){return T()}function me(e){return e.connectionState===`connected`}function he(e){return e.language}function ge(e){return e.conversationId}var X=r();function _e(e){return e===`pass`?`bg-success-soft text-success`:e===`warn`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`bg-red-500/10 text-red-700 dark:text-red-300`:`bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?a:e===`warn`?E:e===`fail`?C:S}function Q(e,t){return e===`blocked`?{icon:C,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:E,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:k,className:`bg-surface-hover/50 text-fg`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function ve(e){let t=(0,L.c)(46),{tier:n,issueCount:r,onRunDoctor:a,ready:c,doctorRunning:l,doctorRunState:d}=e,p=u($),m,h,g,_,v,y,S,C,w;if(t[0]!==r||t[1]!==p||t[2]!==n){h=f(p).setupStatus;let e=Q(n,h),a=e.icon,o=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,c=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=o?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(o)?.scrollIntoView({block:`start`,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}):(0,X.jsxs)(i,{to:c,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}),w=s(`rounded-xl p-4`,e.className),C=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,y=`flex min-w-0 gap-3`,S=(0,X.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),g=`min-w-0`,_=(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),v=r>0?(0,X.jsx)(`p`,{className:`mt-1 text-sm opacity-80`,children:h.health.issueCount.replace(`{{count}}`,String(r))}):null,t[0]=r,t[1]=p,t[2]=n,t[3]=m,t[4]=h,t[5]=g,t[6]=_,t[7]=v,t[8]=y,t[9]=S,t[10]=C,t[11]=w}else m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],S=t[9],C=t[10],w=t[11];let T;t[12]!==g||t[13]!==_||t[14]!==v?(T=(0,X.jsxs)(`div`,{className:g,children:[_,v]}),t[12]=g,t[13]=_,t[14]=v,t[15]=T):T=t[15];let E;t[16]!==y||t[17]!==S||t[18]!==T?(E=(0,X.jsxs)(`div`,{className:y,children:[S,T]}),t[16]=y,t[17]=S,t[18]=T,t[19]=E):E=t[19];let D;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=s(`inline-flex items-center gap-2 rounded-lg bg-surface-base/70 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`,ee.press),t[20]=D):D=t[20];let O=!c||l,k;t[21]===l?k=t[22]:(k=l?(0,X.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t[21]=l,t[22]=k);let A=l?h.health.runDoctorRunning:h.health.runDoctor,j;t[23]!==l||t[24]!==a||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,X.jsxs)(`button`,{type:`button`,className:D,onClick:a,disabled:O,"aria-busy":l,children:[k,A]}),t[23]=l,t[24]=a,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==m||t[30]!==j?(M=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,j]}),t[29]=m,t[30]=j,t[31]=M):M=t[31];let N;t[32]!==M||t[33]!==C||t[34]!==E?(N=(0,X.jsxs)(`div`,{className:C,children:[E,M]}),t[32]=M,t[33]=C,t[34]=E,t[35]=N):N=t[35];let P;t[36]!==d||t[37]!==l||t[38]!==h.health.doctorCompleteMessage||t[39]!==h.health.doctorFailedMessage||t[40]!==h.health.doctorRunningMessage?(P=l||d!==`idle`?(0,X.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:l?h.health.doctorRunningMessage:d===`success`?h.health.doctorCompleteMessage:h.health.doctorFailedMessage}):null,t[36]=d,t[37]=l,t[38]=h.health.doctorCompleteMessage,t[39]=h.health.doctorFailedMessage,t[40]=h.health.doctorRunningMessage,t[41]=P):P=t[41];let F;return t[42]!==N||t[43]!==P||t[44]!==w?(F=(0,X.jsxs)(`section`,{className:w,children:[N,P]}),t[42]=N,t[43]=P,t[44]=w,t[45]=F):F=t[45],F}function $(e){return e.language}function ye(e){let t=(0,L.c)(26),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]===n.hints[0]?u=t[9]:(u=n.hints[0]?(0,X.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[8]=n.hints[0],t[9]=u);let d;t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l,u]}),t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==r||t[15]!==n.path?(f=n.path?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,X.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}):null,t[14]=r,t[15]=n.path,t[16]=f):f=t[16];let p;t[17]!==s||t[18]!==d||t[19]!==f?(p=(0,X.jsxs)(X.Fragment,{children:[s,d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m=p;if(n.path){let e;return t[21]!==m||t[22]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-start gap-3 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m}),t[21]=m,t[22]=n.path,t[23]=e):e=t[23],e}let h;return t[24]===m?h=t[25]:(h=(0,X.jsx)(`div`,{className:`flex items-start gap-3 px-1 py-3`,children:m}),t[24]=m,t[25]=h),h}function be(e){let t=(0,L.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=s(`flex size-7 shrink-0 items-center justify-center rounded-full`,_e(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===o?u=t[5]:(u=(0,X.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,X.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,X.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,X.jsx)(b,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,X.jsxs)(X.Fragment,{children:[d,m,h]}),t[18]=d,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,X.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function xe(e){let t=(0,L.c)(23),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==r||t[12]!==n.path?(d=n.path?(0,X.jsx)(`span`,{className:`sr-only`,children:r}):null,t[11]=r,t[12]=n.path,t[13]=d):d=t[13];let f;t[14]!==s||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(X.Fragment,{children:[s,u,d]}),t[14]=s,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p=f;if(n.path){let e;return t[18]!==p||t[19]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:p}),t[18]=p,t[19]=n.path,t[20]=e):e=t[20],e}let m;return t[21]===p?m=t[22]:(m=(0,X.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 px-1 py-3`,children:p}),t[21]=p,t[22]=m),m}function Se(){let e=f(u(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=Y(),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(`idle`),l=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],d=async()=>{if(!(a||!t)){o(!0),c(`idle`);try{await i(),c(`success`)}catch{c(`error`)}finally{o(!1)}}};return(0,X.jsxs)(j,{gap:`gap-6`,children:[(0,X.jsx)(A,{title:e.title}),n?(0,X.jsx)(`p`,{className:`rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,X.jsx)(P,{sections:2}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ve,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void d(),doctorRunning:a,doctorRunState:s}),(0,X.jsxs)(N,{id:`next-steps`,children:[(0,X.jsx)(M,{icon:r.issues.length?E:y,title:e.nextStepsTitle}),r.issues.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:r.issues.slice(0,8).map(t=>(0,X.jsx)(ye,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:bg-surface-base/45`,children:r.readiness.map(t=>(0,X.jsx)(be,{item:t,labels:e.readinessLabels},t.id))})]}),(0,X.jsx)(F,{children:(0,X.jsxs)(N,{children:[(0,X.jsx)(M,{icon:D,title:e.diagnosticsTitle}),l.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:l.map(t=>(0,X.jsx)(xe,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,X.jsx)(`p`,{className:`mt-3 py-2 text-sm text-fg-muted`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})})]})]})}export{Se as SetupStatusPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./cn-JdwAhgNB.js";import{a as c,c as l,n as u,r as d}from"./locale-store-DPZ79W1-.js";import{t as f}from"./messages-BiYTyLJr.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-xAOGtenO.js";import{n as h}from"./electron-env-Dit0bHgy.js";import{n as g}from"./gateway-realtime-store-BG95uGVW.js";import{n as _,t as v}from"./registry-api-B_e_nZSN.js";import{$u as y,Au as b,Mc as x,Ml as S,Su as C,Tt as w,li as T,tc as E,uc as D,xo as O,xs as ee,xu as k}from"./index-DJo4DimT.js";import{n as A,r as j}from"./settings-page-layout-X1x-2Cp9.js";import{n as M,t as N}from"./settings-form-section-B0veRBZs.js";import{n as P}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as F}from"./settings-advanced-gate-C1SM5B93.js";var I=e(t(),1),L=n();function R(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&O(e)).length}function z(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function B(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function te(e){if(!e||typeof e!=`object`)return{enabled:!1,driverKind:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,driverKind:`extension`};let n=t,r=n.driver&&typeof n.driver==`object`&&!Array.isArray(n.driver)?n.driver:void 0;return{enabled:n.enabled===!0,driverKind:typeof r?.kind==`string`&&r.kind.trim()?r.kind.trim():`extension`}}function V(e){return e?`pass`:`fail`}function H(e){if(e===`tool-runtimes`)return`/settings/runtimes`;if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function U(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function W(e,t){let n=e.match(/^Run(?::|\s)(.*)$/i);if(n?.[1])return t.runCommand(n[1].trim());let r=e.match(/^Install(?::|\s)(.*)$/i);if(r?.[1])return t.installCommand(r[1].trim());let i=e.match(/^Start(?::|\s)(.*)$/i);return i?.[1]?t.startCommand(i[1].trim()):e}function G(e,t){if(!t)return e;let n=e.message;if(e.id===`tool-runtimes`){let r=e.message.match(/^(.*) runtime is not installed\.$/),i=e.message.match(/^(.*) runtime installation is invalid\.$/);r?.[1]?n=t.runtimeMissing(r[1]):i?.[1]&&(n=t.runtimeInvalid(i[1]))}else if(e.id===`gateway-service`)if(e.message===`Gateway is not installed as a system service.`)n=t.gatewayNotInstalled;else{let r=e.message.match(/^Service backend unavailable: (.*)$/),i=e.message.match(/^Gateway service is installed but not running \(status: (.*)\)\.$/);r?.[1]?n=t.gatewayUnavailable(r[1]):i?.[1]&&(n=t.gatewayNotRunning(i[1]))}else e.id===`provider-auth`&&e.message===`No API keys detected for configured providers.`&&(n=t.providerAuthMissing);return{...e,label:t.labels[e.id]??e.label,message:n,hints:e.hints.map(e=>W(e,t))}}function K(e,t){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>{let n=G(e,t);return{id:n.id,label:n.label,status:n.status,message:n.message,hints:n.hints,path:H(n.id),source:`doctor`}}).toSorted((e,t)=>U(t.status)-U(e.status)||e.label.localeCompare(t.label))}function ne(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let r of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let i=t.get(r);if(i){let t=G(i,e.copy);n.push({id:t.id,label:t.label,status:t.status,message:t.message,path:H(t.id)})}}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:e.copy?.labels[`logs-health`]??`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.copy?e.logsHealth.shuttingDown?e.copy.logsShuttingDown:t>0?e.copy.logsErrors(t):e.copy.logsHealthy:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[]){let r=t.message;if(e.copy){r={"Local Chromium is installed.":e.copy.chromiumInstalled,"Local Chromium is not installed.":e.copy.chromiumNotInstalled,"Chrome extension bridge is connected.":e.copy.extensionConnected,"Chrome extension needs refresh.":e.copy.extensionNeedsRefresh,"Chrome extension is installed but not connected.":e.copy.extensionNotConnected,"Chrome extension is not installed.":e.copy.extensionNotInstalled}[t.message]??t.message;let n=t.message.match(/^Browser driver "(.*)" is configured\.$/);n?.[1]&&(r=e.copy.browserDriverConfigured(n[1]))}n.push({...t,label:e.copy?.labels[t.id]??t.label,message:r})}return n}function re(e){let t=R(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=z(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=B(e.config),l=e.skillCount>0,u=(e.doctorChecks??[]).filter(t=>!e.isElectron||t.id!==`gateway-service`),d=K(u,e.labels.diagnostics),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:V(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:V(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:V(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=ne({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics,copy:e.labels.diagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function ie(e){return te(e)}function ae(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function oe(){return d(`/api/doctor`)}async function se(){return((await c(oe())).checks??[]).map(ae).filter(e=>e!==null)}function ce(){return d(`/api/logs/health`)}async function le(){return c(ce())}function q(e){return e?`pass`:`warn`}function ue(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function J(e){if(!e.enabled)return[];if(e.driverKind===`playwright`){let e=await c(d(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:q(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser`}]}if(e.driverKind===`extension`){let e=await c(d(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:`/settings/agent-browser`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser driver "${e.driverKind}" is configured.`,path:`/settings/agent-browser`}]}function Y(){let e=(0,L.c)(95),t=l(ge),n=u(he),r;e[0]===n?r=e[1]:(r=f(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=i.setupStatus.diagnostics,s=g(me),{data:c,error:d,isLoading:y,mutate:b}=m(!!t),x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!1},e[2]=x):x=e[2];let{data:S,error:C,isLoading:T,mutate:E}=p(t?`setup-checklist-skills`:null,pe,x),D;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(D={revalidateOnFocus:!1},e[3]=D):D=e[3];let{data:O,error:ee,isLoading:k,mutate:A}=p(t?`setup-checklist-provider-meta`:null,w,D),j;e[4]===t?j=e[5]:(j=t?oe():null,e[4]=t,e[5]=j);let M;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(M={revalidateOnFocus:!1},e[6]=M):M=e[6];let{data:N,error:P,isLoading:F,mutate:I}=p(j,se,M),R;e[7]===t?R=e[8]:(R=t?ce():null,e[7]=t,e[8]=R);let z;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(z={revalidateOnFocus:!1},e[9]=z):z=e[9];let{data:B,isLoading:te,mutate:V}=p(R,le,z);c?.payload?.config;let H=c?.payload?.config,U;e[10]===H?U=e[11]:(U=ie(H),e[10]=H,e[11]=U);let W=t?U:null,G;e[12]===W?G=e[13]:(G=ue(W),e[12]=W,e[13]=G);let K;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(K={revalidateOnFocus:!1},e[14]=K):K=e[14];let{data:ne,isLoading:ae,mutate:q}=p(G,fe,K),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?v:null,_,J);let Y=!t||!y&&!T&&!k&&!F&&!te&&!ae,X=!!(d||C||ee||P),_e;bb0:{if(!t||!Y){_e=null;break bb0}let n=S?.catalog?.length??0,r;if(e[16]!==ne||e[17]!==c?.payload?.config||e[18]!==o.browserDriverConfigured||e[19]!==o.chromiumInstalled||e[20]!==o.chromiumNotInstalled||e[21]!==o.extensionConnected||e[22]!==o.extensionNeedsRefresh||e[23]!==o.extensionNotConnected||e[24]!==o.extensionNotInstalled||e[25]!==o.gatewayNotInstalled||e[26]!==o.gatewayNotRunning||e[27]!==o.gatewayUnavailable||e[28]!==o.installCommand||e[29]!==o.labels||e[30]!==o.logsErrors||e[31]!==o.logsHealthy||e[32]!==o.logsShuttingDown||e[33]!==o.providerAuthMissing||e[34]!==o.runCommand||e[35]!==o.runtimeInvalid||e[36]!==o.runtimeMissing||e[37]!==o.startCommand||e[38]!==N||e[39]!==a.channelConfigured||e[40]!==a.channelMissing||e[41]!==a.gatewayOffline||e[42]!==a.gatewayOnline||e[43]!==a.modelConfigured||e[44]!==a.modelMissing||e[45]!==a.providersConfigured||e[46]!==a.providersMetaReady||e[47]!==a.providersMissing||e[48]!==a.skillsConfigured||e[49]!==a.skillsMissing||e[50]!==B||e[51]!==i.setupStatus.requiredCompleteMessage||e[52]!==O||e[53]!==s||e[54]!==n||e[55]!==t){let l=O?.filter(de).length??0,u=O?.length??0,d;e[57]===a.providersConfigured?d=e[58]:(d=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[57]=a.providersConfigured,e[58]=d);let f;e[59]===a.providersMetaReady?f=e[60]:(f=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[59]=a.providersMetaReady,e[60]=f);let p;e[61]===a.modelConfigured?p=e[62]:(p=e=>a.modelConfigured.replace(`{{model}}`,e),e[61]=a.modelConfigured,e[62]=p);let m;e[63]===a.skillsConfigured?m=e[64]:(m=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[63]=a.skillsConfigured,e[64]=m);let g;e[65]===o.runtimeMissing?g=e[66]:(g=e=>o.runtimeMissing.replace(`{{runtimes}}`,e),e[65]=o.runtimeMissing,e[66]=g);let _;e[67]===o.runtimeInvalid?_=e[68]:(_=e=>o.runtimeInvalid.replace(`{{runtimes}}`,e),e[67]=o.runtimeInvalid,e[68]=_);let v;e[69]===o.gatewayUnavailable?v=e[70]:(v=e=>o.gatewayUnavailable.replace(`{{detail}}`,e),e[69]=o.gatewayUnavailable,e[70]=v);let y;e[71]===o.gatewayNotRunning?y=e[72]:(y=e=>o.gatewayNotRunning.replace(`{{status}}`,e),e[71]=o.gatewayNotRunning,e[72]=y);let b;e[73]===o.runCommand?b=e[74]:(b=e=>o.runCommand.replace(`{{command}}`,e),e[73]=o.runCommand,e[74]=b);let x;e[75]===o.installCommand?x=e[76]:(x=e=>o.installCommand.replace(`{{command}}`,e),e[75]=o.installCommand,e[76]=x);let S;e[77]===o.startCommand?S=e[78]:(S=e=>o.startCommand.replace(`{{command}}`,e),e[77]=o.startCommand,e[78]=S);let C;e[79]===o.logsErrors?C=e[80]:(C=e=>o.logsErrors.replace(`{{count}}`,String(e)),e[79]=o.logsErrors,e[80]=C);let w;e[81]===o.browserDriverConfigured?w=e[82]:(w=e=>o.browserDriverConfigured.replace(`{{driver}}`,e),e[81]=o.browserDriverConfigured,e[82]=w),r=re({isElectron:h(),hasToken:!!t,realtimeConnected:s,config:c?.payload?.config,skillCount:n,providerMeta:u>0?{configured:l,total:u}:null,doctorChecks:N,logsHealth:B,browserDiagnostics:ne,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:d,providersMetaReady:f,providersMissing:a.providersMissing,modelConfigured:p,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:m,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage,diagnostics:{labels:o.labels,runtimeMissing:g,runtimeInvalid:_,gatewayNotInstalled:o.gatewayNotInstalled,gatewayUnavailable:v,gatewayNotRunning:y,providerAuthMissing:o.providerAuthMissing,runCommand:b,installCommand:x,startCommand:S,logsHealthy:o.logsHealthy,logsShuttingDown:o.logsShuttingDown,logsErrors:C,chromiumInstalled:o.chromiumInstalled,chromiumNotInstalled:o.chromiumNotInstalled,extensionConnected:o.extensionConnected,extensionNeedsRefresh:o.extensionNeedsRefresh,extensionNotConnected:o.extensionNotConnected,extensionNotInstalled:o.extensionNotInstalled,browserDriverConfigured:w}}}),e[16]=ne,e[17]=c?.payload?.config,e[18]=o.browserDriverConfigured,e[19]=o.chromiumInstalled,e[20]=o.chromiumNotInstalled,e[21]=o.extensionConnected,e[22]=o.extensionNeedsRefresh,e[23]=o.extensionNotConnected,e[24]=o.extensionNotInstalled,e[25]=o.gatewayNotInstalled,e[26]=o.gatewayNotRunning,e[27]=o.gatewayUnavailable,e[28]=o.installCommand,e[29]=o.labels,e[30]=o.logsErrors,e[31]=o.logsHealthy,e[32]=o.logsShuttingDown,e[33]=o.providerAuthMissing,e[34]=o.runCommand,e[35]=o.runtimeInvalid,e[36]=o.runtimeMissing,e[37]=o.startCommand,e[38]=N,e[39]=a.channelConfigured,e[40]=a.channelMissing,e[41]=a.gatewayOffline,e[42]=a.gatewayOnline,e[43]=a.modelConfigured,e[44]=a.modelMissing,e[45]=a.providersConfigured,e[46]=a.providersMetaReady,e[47]=a.providersMissing,e[48]=a.skillsConfigured,e[49]=a.skillsMissing,e[50]=B,e[51]=i.setupStatus.requiredCompleteMessage,e[52]=O,e[53]=s,e[54]=n,e[55]=t,e[56]=r}else r=e[56];_e=r}let Z=_e,Q;e[83]!==q||e[84]!==b||e[85]!==I||e[86]!==V||e[87]!==A||e[88]!==E?(Q=async()=>{await Promise.all([b(),E(),A(),I(),V(),q()])},e[83]=q,e[84]=b,e[85]=I,e[86]=V,e[87]=A,e[88]=E,e[89]=Q):Q=e[89];let ve=Q,$;return e[90]!==X||e[91]!==Y||e[92]!==ve||e[93]!==Z?($={ready:Y,error:X,snapshot:Z,refresh:ve},e[90]=X,e[91]=Y,e[92]=ve,e[93]=Z,e[94]=$):$=e[94],$}function de(e){return e.configured}function fe(e){let[,t]=e;return J(t)}function pe(){return T()}function me(e){return e.connectionState===`connected`}function he(e){return e.language}function ge(e){return e.conversationId}var X=r();function _e(e){return e===`pass`?`bg-success-soft text-success`:e===`warn`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`bg-red-500/10 text-red-700 dark:text-red-300`:`bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?a:e===`warn`?E:e===`fail`?C:S}function Q(e,t){return e===`blocked`?{icon:C,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:E,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:k,className:`bg-surface-hover/50 text-fg`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function ve(e){let t=(0,L.c)(46),{tier:n,issueCount:r,onRunDoctor:a,ready:c,doctorRunning:l,doctorRunState:d}=e,p=u($),m,h,g,_,v,y,S,C,w;if(t[0]!==r||t[1]!==p||t[2]!==n){h=f(p).setupStatus;let e=Q(n,h),a=e.icon,o=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,c=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=o?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(o)?.scrollIntoView({block:`start`,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}):(0,X.jsxs)(i,{to:c,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}),w=s(`rounded-xl p-4`,e.className),C=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,y=`flex min-w-0 gap-3`,S=(0,X.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),g=`min-w-0`,_=(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),v=r>0?(0,X.jsx)(`p`,{className:`mt-1 text-sm opacity-80`,children:h.health.issueCount.replace(`{{count}}`,String(r))}):null,t[0]=r,t[1]=p,t[2]=n,t[3]=m,t[4]=h,t[5]=g,t[6]=_,t[7]=v,t[8]=y,t[9]=S,t[10]=C,t[11]=w}else m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],S=t[9],C=t[10],w=t[11];let T;t[12]!==g||t[13]!==_||t[14]!==v?(T=(0,X.jsxs)(`div`,{className:g,children:[_,v]}),t[12]=g,t[13]=_,t[14]=v,t[15]=T):T=t[15];let E;t[16]!==y||t[17]!==S||t[18]!==T?(E=(0,X.jsxs)(`div`,{className:y,children:[S,T]}),t[16]=y,t[17]=S,t[18]=T,t[19]=E):E=t[19];let D;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=s(`inline-flex items-center gap-2 rounded-lg bg-surface-base/70 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`,ee.press),t[20]=D):D=t[20];let O=!c||l,k;t[21]===l?k=t[22]:(k=l?(0,X.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t[21]=l,t[22]=k);let A=l?h.health.runDoctorRunning:h.health.runDoctor,j;t[23]!==l||t[24]!==a||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,X.jsxs)(`button`,{type:`button`,className:D,onClick:a,disabled:O,"aria-busy":l,children:[k,A]}),t[23]=l,t[24]=a,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==m||t[30]!==j?(M=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,j]}),t[29]=m,t[30]=j,t[31]=M):M=t[31];let N;t[32]!==M||t[33]!==C||t[34]!==E?(N=(0,X.jsxs)(`div`,{className:C,children:[E,M]}),t[32]=M,t[33]=C,t[34]=E,t[35]=N):N=t[35];let P;t[36]!==d||t[37]!==l||t[38]!==h.health.doctorCompleteMessage||t[39]!==h.health.doctorFailedMessage||t[40]!==h.health.doctorRunningMessage?(P=l||d!==`idle`?(0,X.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:l?h.health.doctorRunningMessage:d===`success`?h.health.doctorCompleteMessage:h.health.doctorFailedMessage}):null,t[36]=d,t[37]=l,t[38]=h.health.doctorCompleteMessage,t[39]=h.health.doctorFailedMessage,t[40]=h.health.doctorRunningMessage,t[41]=P):P=t[41];let F;return t[42]!==N||t[43]!==P||t[44]!==w?(F=(0,X.jsxs)(`section`,{className:w,children:[N,P]}),t[42]=N,t[43]=P,t[44]=w,t[45]=F):F=t[45],F}function $(e){return e.language}function ye(e){let t=(0,L.c)(26),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]===n.hints[0]?u=t[9]:(u=n.hints[0]?(0,X.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[8]=n.hints[0],t[9]=u);let d;t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l,u]}),t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==r||t[15]!==n.path?(f=n.path?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,X.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}):null,t[14]=r,t[15]=n.path,t[16]=f):f=t[16];let p;t[17]!==s||t[18]!==d||t[19]!==f?(p=(0,X.jsxs)(X.Fragment,{children:[s,d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m=p;if(n.path){let e;return t[21]!==m||t[22]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-start gap-3 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m}),t[21]=m,t[22]=n.path,t[23]=e):e=t[23],e}let h;return t[24]===m?h=t[25]:(h=(0,X.jsx)(`div`,{className:`flex items-start gap-3 px-1 py-3`,children:m}),t[24]=m,t[25]=h),h}function be(e){let t=(0,L.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=s(`flex size-7 shrink-0 items-center justify-center rounded-full`,_e(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===o?u=t[5]:(u=(0,X.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,X.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,X.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,X.jsx)(b,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,X.jsxs)(X.Fragment,{children:[d,m,h]}),t[18]=d,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,X.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function xe(e){let t=(0,L.c)(23),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==r||t[12]!==n.path?(d=n.path?(0,X.jsx)(`span`,{className:`sr-only`,children:r}):null,t[11]=r,t[12]=n.path,t[13]=d):d=t[13];let f;t[14]!==s||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(X.Fragment,{children:[s,u,d]}),t[14]=s,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p=f;if(n.path){let e;return t[18]!==p||t[19]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:p}),t[18]=p,t[19]=n.path,t[20]=e):e=t[20],e}let m;return t[21]===p?m=t[22]:(m=(0,X.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 px-1 py-3`,children:p}),t[21]=p,t[22]=m),m}function Se(){let e=f(u(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=Y(),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(`idle`),l=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],d=async()=>{if(!(a||!t)){o(!0),c(`idle`);try{await i(),c(`success`)}catch{c(`error`)}finally{o(!1)}}};return(0,X.jsxs)(j,{gap:`gap-6`,children:[(0,X.jsx)(A,{title:e.title}),n?(0,X.jsx)(`p`,{className:`rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,X.jsx)(P,{sections:2}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ve,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void d(),doctorRunning:a,doctorRunState:s}),(0,X.jsxs)(N,{id:`next-steps`,children:[(0,X.jsx)(M,{icon:r.issues.length?E:y,title:e.nextStepsTitle}),r.issues.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:r.issues.slice(0,8).map(t=>(0,X.jsx)(ye,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:bg-surface-base/45`,children:r.readiness.map(t=>(0,X.jsx)(be,{item:t,labels:e.readinessLabels},t.id))})]}),(0,X.jsx)(F,{children:(0,X.jsxs)(N,{children:[(0,X.jsx)(M,{icon:D,title:e.diagnosticsTitle}),l.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:l.map(t=>(0,X.jsx)(xe,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,X.jsx)(`p`,{className:`mt-3 py-2 text-sm text-fg-muted`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})})]})]})}export{Se as SetupStatusPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-Db4nTY5N.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/pdf-runtime-DU_sMPjG.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{p as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./markdown-view-BInabSKf.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c,r as l}from"./locale-store-msTfRK8P.js";import{t as u}from"./messages-F74LVAiU.js";import{t as d}from"./copy-to-clipboard-HOJ79TWv.js";import{t as f}from"./skeleton-BwbyijEw.js";import{Bi as p,Io as m,Jr as h,Ri as g,Vi as _,Yr as v,ra as y}from"./index-CDfcPiPb.js";var b=e(t(),1),x=n(),S=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,C=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,w=/!\[([^\]]*)\]\[([^\]]+)\]/g;function T(e,t){let n=new Map;for(let t of e.matchAll(S))n.set(E(t[1]??``),t[2]??``);return e.replace(C,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(w,(e,r,i)=>{let a=n.get(E(i));return a?`[${r.trim()||t}](${a})`:e})}function E(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var D=r();function O(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function k(e){let t=(0,x.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:o,setExpanded:c}=h(),l=u(a.language),f;t[0]===l?f=t[1]:(f=async()=>{let e=await d(window.location.href);m(e?`success`:`warning`,e?l.sharesSettings.copied:l.clipboard.copyFailed)},t[0]=l,t[1]=f);let p=f,g=o&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,_;t[2]===g?_=t[3]:(_=s(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,g),t[2]=g,t[3]=_);let y;t[4]!==c||t[5]!==a.loadError||t[6]!==a.loading?(y=!a.loading&&!a.loadError?()=>c(A):void 0,t[4]=c,t[5]=a.loadError,t[6]=a.loading,t[7]=y):y=t[7];let b;t[8]===i?b=t[9]:(b=()=>window.location.assign(i),t[8]=i,t[9]=b);let S;t[10]===p?S=t[11]:(S=()=>void p(),t[10]=p,t[11]=S);let C=a.loading||!!a.loadError,w;t[12]!==S||t[13]!==C?(w={onClick:S,disabled:C},t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==o||t[18]!==n||t[19]!==y||t[20]!==b||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:o,onToggleExpanded:y,onClose:b,share:w,openInBrowser:T},t[17]=o,t[18]=n,t[19]=y,t[20]=b,t[21]=w,t[22]=T,t[23]=E):E=t[23];let O;t[24]!==a||t[25]!==E?(O=(0,D.jsx)(v,{...a,header:E}),t[24]=a,t[25]=E,t[26]=O):O=t[26];let k;return t[27]!==O||t[28]!==_?(k=(0,D.jsx)(`div`,{className:_,children:O}),t[27]=O,t[28]=_,t[29]=k):k=t[29],k}function A(e){return!e}function j(){let{token:e}=a(),t=c(e=>e.language),n=t===`zh`?P:F,[r,s]=(0,b.useState)(null),[u,d]=(0,b.useState)(O),[m,h]=(0,b.useState)(!0),[v,x]=(0,b.useState)(null),[S,C]=(0,b.useState)(null),[w,E]=(0,b.useState)(null),A=(0,b.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=p(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:g(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,b.useEffect)(()=>{if(!e){x(n.invalidLink),h(!1);return}let t=!1;return(async()=>{try{h(!0),x(null),d(O()),C(null),E(null);let r=await fetch(l(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||x(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(s(a),!a.valid){x(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(l(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){x(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&C(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let o=p(a.fileName,a.mimeType),c=g(a.fileName,o),u=_(c),f=l(`/s/${encodeURIComponent(e)}?inline=1`);if(u===`text`){if(a.fileSize>5242880){x(n.tooLarge);return}let e=await fetch(f);if(!e.ok){x(n.expired);return}let r=await e.text();t||d({...O(),textContent:r});return}if(u===`binary`){if(a.fileSize>33554432){x(n.tooLarge);return}let e=await fetch(f);if(!e.ok){x(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-Db4nTY5N.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>y;d({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,y):t,extractedTextTruncated:n});return}d({...O(),binaryBuffer:r})}}catch(e){t||x(e instanceof Error?e.message:String(e))}finally{t||h(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let j=e?l(`/s/${encodeURIComponent(e)}?dl=1`):`#`,I=e?l(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return A&&r&&e?(0,D.jsx)(k,{language:t,descriptor:A,loading:m,loadError:v,textContent:u.textContent,binaryBuffer:u.binaryBuffer,extractedText:u.extractedText,extractedTextTruncated:u.extractedTextTruncated,subtitle:(0,D.jsxs)(`span`,{className:`truncate`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:I,landingUrl:l(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=j},canDownload:!m&&!v}}):(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,D.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,D.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):m?(0,D.jsx)(f,{className:`h-4 w-48 max-w-full`}):(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,D.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,D.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:m?(0,D.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,D.jsx)(f,{className:`h-5 w-56 max-w-full`}),(0,D.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,D.jsx)(f,{className:`h-4 w-full`}),(0,D.jsx)(f,{className:`h-4 w-11/12`}),(0,D.jsx)(f,{className:`h-4 w-10/12`}),(0,D.jsx)(f,{className:`h-4 w-3/4`})]}),(0,D.jsx)(f,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):v?(0,D.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,D.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,D.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:v})]}):r?.kind===`directory`?(0,D.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&S?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,D.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:S.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(S.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(S.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),S.description?(0,D.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-inset px-4 py-3 text-sm leading-6 text-fg-muted`,children:S.description}):null,(0,D.jsx)(o,{content:T(S.markdown,n.remoteImageBlocked),className:`mt-8`}),(0,D.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&w?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,D.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:w.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(w.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(w.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),w.description?(0,D.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:w.description}):null]}),(0,D.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[w.messages.map(e=>(0,D.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,D.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,D.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-inset px-4 py-3`:`px-1 py-1`,children:[(0,D.jsx)(o,{content:T(e.markdown,n.remoteImageBlocked)}),w.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,D.jsx)(M,{attachment:e},e.id)),w.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,D.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e.toolName}),(0,D.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,D.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),w.toolActivities.filter(e=>!e.messageId).map(e=>(0,D.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,D.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})}function M(e){let t=(0,x.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,D.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,D.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,D.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=N(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,D.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,D.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function N(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var P={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},F={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{j as SharePreviewPage};
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{p as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./markdown-view-p2P5hP1U.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c,r as l}from"./locale-store-DPZ79W1-.js";import{t as u}from"./messages-BiYTyLJr.js";import{t as d}from"./copy-to-clipboard-HOJ79TWv.js";import{t as f}from"./skeleton-BwbyijEw.js";import{Bi as p,Io as m,Jr as h,Ri as g,Vi as _,Yr as v,ra as y}from"./index-DJo4DimT.js";var b=e(t(),1),x=n(),S=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,C=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,w=/!\[([^\]]*)\]\[([^\]]+)\]/g;function T(e,t){let n=new Map;for(let t of e.matchAll(S))n.set(E(t[1]??``),t[2]??``);return e.replace(C,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(w,(e,r,i)=>{let a=n.get(E(i));return a?`[${r.trim()||t}](${a})`:e})}function E(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var D=r();function O(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function k(e){let t=(0,x.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:o,setExpanded:c}=h(),l=u(a.language),f;t[0]===l?f=t[1]:(f=async()=>{let e=await d(window.location.href);m(e?`success`:`warning`,e?l.sharesSettings.copied:l.clipboard.copyFailed)},t[0]=l,t[1]=f);let p=f,g=o&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,_;t[2]===g?_=t[3]:(_=s(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,g),t[2]=g,t[3]=_);let y;t[4]!==c||t[5]!==a.loadError||t[6]!==a.loading?(y=!a.loading&&!a.loadError?()=>c(A):void 0,t[4]=c,t[5]=a.loadError,t[6]=a.loading,t[7]=y):y=t[7];let b;t[8]===i?b=t[9]:(b=()=>window.location.assign(i),t[8]=i,t[9]=b);let S;t[10]===p?S=t[11]:(S=()=>void p(),t[10]=p,t[11]=S);let C=a.loading||!!a.loadError,w;t[12]!==S||t[13]!==C?(w={onClick:S,disabled:C},t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==o||t[18]!==n||t[19]!==y||t[20]!==b||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:o,onToggleExpanded:y,onClose:b,share:w,openInBrowser:T},t[17]=o,t[18]=n,t[19]=y,t[20]=b,t[21]=w,t[22]=T,t[23]=E):E=t[23];let O;t[24]!==a||t[25]!==E?(O=(0,D.jsx)(v,{...a,header:E}),t[24]=a,t[25]=E,t[26]=O):O=t[26];let k;return t[27]!==O||t[28]!==_?(k=(0,D.jsx)(`div`,{className:_,children:O}),t[27]=O,t[28]=_,t[29]=k):k=t[29],k}function A(e){return!e}function j(){let{token:e}=a(),t=c(e=>e.language),n=t===`zh`?P:F,[r,s]=(0,b.useState)(null),[u,d]=(0,b.useState)(O),[m,h]=(0,b.useState)(!0),[v,x]=(0,b.useState)(null),[S,C]=(0,b.useState)(null),[w,E]=(0,b.useState)(null),A=(0,b.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=p(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:g(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,b.useEffect)(()=>{if(!e){x(n.invalidLink),h(!1);return}let t=!1;return(async()=>{try{h(!0),x(null),d(O()),C(null),E(null);let r=await fetch(l(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||x(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(s(a),!a.valid){x(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(l(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){x(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&C(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let o=p(a.fileName,a.mimeType),c=g(a.fileName,o),u=_(c),f=l(`/s/${encodeURIComponent(e)}?inline=1`);if(u===`text`){if(a.fileSize>5242880){x(n.tooLarge);return}let e=await fetch(f);if(!e.ok){x(n.expired);return}let r=await e.text();t||d({...O(),textContent:r});return}if(u===`binary`){if(a.fileSize>33554432){x(n.tooLarge);return}let e=await fetch(f);if(!e.ok){x(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-Db4nTY5N.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>y;d({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,y):t,extractedTextTruncated:n});return}d({...O(),binaryBuffer:r})}}catch(e){t||x(e instanceof Error?e.message:String(e))}finally{t||h(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let j=e?l(`/s/${encodeURIComponent(e)}?dl=1`):`#`,I=e?l(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return A&&r&&e?(0,D.jsx)(k,{language:t,descriptor:A,loading:m,loadError:v,textContent:u.textContent,binaryBuffer:u.binaryBuffer,extractedText:u.extractedText,extractedTextTruncated:u.extractedTextTruncated,subtitle:(0,D.jsxs)(`span`,{className:`truncate`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:I,landingUrl:l(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=j},canDownload:!m&&!v}}):(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,D.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,D.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):m?(0,D.jsx)(f,{className:`h-4 w-48 max-w-full`}):(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,D.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,D.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:m?(0,D.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,D.jsx)(f,{className:`h-5 w-56 max-w-full`}),(0,D.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,D.jsx)(f,{className:`h-4 w-full`}),(0,D.jsx)(f,{className:`h-4 w-11/12`}),(0,D.jsx)(f,{className:`h-4 w-10/12`}),(0,D.jsx)(f,{className:`h-4 w-3/4`})]}),(0,D.jsx)(f,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):v?(0,D.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,D.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,D.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:v})]}):r?.kind===`directory`?(0,D.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&S?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,D.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:S.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(S.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(S.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),S.description?(0,D.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-inset px-4 py-3 text-sm leading-6 text-fg-muted`,children:S.description}):null,(0,D.jsx)(o,{content:T(S.markdown,n.remoteImageBlocked),className:`mt-8`}),(0,D.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&w?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,D.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:w.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(w.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(w.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),w.description?(0,D.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:w.description}):null]}),(0,D.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[w.messages.map(e=>(0,D.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,D.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,D.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-inset px-4 py-3`:`px-1 py-1`,children:[(0,D.jsx)(o,{content:T(e.markdown,n.remoteImageBlocked)}),w.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,D.jsx)(M,{attachment:e},e.id)),w.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,D.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e.toolName}),(0,D.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,D.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),w.toolActivities.filter(e=>!e.messageId).map(e=>(0,D.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,D.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})}function M(e){let t=(0,x.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,D.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,D.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,D.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=N(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,D.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,D.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function N(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var P={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},F={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{j as SharePreviewPage};
|