@xopcai/xopc 0.0.199 → 0.0.200

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.
Files changed (135) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Bt70bZjv.js → agent-avatar-dicebear-eMarz29u.js} +1 -1
  4. package/dist/gateway/static/root/assets/agents-DeLW-454.js +68 -0
  5. package/dist/gateway/static/root/assets/{app-management-settings-panel-B4x7JfL8.js → app-management-settings-panel-yfb68wq9.js} +1 -1
  6. package/dist/gateway/static/root/assets/{appearance-settings-Dwdagf-Q.js → appearance-settings-B8SPknFM.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-DkTiesxe.js → apps-page-Bmor22Ny.js} +1 -1
  8. package/dist/gateway/static/root/assets/{archive-plugin-Cv0VXKLm.js → archive-plugin-DmYRiOP3.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-CgidKrXn.js → attachment-load-D66JvcPi.js} +1 -1
  10. package/dist/gateway/static/root/assets/automations-page-Q4e8m11h.js +6 -0
  11. package/dist/gateway/static/root/assets/{binary-plugins-DN3CQgIq.js → binary-plugins-ChIsZArT.js} +1 -1
  12. package/dist/gateway/static/root/assets/{block-editor-BwkSl1F_.js → block-editor-Ck-k_d0Z.js} +5 -5
  13. package/dist/gateway/static/root/assets/browser-settings-page--uVL73Sb.js +8 -0
  14. package/dist/gateway/static/root/assets/{browser-workflows-page-C_I31wLm.js → browser-workflows-page-BC5jm1zL.js} +2 -2
  15. package/dist/gateway/static/root/assets/capabilities-settings-panel-DXpf3QYN.js +7 -0
  16. package/dist/gateway/static/root/assets/capability-presets-settings-panel-NAjCsrTi.js +3 -0
  17. package/dist/gateway/static/root/assets/{channels-settings-DV5BhAeu.js → channels-settings-CiWUo7jW.js} +1 -1
  18. package/dist/gateway/static/root/assets/{connectors-api-5FEBYguL.js → connectors-api-5xiCRVUS.js} +1 -1
  19. package/dist/gateway/static/root/assets/connectors-page-DOwlMseU.js +2 -0
  20. package/dist/gateway/static/root/assets/{cron-expression-SEFx5rnr.js → cron-expression-B3PebXKZ.js} +1 -1
  21. package/dist/gateway/static/root/assets/{date-picker-D4zCUQJL.js → date-picker-C1Vke7Xn.js} +1 -1
  22. package/dist/gateway/static/root/assets/{dependency-picker-DpQAxS2k.js → dependency-picker-FrQ0tsBC.js} +1 -1
  23. package/dist/gateway/static/root/assets/{desktop-pet-B_5G3lQl.js → desktop-pet-CPBAzNJi.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-settings-ClEyoUJe.js → desktop-pet-settings-D6s3glDP.js} +1 -1
  25. package/dist/gateway/static/root/assets/{directory-picker-path-field-AsFWmOjG.js → directory-picker-path-field-CbNQ7QQS.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-debug-page-C22Y2o5l.js → extension-debug-page-dTK14hUv.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-page-C61Ikawk.js → extension-page-Cpdj1Kip.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-settings-page-WlWWcDFr.js → extension-settings-page-iNHUZGd5.js} +1 -1
  29. package/dist/gateway/static/root/assets/{gateway-config-api-ByIOMQdc.js → gateway-config-api-SvMvWqMM.js} +1 -1
  30. package/dist/gateway/static/root/assets/{gateway-settings-CzzS9A17.js → gateway-settings-BilR3dGZ.js} +1 -1
  31. package/dist/gateway/static/root/assets/heartbeat-settings-zK40dcQ5.js +1 -0
  32. package/dist/gateway/static/root/assets/home-page-NyXy5MLr.js +3 -0
  33. package/dist/gateway/static/root/assets/{index-CR233S0Q.css → index-Bp8I_eX4.css} +1 -1
  34. package/dist/gateway/static/root/assets/index-CCK8zdlS.js +152 -0
  35. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BD_TFz0_.js → keyboard-shortcuts-settings-nKzsroud.js} +1 -1
  36. package/dist/gateway/static/root/assets/local-app-workbench-page-Ds3sPXTh.js +2 -0
  37. package/dist/gateway/static/root/assets/{local-apps-page-BwbUeLfm.js → local-apps-page-DV1s_FYh.js} +1 -1
  38. package/dist/gateway/static/root/assets/logs-page-Biz4eA02.js +2 -0
  39. package/dist/gateway/static/root/assets/{management-settings-CW2VpqtT.js → management-settings-D7KjYgHu.js} +1 -1
  40. package/dist/gateway/static/root/assets/{markdown-split-B1M9KO16.js → markdown-split-CTYbpkrd.js} +1 -1
  41. package/dist/gateway/static/root/assets/{media-plugins-B_QlNdqZ.js → media-plugins-BXYnaiZ6.js} +1 -1
  42. package/dist/gateway/static/root/assets/{notes-page-BTbD4GmH.js → notes-page-CWWVXpw5.js} +1 -1
  43. package/dist/gateway/static/root/assets/notes-workbench-DnBkQihH.js +4 -0
  44. package/dist/gateway/static/root/assets/{preview-open-alternatives-CeqtArlZ.js → preview-open-alternatives-pimQAkeI.js} +1 -1
  45. package/dist/gateway/static/root/assets/{product-open-page-DnalBZZs.js → product-open-page-BoYSS_YR.js} +1 -1
  46. package/dist/gateway/static/root/assets/project-detail-page-ZO7t1UkB.js +1 -0
  47. package/dist/gateway/static/root/assets/projects-page-By-vq41g.js +1 -0
  48. package/dist/gateway/static/root/assets/remote-access-hub-C0C_Y9d0.js +1 -0
  49. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-cGkBEfg4.js → runtime-tools-settings-panel-DT8flaX1.js} +2 -2
  50. package/dist/gateway/static/root/assets/{schema-form-CmsrLlxu.js → schema-form-DabEP-UI.js} +1 -1
  51. package/dist/gateway/static/root/assets/sessions-page-BNlVwUzV.js +1 -0
  52. package/dist/gateway/static/root/assets/settings-advanced-gate-CxYBQDaM.js +1 -0
  53. package/dist/gateway/static/root/assets/{settings-form-section-DUWCbaMJ.js → settings-form-section-DCsfZAtC.js} +1 -1
  54. package/dist/gateway/static/root/assets/{settings-loading-skeleton-Bvy5rdMY.js → settings-loading-skeleton-Dac6Yd0T.js} +1 -1
  55. package/dist/gateway/static/root/assets/{settings-page-cZSAwsRR.js → settings-page-BDoYoEar.js} +1 -1
  56. package/dist/gateway/static/root/assets/setup-status-panel-DWijJ1rw.js +1 -0
  57. package/dist/gateway/static/root/assets/{share-preview-page-BzA2NCAH.js → share-preview-page-ie9I2_7h.js} +1 -1
  58. package/dist/gateway/static/root/assets/shares-settings-DU9VrJLf.js +1 -0
  59. package/dist/gateway/static/root/assets/skill-reload-api-C5RaIvoE.js +1 -0
  60. package/dist/gateway/static/root/assets/{skills-page-Bvde7_i5.js → skills-page-N0YhaR5S.js} +1 -1
  61. package/dist/gateway/static/root/assets/{skills-page.utils-vXSqHR7g.js → skills-page.utils-C639DLXr.js} +1 -1
  62. package/dist/gateway/static/root/assets/{system-settings-panel-9cQGOGCK.js → system-settings-panel-CpshpQtC.js} +1 -1
  63. package/dist/gateway/static/root/assets/task-detail-page-DsTocYkK.js +1 -0
  64. package/dist/gateway/static/root/assets/{use-autosave-7XfKULPI.js → use-autosave-ms6rDy59.js} +1 -1
  65. package/dist/gateway/static/root/assets/{user-context-page-CZ9m9aC_.js → user-context-page-BUxIemwy.js} +1 -1
  66. package/dist/gateway/static/root/assets/{voice-api-key-field-DXr21v-3.js → voice-api-key-field-CObrQWh2.js} +1 -1
  67. package/dist/gateway/static/root/assets/{work-discovery-overlay-CeG7g_DZ.js → work-discovery-overlay-BBxrnEFt.js} +1 -1
  68. package/dist/gateway/static/root/assets/work-discovery-page-DN3l-HW3.js +1 -0
  69. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DSQQZP9T.js → workflow-run-setup-panel-BxXhe3IV.js} +2 -2
  70. package/dist/gateway/static/root/assets/workflows-page-BCHkjd1i.js +5 -0
  71. package/dist/gateway/static/root/index.html +2 -2
  72. package/dist/package.js +1 -1
  73. package/dist/packages/gateway-contract/src/tasks.js +51 -9
  74. package/dist/src/agent/context/execution-scope.js +3 -1
  75. package/dist/src/agent/tasks/task-judge-service.d.ts +1 -1
  76. package/dist/src/agent/tasks/task-judge-service.js +3 -2
  77. package/dist/src/agent/tools/xopc-use-tool.js +13 -3
  78. package/dist/src/automations/domain/validation.d.ts +0 -12
  79. package/dist/src/automations/draft/automation-draft-validator.d.ts +0 -3
  80. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  81. package/dist/src/gateway/hono/app.js +1 -1
  82. package/dist/src/gateway/hono/routes/agent-stream.js +2 -74
  83. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +62 -0
  84. package/dist/src/gateway/hono/routes/session-input-handler.js +82 -0
  85. package/dist/src/gateway/hono/routes/tasks.js +161 -2
  86. package/dist/src/gateway/service/task-conversation-query-service.d.ts +58 -0
  87. package/dist/src/gateway/service/task-conversation-query-service.js +84 -0
  88. package/dist/src/gateway/service.d.ts +10 -0
  89. package/dist/src/gateway/service.js +70 -37
  90. package/dist/src/projects/project-agent.js +1 -1
  91. package/dist/src/storage/sqlite/migrations/120_task_conversation.sql +112 -0
  92. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  93. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  94. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  95. package/dist/src/storage/sqlite/schema.js +1 -1
  96. package/dist/src/tasks/execution-context.js +8 -4
  97. package/dist/src/tasks/index.d.ts +2 -0
  98. package/dist/src/tasks/index.js +3 -1
  99. package/dist/src/tasks/task-application-service.js +10 -17
  100. package/dist/src/tasks/task-context-assembler.js +9 -4
  101. package/dist/src/tasks/task-context-repository.d.ts +0 -6
  102. package/dist/src/tasks/task-context-repository.js +0 -4
  103. package/dist/src/tasks/task-conversation-repository.d.ts +71 -0
  104. package/dist/src/tasks/task-conversation-repository.js +194 -0
  105. package/dist/src/tasks/task-handoff-service.d.ts +31 -0
  106. package/dist/src/tasks/task-handoff-service.js +143 -0
  107. package/dist/src/tasks/task-read-model-projector.js +1 -5
  108. package/dist/src/tasks/task-repository.d.ts +0 -2
  109. package/dist/src/tasks/task-repository.js +2 -9
  110. package/dist/src/tasks/task-run-coordinator.js +3 -1
  111. package/dist/src/workflows/service/workflow-run-service.js +4 -2
  112. package/package.json +3 -3
  113. package/dist/gateway/static/root/assets/agents-D19uNmJf.js +0 -68
  114. package/dist/gateway/static/root/assets/automations-page-BR6qMOVr.js +0 -6
  115. package/dist/gateway/static/root/assets/browser-settings-page-CDFQWAxI.js +0 -8
  116. package/dist/gateway/static/root/assets/capabilities-settings-panel-D41mssOq.js +0 -7
  117. package/dist/gateway/static/root/assets/capability-presets-settings-panel-BXgCyuu2.js +0 -3
  118. package/dist/gateway/static/root/assets/connectors-page-C_qkEN0T.js +0 -2
  119. package/dist/gateway/static/root/assets/heartbeat-settings-B4A_CXUL.js +0 -1
  120. package/dist/gateway/static/root/assets/home-page-FVGYYPWo.js +0 -3
  121. package/dist/gateway/static/root/assets/index-CGbKTCST.js +0 -152
  122. package/dist/gateway/static/root/assets/local-app-workbench-page-BNpkigNb.js +0 -2
  123. package/dist/gateway/static/root/assets/logs-page-DXP9OQQt.js +0 -2
  124. package/dist/gateway/static/root/assets/notes-workbench-JRiq7QDW.js +0 -4
  125. package/dist/gateway/static/root/assets/project-detail-page-CjWA13aE.js +0 -1
  126. package/dist/gateway/static/root/assets/projects-page-jsCkScbG.js +0 -1
  127. package/dist/gateway/static/root/assets/remote-access-hub-CGPJTEkM.js +0 -1
  128. package/dist/gateway/static/root/assets/sessions-page-BBHzziMd.js +0 -1
  129. package/dist/gateway/static/root/assets/settings-advanced-gate-2cGg8-9h.js +0 -1
  130. package/dist/gateway/static/root/assets/setup-status-panel-Cf06b66-.js +0 -1
  131. package/dist/gateway/static/root/assets/shares-settings-xlNKydYY.js +0 -1
  132. package/dist/gateway/static/root/assets/skill-reload-api-C5Xu93c_.js +0 -1
  133. package/dist/gateway/static/root/assets/task-detail-page-Bkno4tTe.js +0 -1
  134. package/dist/gateway/static/root/assets/work-discovery-page-CQWZD03N.js +0 -1
  135. package/dist/gateway/static/root/assets/workflows-page-Cs-MXFJ1.js +0 -5
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as a,r as o}from"./popover-select-BzdnTy3h.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./button-CSEbl4zT.js";import{s as l}from"./form-field-width-DJw_jULe.js";import{n as u,t as d}from"./interaction-BmQogeqz.js";import{t as f}from"./messages-3qRsLZuX.js";import{l as p,n as m,r as h,s as g}from"./locale-store-xULEcFVs.js";import{i as _,o as v}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as y,n as b,o as ee,r as x,s as S,t as C}from"./dist-BPoKqzeH.js";import{i as w}from"./vendor-swr-BIWyz7Rc.js";import{n as T,r as E}from"./gateway-config-swr-jB0hAhWO.js";import{n as D,r as O,t as k}from"./settings-form-draft-Dy10ldo8.js";import{Aa as A,As as j,Bi as M,Bt as N,Es as P,Gi as F,Go as I,Gs as L,Hi as R,J as z,Ji as B,Jl as V,Ki as H,Ko as U,Ks as W,Li as G,Ri as te,Rt as ne,Sc as re,Uc as ie,Ui as ae,Vi as K,Vs as q,Vt as oe,Yi as se,ic as J,ka as ce,ml as le,nl as ue,oc as de,os as fe,qi as pe,ql as me,rl as he,wc as ge,xc as _e,zi as ve,zt as ye}from"./index-CGbKTCST.js";import{n as be,t as xe}from"./use-autosave-7XfKULPI.js";import{t as Se}from"./settings-advanced-gate-2cGg8-9h.js";import{n as Ce,t as Y}from"./settings-form-section-DUWCbaMJ.js";import{t as we}from"./page-tabs-BaEQMYm_.js";var X=e(t(),1),Te=n(),Z=r();function Ee(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 De(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Oe(e){let t=(0,Te.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let f=u,p;t[3]===n.name?p=t[4]:(p=n.name?.trim(),t[3]=n.name,t[4]=p);let m=!!p,h=n.status===`archived`,g=n.status===`pinned`,_=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,v;t[5]===_?v=t[6]:(v=s(`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`,_),t[5]=_,t[6]=v);let y;t[7]===c?y=t[8]:(y=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=y);let b=r===`list`&&`sm:py-3`,ee;t[9]===b?ee=t[10]:(ee=s(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,b),t[9]=b,t[10]=ee);let x;t[11]===n.sourceChannel?x=t[12]:(x=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=x);let S;t[13]===g?S=t[14]:(S=g?(0,Z.jsx)(W,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=g,t[14]=S);let C;t[15]===n.updatedAt?C=t[16]:(C=Ee(n.updatedAt),t[15]=n.updatedAt,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,Z.jsx)(`span`,{children:C}),t[17]=C,t[18]=w);let T;t[19]!==w||t[20]!==S?(T=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[S,w]}),t[19]=w,t[20]=S,t[21]=T):T=t[21];let E;t[22]!==T||t[23]!==ee||t[24]!==x?(E=(0,Z.jsxs)(`div`,{className:ee,children:[x,T]}),t[22]=T,t[23]=ee,t[24]=x,t[25]=E):E=t[25];let D=r===`list`&&`sm:py-3`,O;t[26]===D?O=t[27]:(O=s(`min-w-0 flex-1 px-3 py-2`,D),t[26]=D,t[27]=O);let k=r===`list`&&`sm:items-start`,A;t[28]===k?A=t[29]:(A=s(`flex gap-3`,k),t[28]=k,t[29]=A);let j;t[30]!==o||t[31]!==a?(j=(0,Z.jsx)(se,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=j):j=t[32];let M;t[33]===f?M=t[34]:(M=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[33]=f,t[34]=M);let N;t[35]!==n.key||t[36]!==m?(N=m?(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[35]=n.key,t[36]=m,t[37]=N):N=t[37];let P;t[38]!==M||t[39]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[M,N]}),t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==A||t[42]!==j||t[43]!==P?(F=(0,Z.jsxs)(`div`,{className:A,children:[j,P]}),t[41]=A,t[42]=j,t[43]=P,t[44]=F):F=t[44];let R;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(de,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=R):R=t[45];let z;t[46]===n.messageCount?z=t[47]:(z=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[R,n.messageCount]}),t[46]=n.messageCount,t[47]=z);let B;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(I,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=B):B=t[48];let H;t[49]===n.estimatedTokens?H=t[50]:(H=De(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=H);let U;t[51]===H?U=t[52]:(U=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[B,H]}),t[51]=H,t[52]=U);let G;t[53]!==z||t[54]!==U?(G=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[z,U]}),t[53]=z,t[54]=U,t[55]=G):G=t[55];let te;t[56]===n.tags?te=t[57]:(te=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(je),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=te);let ne;t[58]!==O||t[59]!==F||t[60]!==G||t[61]!==te?(ne=(0,Z.jsxs)(`div`,{className:O,children:[F,G,te]}),t[58]=O,t[59]=F,t[60]=G,t[61]=te,t[62]=ne):ne=t[62];let re;t[63]===l?re=t[64]:(re=()=>l(`continue`),t[63]=l,t[64]=re);let ie;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(de,{className:`size-4`,strokeWidth:1.75}),t[65]=ie):ie=t[65];let ae;t[66]!==i.continueChat||t[67]!==re?(ae=(0,Z.jsx)(`button`,{type:`button`,className:d,title:i.continueChat,"aria-label":i.continueChat,onClick:re,children:ie}),t[66]=i.continueChat,t[67]=re,t[68]=ae):ae=t[68];let K;t[69]!==h||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(K=h?(0,Z.jsx)(`button`,{type:`button`,className:d,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(V,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:d,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(me,{className:`size-4`,strokeWidth:1.75})}),t[69]=h,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=K):K=t[73];let q;t[74]!==g||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(q=g?(0,Z.jsx)(`button`,{type:`button`,className:d,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(L,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:d,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(W,{className:`size-4`,strokeWidth:1.75})}),t[74]=g,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=q):q=t[78];let oe;t[79]===l?oe=t[80]:(oe=()=>l(`export`),t[79]=l,t[80]=oe);let J;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(ue,{className:`size-4`,strokeWidth:1.75}),t[81]=J):J=t[81];let ce;t[82]!==i.export||t[83]!==oe?(ce=(0,Z.jsx)(`button`,{type:`button`,className:d,title:i.export,"aria-label":i.export,onClick:oe,children:J}),t[82]=i.export,t[83]=oe,t[84]=ce):ce=t[84];let le;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(le=s(d,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=le):le=t[85];let pe;t[86]===l?pe=t[87]:(pe=()=>l(`delete`),t[86]=l,t[87]=pe);let he;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(fe,{className:`size-4`,strokeWidth:1.75}),t[88]=he):he=t[88];let ge;t[89]!==i.delete||t[90]!==pe?(ge=(0,Z.jsx)(`button`,{type:`button`,className:le,title:i.delete,"aria-label":i.delete,onClick:pe,children:he}),t[89]=i.delete,t[90]=pe,t[91]=ge):ge=t[91];let _e;t[92]!==ae||t[93]!==K||t[94]!==q||t[95]!==ce||t[96]!==ge?(_e=(0,Z.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:Ae,onKeyDown:ke,children:[ae,K,q,ce,ge]}),t[92]=ae,t[93]=K,t[94]=q,t[95]=ce,t[96]=ge,t[97]=_e):_e=t[97];let ve;return t[98]!==c||t[99]!==E||t[100]!==ne||t[101]!==v||t[102]!==_e||t[103]!==y?(ve=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:v,onClick:c,onKeyDown:y,children:[E,ne,_e]}),t[98]=c,t[99]=E,t[100]=ne,t[101]=v,t[102]=_e,t[103]=y,t[104]=ve):ve=t[104],ve}function ke(e){return e.stopPropagation()}function Ae(e){return e.stopPropagation()}function je(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)}var Me={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(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 Fe(e){let t=Ne(e)?e:{},n=Ne(t.userContext)?t.userContext:{},r=Ne(n.memory)?n.memory:{},i=Ne(r.retention)?r.retention:{},a=Ne(i.compaction)?i.compaction:{},o=Me,s=typeof a.model==`string`&&a.model.trim()?a.model.trim():void 0,c=Array.isArray(a.postCompactionSections)&&a.postCompactionSections.length<=12&&a.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(a.postCompactionSections.map(e=>e.trim()))]:[...o.postCompactionSections];return{enabled:typeof a.enabled==`boolean`?a.enabled:o.enabled,triggerThreshold:Pe(a.triggerThreshold,o.triggerThreshold,.1,.98),reserveTokens:Q(a.reserveTokens,o.reserveTokens,1024),minMessagesBeforeCompact:Q(a.minMessagesBeforeCompact,o.minMessagesBeforeCompact,2),keepRecentTokens:Q(a.keepRecentTokens,o.keepRecentTokens,1e3),recentTurnsPreserve:Q(a.recentTurnsPreserve,o.recentTurnsPreserve,1,12),summaryMaxTokens:Q(a.summaryMaxTokens,o.summaryMaxTokens,256),summaryChunkTokens:Q(a.summaryChunkTokens,o.summaryChunkTokens,1e3),summaryTimeoutMs:Q(a.summaryTimeoutMs,o.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(a.summaryRetries,o.summaryRetries,0,5),qualityGuard:typeof a.qualityGuard==`boolean`?a.qualityGuard:o.qualityGuard,...s?{model:s}:{},minToolResultKeepChars:Q(a.minToolResultKeepChars,o.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(a.maxActiveTranscriptBytes,o.maxActiveTranscriptBytes,64e3),postCompactionSections:c}}function Ie(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 Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{memory:{retention:{compaction:t}}}}}async function Re(e){await g(h(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await T()}var ze=128e3,Be={balanced:Me,preserve:{...Me,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Me,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=k();function He(){return s(`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`,l,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(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,Te.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=He(),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 Ke(e){let t=(0,Te.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,c=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,l;t[0]===c?l=t[1]:(l=s(`flex items-start gap-2 text-sm text-fg`,c),t[0]=c,t[1]=l);let u;t[2]===o?u=t[3]:(u=e=>o(e.target.checked),t[2]=o,t[3]=u);let d;t[4]!==i||t[5]!==a||t[6]!==u?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:u}),t[4]=i,t[5]=a,t[6]=u,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]!==l||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:l,children:[d,m]}),t[15]=l,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function qe({hasToken:e}){let t=f(m(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=E(e),{data:i=[],isLoading:a}=w(e?N:null,oe,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[l,d]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[p,h]=(0,X.useState)(``),g=(0,X.useRef)(!1),_=(0,X.useRef)(l.form);_.current=l.form;let v=(0,X.useRef)(null);D({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:v,dispatch:d,onResetDirty:()=>{g.current=!1}});let y=l.form,b=l.baseline,ee=!!(y&&b&&JSON.stringify(y)!==JSON.stringify(b)),x=(0,X.useCallback)(e=>{g.current=!0,d({type:`patch`,patch:e})},[]),S=(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,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),C=xe({value:y,dirty:ee,onSave:(0,X.useCallback)(async e=>{try{await Re(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=Ie(e);return n?t.invalidValue.replace(`{{field}}`,S(n)):null}});if(!e||!y)return r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(A,{className:`h-5 w-48`}),(0,Z.jsx)(A,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(A,{className:`h-36 w-full rounded-xl`})]})}):null;let T=We(y),O=Math.max(0,ze-y.reserveTokens),k=Math.min(Math.floor(ze*y.triggerThreshold),O),j=Math.min(100,k/ze*100),M=Math.min(100,O/ze*100),P=y.model?i.find(e=>e.id===y.model):void 0,F=P?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>P.contextWindow,I=y.keepRecentTokens+y.reserveTokens>k,L=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),R=e=>{let t=Be[e];x({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},B={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},V=()=>{let e=p.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(x({postCompactionSections:[...y.postCompactionSections,e]}),h(``))};return(0,Z.jsxs)(Y,{onBlurCapture:C.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:J,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(be,{status:C.status,error:C.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=>x({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),C.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:C.error}):null,y.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 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})]}),T===`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":T===e,className:s(`rounded-xl border px-3 py-3 text-left`,u.transition,u.focusRingPanel,T===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>R(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:B[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:B[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,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:Ge(k)})]}),(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:`${j}%`}})})]}),(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:Ge(O)})]}),(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:`${M}%`}})})]})]}),(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=>x({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>x({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=>x({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>x({keepRecentTokens:Math.floor(e)})})]}),I?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 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)(z,{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=>x({model:e})}),y.model?(0,Z.jsx)(c,{type:`button`,variant:`secondary`,onClick:()=>x({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)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>x({qualityGuard:e})})]}),y.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(Se,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,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=>x({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=>x({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=>x({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=>x({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(L)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>x({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=>x({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=>x({minToolResultKeepChars:Math.floor(e)})})]}),F?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`border-t border-edge pt-5`,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:s(`text-fg-muted hover:text-fg`,u.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>x({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(U,{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:He(),value:p,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),V())}}),(0,Z.jsxs)(c,{type:`button`,variant:`secondary`,disabled:!p.trim()||y.postCompactionSections.length>=12,onClick:V,children:[(0,Z.jsx)(q,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(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:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await g(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),T()}function Qe(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,l,`dark:border-edge`)}var $e=k();function et({hasToken:e}){let t=f(m(e=>e.language)).sessions.config,{data:n,isLoading:r}=E(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[s,c]=(0,X.useReducer)($e,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),p=(0,X.useRef)(l);p.current=l;let h=(0,X.useRef)(null);D({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:h,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=xe({value:l,dirty:g,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),c({type:`saved`,value:e}),d.current=!!(p.current&&JSON.stringify(p.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(A,{className:`h-5 w-40`}),(0,Z.jsx)(A,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(Y,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:he,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(be,{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:Qe(),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:Qe(),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:Qe(),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 tt(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 nt(e){let t=(0,Te.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:l,onClose:u,onArchive:d,onUnarchive:f,onPin:p,onUnpin:m,onExport:h,onDelete:g}=e,w=i?.status===`archived`,T=i?.status===`pinned`,E;t[0]===u?E=t[1]:(E=e=>!e&&u(),t[0]=u,t[1]=E);let D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(y,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim`,v)}),t[2]=D):D=t[2];let O;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(O=s(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,_,`dark:border-edge`),t[3]=O):O=t[3];let k;t[4]!==i||t[5]!==o||t[6]!==a?(k=i&&a?(0,Z.jsx)(se,{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]=k):k=t[7];let A;t[8]!==l.unnamedSession||t[9]!==i?.name?(A=i?.name?.trim()||l.unnamedSession,t[8]=l.unnamedSession,t[9]=i?.name,t[10]=A):A=t[10];let j;t[11]===A?j=t[12]:(j=(0,Z.jsx)(S,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:A}),t[11]=A,t[12]=j);let M;t[13]!==k||t[14]!==j?(M=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[k,j]}),t[13]=k,t[14]=j,t[15]=M):M=t[15];let N;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(U,{className:`size-5`,strokeWidth:1.75}),t[16]=N):N=t[16];let P;t[17]===l.close?P=t[18]:(P=(0,Z.jsx)(b,{asChild:!0,children:(0,Z.jsx)(c,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l.close,children:N})}),t[17]=l.close,t[18]=P);let F;t[19]!==M||t[20]!==P?(F=(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:[M,P]}),t[19]=M,t[20]=P,t[21]=F):F=t[21];let I;t[22]!==l.detailLoading||t[23]!==l.detailMessages||t[24]!==r||t[25]!==i?(I=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.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:l.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=l.detailLoading,t[23]=l.detailMessages,t[24]=r,t[25]=i,t[26]=I):I=t[26];let L;t[27]===I?L=t[28]:(L=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:I}),t[27]=I,t[28]=L);let R;t[29]!==l.detailExport||t[30]!==h?(R=(0,Z.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:l.detailExport}),t[29]=l.detailExport,t[30]=h,t[31]=R):R=t[31];let z;t[32]!==w||t[33]!==l.archive||t[34]!==l.unarchive||t[35]!==d||t[36]!==f?(z=w?(0,Z.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:l.unarchive}):(0,Z.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:l.archive}),t[32]=w,t[33]=l.archive,t[34]=l.unarchive,t[35]=d,t[36]=f,t[37]=z):z=t[37];let B;t[38]!==T||t[39]!==l.pin||t[40]!==l.unpin||t[41]!==p||t[42]!==m?(B=T?(0,Z.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:l.unpin}):(0,Z.jsx)(c,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:l.pin}),t[38]=T,t[39]=l.pin,t[40]=l.unpin,t[41]=p,t[42]=m,t[43]=B):B=t[43];let V;t[44]!==l.delete||t[45]!==g?(V=(0,Z.jsx)(c,{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:g,children:l.delete}),t[44]=l.delete,t[45]=g,t[46]=V):V=t[46];let H;t[47]!==R||t[48]!==z||t[49]!==B||t[50]!==V?(H=(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:[R,z,B,V]})}),t[47]=R,t[48]=z,t[49]=B,t[50]=V,t[51]=H):H=t[51];let W;t[52]!==F||t[53]!==L||t[54]!==H?(W=(0,Z.jsxs)(ee,{children:[D,(0,Z.jsxs)(x,{className:O,"aria-describedby":void 0,children:[F,L,H]})]}),t[52]=F,t[53]=L,t[54]=H,t[55]=W):W=t[55];let G;return t[56]!==n||t[57]!==E||t[58]!==W?(G=(0,Z.jsx)(C,{open:n,onOpenChange:E,children:W}),t[56]=n,t[57]=E,t[58]=W,t[59]=G):G=t[59],G}function rt(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:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,Te.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?ge:P})),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)(we,{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 pt(e){let t=(0,Te.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-2xl bg-surface-base 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:ut(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(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 mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.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 ht(){let e=f(m(e=>e.language)),t=e.sessions,n=p(e=>e.token),r=!!n,{data:a,mutate:o}=w(r?[`gateway-chat-agents`,n]:null,ce,{revalidateOnFocus:!1}),l=a?.defaultId??`main`,d=a?.items??[],[h,g]=i(),b=lt(h.get(`tab`)),T=(0,X.useCallback)(e=>{let t=new URLSearchParams(h);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[h,g]),[E,D]=(0,X.useReducer)(O,h,mt),{searchInput:k,debouncedSearch:A,statusFilter:N,viewMode:P,channelFilter:I,sessions:L,loading:z,error:V,hasMore:U,stats:q,detailOpen:oe,detailLoading:se,detailSession:J,confirmOpen:ue,confirmKey:de}=E;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=k.trim();A!==e&&D({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[k,A]);let fe=h.toString(),he=(0,X.useRef)(fe);if(he.current!==fe){he.current=fe;let e=h.get(`q`)??``,t=h.get(`status`),n=h.get(`view`),r=(h.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();D({type:`patch`,patch:{...k===e?{}:{searchInput:e},...A===o?{}:{debouncedSearch:o},...N===i?{}:{statusFilter:i},...P===a?{}:{viewMode:a},...I===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(h),t=A.trim();t?e.set(`q`,t):e.delete(`q`),N===`all`?e.delete(`status`):e.set(`status`,N),P===`grid`?e.delete(`view`):e.set(`view`,P),I?e.set(`channel`,I):e.delete(`channel`),e.toString()!==h.toString()&&g(e,{replace:!0})},[A,h,g,N,P,I]),(0,X.useEffect)(()=>{if(!r||b!==`sessions`)return;let e=!1;return(async()=>{D({type:`patch`,patch:{loading:!0,error:null}});try{let t=await R({limit:it,offset:0,...A?{search:A}:{},...N===`all`?{}:{status:N},...I?{channel:I}:{}});if(e)return;D({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||D({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||D({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,b,A,N,I,t.loadError]),(0,X.useEffect)(()=>{!r||b!==`sessions`||K().then(e=>D({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,b]),(0,X.useEffect)(()=>{if(!r||b!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,b,o]),(0,X.useEffect)(()=>{if(!r||b!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||D({type:`patch`,patch:{sessions:L.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:J&&J.key===t.key?{...J,name:t.name}:J}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,b,L,J]);let be=(0,X.useCallback)(async()=>{if(!(!r||z||!U)){D({type:`patch`,patch:{loading:!0,error:null}});try{let e=await R({limit:it,offset:L.length,...A?{search:A}:{},...N===`all`?{}:{status:N},...I?{channel:I}:{}});D({type:`patch`,patch:{sessions:[...L,...e.items],hasMore:e.hasMore}})}catch(e){D({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{D({type:`patch`,patch:{loading:!1}})}}},[r,z,U,L.length,A,N,I,t.loadError]),xe=(0,X.useCallback)((e,t)=>{D({type:`patch`,patch:{sessions:L.map(n=>n.key===e?{...n,status:t}:n),detailSession:J&&J.key===e?{...J,status:t}:J}})},[L,J]),Se=(0,X.useCallback)(async e=>{D({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{D({type:`patch`,patch:{detailSession:await M(e)}})}catch{D({type:`patch`,patch:{detailOpen:!1}})}finally{D({type:`patch`,patch:{detailLoading:!1}})}},[]),Ce=e=>{Se(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){D({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await G(e),xe(e,`archived`);break;case`unarchive`:await F(e),xe(e,`active`);break;case`pin`:await ae(e),xe(e,`pinned`);break;case`unpin`:await H(e),xe(e,`active`);break;case`export`:{let t=await ve(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}K().then(e=>D({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await te(e),D({type:`patch`,patch:{sessions:L.filter(t=>t.key!==e),detailSession:J?.key===e?null:J,...J?.key===e?{detailOpen:!1}:{}}}),K().then(e=>D({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:ge},{key:`active`,label:t.filterActive,icon:le},{key:`pinned`,label:t.filterPinned,icon:W},{key:`archived`,label:t.filterArchived,icon:me}],ke=(()=>{let e=Object.entries(q?.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)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Z.jsx)(ft,{s:t,activeTab:b,onChange:T}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:b,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:b,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":N===e,onClick:()=>D({type:`patch`,patch:{statusFilter:e}}),className:s(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,u.transition,u.focusRingPanel,N===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 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(j,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:k,onChange:e=>D({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":A||void 0,className:`min-w-0 flex-1 border-0 bg-transparent 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":!I,onClick:()=>D({type:`patch`,patch:{channelFilter:``}}),className:s(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,u.transition,u.focusRingPanel,I?`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}),ke.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":I===e,onClick:()=>D({type:`patch`,patch:{channelFilter:e}}),className:s(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,u.transition,u.focusRingPanel,I===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,q?.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:q.byChannel[e]})]},e))]}),q?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[q.totalSessions,t.totalSessions],[q.activeSessions,t.activeSessions],[q.pinnedSessions,t.pinnedSessions],[q.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,V?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:V}):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:at(t.sessionCount,{count:L.length})}),(0,Z.jsxs)(`div`,{className:ye,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(c,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":P===`grid`,onClick:()=>D({type:`patch`,patch:{viewMode:`grid`}}),className:s(ne,`size-7 p-0`,P===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,P===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(re,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(c,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":P===`list`,onClick:()=>D({type:`patch`,patch:{viewMode:`list`}}),className:s(ne,`size-9 p-0`,P===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,P===`list`&&`text-accent-fg`),children:(0,Z.jsx)(_e,{className:`size-3.5`,strokeWidth:1.5})})]})]}),z&&L.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))}):L.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)(ie,{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)(c,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:s(`grid min-w-0 gap-3`,P===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":A||void 0,children:L.map(e=>{let t=B(e,l);return(0,Z.jsx)(Oe,{session:e,variant:P,labels:Te,sessionAgentId:t,sessionAgentAvatar:pe(t,d),onOpen:()=>Ce(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),U?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(c,{type:`button`,variant:`secondary`,disabled:z,onClick:()=>void be(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:oe,loading:se,session:J,sessionAgentId:J?B(J,l):void 0,sessionAgentAvatar:J?pe(B(J,l),d):void 0,labels:Ee,onClose:()=>{D({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>J&&void Y(J.key,`archive`),onUnarchive:()=>J&&void Y(J.key,`unarchive`),onPin:()=>J&&void Y(J.key,`pin`),onUnpin:()=>J&&void Y(J.key,`unpin`),onExport:()=>J&&void Y(J.key,`export`),onDelete:()=>J&&D({type:`patch`,patch:{confirmKey:J.key,confirmOpen:!0}})}),(0,Z.jsx)(C,{open:ue,onOpenChange:e=>D({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(ee,{children:[(0,Z.jsx)(y,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim`,v)}),(0,Z.jsxs)(x,{className:s(`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-panel p-4 shadow-popover dark:border-edge`,_),children:[(0,Z.jsx)(S,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:de?at(t.deleteSessionMessage,{name:L.find(e=>e.key===de)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(c,{type:`button`,variant:`secondary`,onClick:()=>D({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(c,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{de&&we(de),D({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{ht as SessionsPage};
@@ -1 +0,0 @@
1
- import{Gn as e}from"./index-CGbKTCST.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +0,0 @@
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-BMhrPKJC.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./interaction-BmQogeqz.js";import{t as c}from"./messages-3qRsLZuX.js";import{l,n as u,r as d,s as f}from"./locale-store-xULEcFVs.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-jB0hAhWO.js";import{Bt as h,Dc as g,Hn as _,Ot as v,Ps as y,Sl as b,Tl as x,Uo as S,Vt as C,Yl as w,as as T,hl as E,ml as D,ms as O,wa as k}from"./index-CGbKTCST.js";import{n as A,r as j}from"./settings-page-layout-BRQNel6r.js";import{n as M}from"./settings-loading-skeleton-Bvy5rdMY.js";import{n as N,t as P}from"./settings-form-section-DUWCbaMJ.js";var F=e(t(),1),I=n();function L(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`&&S(e)).length}function R(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t,r=typeof n.defaultPreset==`string`&&n.defaultPreset.trim()?n.defaultPreset.trim():`default`,i=n.capabilityPresets,a=i&&typeof i==`object`&&!Array.isArray(i)?i[r]:void 0,o=a&&typeof a==`object`&&!Array.isArray(a)?a.models:void 0;if(!o||typeof o!=`object`||Array.isArray(o))return``;let s=o,c=s.roles;if(!c||typeof c!=`object`||Array.isArray(c))return``;let l=c,u=typeof s.defaultRole==`string`&&s.defaultRole.trim()?s.defaultRole.trim():Object.keys(l)[0],d=u?l[u]:void 0;if(!d||typeof d!=`object`||Array.isArray(d))return``;let f=d.model;return typeof f==`string`?f.trim():``}function z(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 B(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t;return{enabled:n.enabled===!0,backend:typeof n.backend==`string`&&n.backend.trim()?n.backend.trim():`extension`}}function V(e){return e?`pass`:`fail`}function H(e){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 ee(e){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>({id:e.id,label:e.label,status:e.status,message:e.message,hints:e.hints,path:H(e.id),source:`doctor`})).toSorted((e,t)=>U(t.status)-U(e.status)||e.label.localeCompare(t.label))}function W(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let e of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:H(r.id)})}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message: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??[])n.push(t);return n}function te(e){let t=L(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=R(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=z(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=ee(u),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=W({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics});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 ne(e){return B(e)}function G(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 re(){return d(`/api/doctor`)}async function ie(){return((await f(re())).checks??[]).map(G).filter(e=>e!==null)}function ae(){return d(`/api/logs/health`)}async function oe(){return f(ae())}function K(e){return e?`pass`:`warn`}function q(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function se(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function ce(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await f(d(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:K(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:q(`local`)}]}if(e.backend===`cloakbrowser`){let e=await f(d(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:K(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:q(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await f(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:q(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:q(e.backend||`overview`)}]}function J(){let e=(0,I.c)(57),t=l(me),n=u(pe),r;e[0]===n?r=e[1]:(r=c(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=k(fe),{data:s,error:d,isLoading:f,mutate:g}=m(!!t),_;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},e[2]=_):_=e[2];let{data:y,error:b,isLoading:x,mutate:S}=p(t?`setup-checklist-skills`:null,de,_),w;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(w={revalidateOnFocus:!1},e[3]=w):w=e[3];let{data:T,error:E,isLoading:D,mutate:O}=p(t?`setup-checklist-provider-meta`:null,v,w),A;e[4]===t?A=e[5]:(A=t?re():null,e[4]=t,e[5]=A);let j;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!1},e[6]=j):j=e[6];let{data:M,error:N,isLoading:P,mutate:F}=p(A,ie,j),L;e[7]===t?L=e[8]:(L=t?ae():null,e[7]=t,e[8]=L);let R;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(R={revalidateOnFocus:!1},e[9]=R):R=e[9];let{data:z,isLoading:B,mutate:V}=p(L,oe,R);s?.payload?.config;let H=s?.payload?.config,U;e[10]===H?U=e[11]:(U=ne(H),e[10]=H,e[11]=U);let ee=t?U:null,W;e[12]===ee?W=e[13]:(W=se(ee),e[12]=ee,e[13]=W);let G;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(G={revalidateOnFocus:!1},e[14]=G):G=e[14];let{data:K,isLoading:q,mutate:ce}=p(W,ue,G),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?h:null,C,J);let Y=!t||!f&&!x&&!D&&!P&&!B&&!q,X=!!(d||b||E||N),Z;bb0:{if(!t||!Y){Z=null;break bb0}let n=y?.catalog?.length??0,r;if(e[16]!==K||e[17]!==s?.payload?.config||e[18]!==M||e[19]!==a.channelConfigured||e[20]!==a.channelMissing||e[21]!==a.gatewayOffline||e[22]!==a.gatewayOnline||e[23]!==a.modelConfigured||e[24]!==a.modelMissing||e[25]!==a.providersConfigured||e[26]!==a.providersMetaReady||e[27]!==a.providersMissing||e[28]!==a.skillsConfigured||e[29]!==a.skillsMissing||e[30]!==z||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==T||e[33]!==o||e[34]!==n||e[35]!==t){let c=T?.filter(le).length??0,l=T?.length??0,u;e[37]===a.providersConfigured?u=e[38]:(u=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=u);let d;e[39]===a.providersMetaReady?d=e[40]:(d=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[39]=a.providersMetaReady,e[40]=d);let f;e[41]===a.modelConfigured?f=e[42]:(f=e=>a.modelConfigured.replace(`{{model}}`,e),e[41]=a.modelConfigured,e[42]=f);let p;e[43]===a.skillsConfigured?p=e[44]:(p=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[43]=a.skillsConfigured,e[44]=p),r=te({hasToken:!!t,realtimeConnected:o,config:s?.payload?.config,skillCount:n,providerMeta:l>0?{configured:c,total:l}:null,doctorChecks:M,logsHealth:z,browserDiagnostics:K,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:u,providersMetaReady:d,providersMissing:a.providersMissing,modelConfigured:f,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:p,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[16]=K,e[17]=s?.payload?.config,e[18]=M,e[19]=a.channelConfigured,e[20]=a.channelMissing,e[21]=a.gatewayOffline,e[22]=a.gatewayOnline,e[23]=a.modelConfigured,e[24]=a.modelMissing,e[25]=a.providersConfigured,e[26]=a.providersMetaReady,e[27]=a.providersMissing,e[28]=a.skillsConfigured,e[29]=a.skillsMissing,e[30]=z,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=T,e[33]=o,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==ce||e[46]!==g||e[47]!==F||e[48]!==V||e[49]!==O||e[50]!==S?(Q=async()=>{await Promise.all([g(),S(),O(),F(),V(),ce()])},e[45]=ce,e[46]=g,e[47]=F,e[48]=V,e[49]=O,e[50]=S,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==X||e[53]!==Y||e[54]!==ge||e[55]!==he?($={ready:Y,error:X,snapshot:he,refresh:ge},e[52]=X,e[53]=Y,e[54]=ge,e[55]=he,e[56]=$):$=e[56],$}function le(e){return e.configured}function ue(e){let[,t]=e;return ce(t)}function de(){return _()}function fe(e){return e.connectionState===`connected`}function pe(e){return e.language}function me(e){return e.token}var Y=r();function X(e){return e===`pass`?`border-success/30 bg-success-soft text-success`:e===`warn`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?b:e===`warn`?T:e===`fail`?E:g}function he(e,t){return e===`blocked`?{icon:E,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:T,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:D,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:b,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Q(e){let t=(0,I.c)(48),{tier:n,issueCount:r,onRunDoctor:l,ready:d,doctorRunning:f,doctorRunState:p}=e,m=u(ge),h,g,_,v,b,S,C,w,T,E,D;if(t[0]!==r||t[1]!==m||t[2]!==n){g=c(m).setupStatus;let e=he(n,g),a=e.icon,s=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;h=s?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(s)?.scrollIntoView({block:`start`,behavior:`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,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):(0,Y.jsxs)(i,{to:l,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,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}),D=o(`rounded-xl p-4`,e.className),E=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,w=`flex min-w-0 gap-3`,T=(0,Y.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),b=`min-w-0`,S=(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),C=(0,Y.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),_=`mt-2 text-xs opacity-75`,v=g.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=m,t[2]=n,t[3]=h,t[4]=g,t[5]=_,t[6]=v,t[7]=b,t[8]=S,t[9]=C,t[10]=w,t[11]=T,t[12]=E,t[13]=D}else h=t[3],g=t[4],_=t[5],v=t[6],b=t[7],S=t[8],C=t[9],w=t[10],T=t[11],E=t[12],D=t[13];let O;t[14]!==_||t[15]!==v?(O=(0,Y.jsx)(`p`,{className:_,children:v}),t[14]=_,t[15]=v,t[16]=O):O=t[16];let k;t[17]!==O||t[18]!==b||t[19]!==S||t[20]!==C?(k=(0,Y.jsxs)(`div`,{className:b,children:[S,C,O]}),t[17]=O,t[18]=b,t[19]=S,t[20]=C,t[21]=k):k=t[21];let A;t[22]!==k||t[23]!==w||t[24]!==T?(A=(0,Y.jsxs)(`div`,{className:w,children:[T,k]}),t[22]=k,t[23]=w,t[24]=T,t[25]=A):A=t[25];let j;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(j=o(`inline-flex items-center gap-2 rounded-lg border border-edge bg-surface-base 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`,s.press),t[26]=j):j=t[26];let M=!d||f,N;t[27]===f?N=t[28]:(N=f?(0,Y.jsx)(a,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[27]=f,t[28]=N);let P=f?g.health.runDoctorRunning:g.health.runDoctor,F;t[29]!==f||t[30]!==l||t[31]!==M||t[32]!==N||t[33]!==P?(F=(0,Y.jsxs)(`button`,{type:`button`,className:j,onClick:l,disabled:M,"aria-busy":f,children:[N,P]}),t[29]=f,t[30]=l,t[31]=M,t[32]=N,t[33]=P,t[34]=F):F=t[34];let L;t[35]!==h||t[36]!==F?(L=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[h,F]}),t[35]=h,t[36]=F,t[37]=L):L=t[37];let R;t[38]!==A||t[39]!==L||t[40]!==E?(R=(0,Y.jsxs)(`div`,{className:E,children:[A,L]}),t[38]=A,t[39]=L,t[40]=E,t[41]=R):R=t[41];let z=f?g.health.doctorRunningMessage:p===`success`?g.health.doctorCompleteMessage:p===`error`?g.health.doctorFailedMessage:g.health.doctorIdleMessage,B;t[42]===z?B=t[43]:(B=(0,Y.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:z}),t[42]=z,t[43]=B);let V;return t[44]!==R||t[45]!==B||t[46]!==D?(V=(0,Y.jsxs)(`section`,{className:D,children:[R,B]}),t[44]=R,t[45]=B,t[46]=D,t[47]=V):V=t[47],V}function ge(e){return e.language}function $(e){let t=(0,I.c)(34),{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 s=a,c;t[2]===s?c=t[3]:(c=(0,Y.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.status?u=t[7]:(u=o(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,Y.jsx)(`span`,{className:u,children:n.status}),t[8]=n.status,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.message?p=t[15]:(p=(0,Y.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=p);let m;t[16]===n.hints[0]?m=t[17]:(m=n.hints[0]?(0,Y.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=m);let h;t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):null,t[22]=r,t[23]=n.path,t[24]=g):g=t[24];let _;t[25]!==g||t[26]!==c||t[27]!==h?(_=(0,Y.jsxs)(Y.Fragment,{children:[c,h,g]}),t[25]=g,t[26]=c,t[27]=h,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v}),t[29]=v,t[30]=n.path,t[31]=e):e=t[31],e}let y;return t[32]===v?y=t[33]:(y=(0,Y.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:v}),t[32]=v,t[33]=y),y}function _e(e){let t=(0,I.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 s=a,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=o(`flex size-7 shrink-0 items-center justify-center rounded-full border`,X(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,Y.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,Y.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,Y.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,Y.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,Y.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,Y.jsx)(x,{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,Y.jsxs)(Y.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,Y.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,Y.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function ve(e){let t=(0,I.c)(29),{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 s=a,c;t[2]===s?c=t[3]:(c=(0,Y.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.message?u=t[7]:(u=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;t[11]===n.status?f=t[12]:(f=o(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,Y.jsx)(`span`,{className:f,children:n.status}),t[13]=n.status,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==r||t[17]!==n.path?(m=n.path?(0,Y.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=m):m=t[18];let h;t[19]!==c||t[20]!==d||t[21]!==p||t[22]!==m?(h=(0,Y.jsxs)(Y.Fragment,{children:[c,d,p,m]}),t[19]=c,t[20]=d,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g=h;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g}),t[24]=g,t[25]=n.path,t[26]=e):e=t[26],e}let _;return t[27]===g?_=t[28]:(_=(0,Y.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:g}),t[27]=g,t[28]=_),_}function ye(){let e=c(u(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=J(),[a,l]=(0,F.useState)(!1),[d,f]=(0,F.useState)(`idle`),p=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],m=async()=>{if(!(a||!t)){l(!0),f(`idle`);try{await i(),f(`success`)}catch{f(`error`)}finally{l(!1)}}};return(0,Y.jsxs)(j,{gap:`gap-6`,children:[(0,Y.jsx)(A,{title:e.title,subtitle:e.subtitle,actions:(0,Y.jsxs)(`button`,{type:`button`,className:o(`inline-flex shrink-0 items-center gap-2 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,s.press),onClick:()=>void m(),disabled:!t||a,"aria-busy":a,children:[(0,Y.jsx)(y,{className:o(`size-4`,(!t||a)&&`animate-spin`),"aria-hidden":!0}),a?e.health.runDoctorRunning:e.refresh]})}),n?(0,Y.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,Y.jsx)(M,{sections:2}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void m(),doctorRunning:a,doctorRunState:d}),(0,Y.jsxs)(P,{id:`next-steps`,children:[(0,Y.jsx)(N,{icon:r.issues.length?T:w,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,Y.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,Y.jsx)($,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,Y.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,Y.jsx)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,Y.jsxs)(P,{children:[(0,Y.jsx)(N,{icon:O,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),p.length?(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:p.map(t=>(0,Y.jsx)(ve,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-panel/80 p-3 text-sm text-fg-muted shadow-surface`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{ye as SetupStatusPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,r as s}from"./popover-select-BzdnTy3h.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./cn-JdwAhgNB.js";import{t as d}from"./button-CSEbl4zT.js";import{s as f}from"./form-field-width-DJw_jULe.js";import{t as p}from"./copy-to-clipboard-HOJ79TWv.js";import{t as m}from"./messages-3qRsLZuX.js";import{l as h,n as g,r as _,s as v}from"./locale-store-xULEcFVs.js";import{a as y,n as b,o as x,r as S,s as ee,t as C}from"./dist-BPoKqzeH.js";import{i as te}from"./vendor-swr-BIWyz7Rc.js";import{n as w,r as T}from"./gateway-config-swr-jB0hAhWO.js";import{r as E}from"./settings-form-draft-Dy10ldo8.js";import{Aa as D,Dl as O,Dn as k,Jc as A,Ko as j,Pi as M,Pn as N,Ps as ne,Uc as P,Vs as F,br as I,ci as re,di as L,fi as R,gi as ie,hi as z,li as ae,mi as B,oi as oe,os as se,pi as ce,ui as V,ul as H}from"./index-CGbKTCST.js";import{n as U,r as W,t as G}from"./settings-page-layout-BRQNel6r.js";import{t as K}from"./settings-loading-skeleton-Bvy5rdMY.js";import{t as q}from"./settings-form-section-DUWCbaMJ.js";import{t as le}from"./page-tabs-BaEQMYm_.js";var J=e(t(),1),ue=n(),Y={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function de(){return structuredClone(Y)}var fe=36e5,X=864e5,Z=1048576;function pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function me(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function he(e){let t=pe(e)?e:{},n=pe(t.gateway)?t.gateway:{},r=pe(n.share)?n.share:{},i=pe(r.directory)?r.directory:{},a=pe(n.siteShare)?n.siteShare:{},o=pe(a.static)?a.static:{},s=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):Y.defaultTtlHours*fe,c=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):Y.maxTtlDays*X,l=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):Y.maxFileSizeMb*Z,u=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):Y.directoryMaxFolderSizeMb*Z,d=typeof a.defaultTtlMs==`number`&&Number.isFinite(a.defaultTtlMs)?Math.floor(a.defaultTtlMs):Y.siteDefaultTtlHours*fe,f=typeof a.maxTtlMs==`number`&&Number.isFinite(a.maxTtlMs)?Math.floor(a.maxTtlMs):Y.siteMaxTtlDays*X,p=typeof o.maxRootDirSize==`number`&&Number.isFinite(o.maxRootDirSize)?Math.floor(o.maxRootDirSize):Y.siteMaxRootDirSizeMb*Z;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(s/fe)),maxTtlDays:Math.max(1,Math.round(c/X)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):Y.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(l/Z)),directoryMaxFolderSizeMb:Math.max(1,Math.round(u/Z)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):Y.directoryMaxFileCount,inlinePreviewMimes:me(r.inlinePreviewMimes,32).length?me(r.inlinePreviewMimes,32):[...Y.inlinePreviewMimes],siteEnabled:a.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(d/fe)),siteMaxTtlDays:Math.max(1,Math.round(f/X)),maxActiveSites:typeof a.maxActiveSites==`number`&&Number.isFinite(a.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(a.maxActiveSites))):Y.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(p/Z)),siteMaxFileCount:typeof o.maxFileCount==`number`&&Number.isFinite(o.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(o.maxFileCount))):Y.siteMaxFileCount}}function ge(e){let t=e.defaultTtlHours*fe,n=e.maxTtlDays*X,r=e.siteDefaultTtlHours*fe,i=e.siteMaxTtlDays*X;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function _e(e){let t=ge(e);if(t)throw Error(t);await v(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*fe,maxTtlMs:e.maxTtlDays*X,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Z,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Z,maxFileCount:e.directoryMaxFileCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*fe,maxTtlMs:e.siteMaxTtlDays*X,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Z,maxFileCount:e.siteMaxFileCount}}}})}),w()}var Q=r();function ve(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,f,`dark:border-edge`)}function ye({hasToken:e}){let t=m(g(e=>e.language)).sharesSettings,{data:n,isLoading:r}=T(e),i=(0,J.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(he(n.payload.config)),[n]),a=(0,J.useRef)(!1),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)(null),[p,h]=(0,J.useState)(!1),_=o??i,v=i,y=(0,J.useMemo)(()=>!_||!v?!1:JSON.stringify(_)!==JSON.stringify(v),[_,v]),b=(0,J.useCallback)(e=>{a.current=!0,s(t=>{let n=t??v;return n?{...n,...e}:null})},[v]),x=(0,J.useCallback)(async()=>{if(!(!_||c)){l(!0),f(null),h(!1);try{await _e(_),a.current=!1,s(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){f(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[_,c,t.policySaveError]),S=(0,J.useCallback)(()=>{a.current=!1,s(null),f(null),h(!1)},[]);return!e||!_?r?(0,Q.jsx)(q,{children:(0,Q.jsx)(K,{rows:2})}):null:(0,Q.jsxs)(q,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[p?(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Q.jsx)(d,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>b(de()),children:t.policyUseRecommended}),(0,Q.jsx)(d,{type:`button`,variant:`secondary`,disabled:!y||c,onClick:S,children:t.policyDiscard}),(0,Q.jsx)(d,{type:`button`,variant:`primary`,disabled:!y||c,onClick:()=>void x(),children:c?t.policySaving:t.policySave})]})]}),y?(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Q.jsx)(be,{t,form:_,onChange:b})]})}function be(e){let t=(0,ue.c)(150),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,Q.jsx)($,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,Q.jsx)($,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,Q.jsx)($,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,Q.jsx)($,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let ee=!r.enabled,C;t[47]===i?C=t[48]:(C=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=C);let te;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==ee||t[53]!==C?(te=(0,Q.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:ee,onChange:C}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=ee,t[53]=C,t[54]=te):te=t[54];let w=!r.enabled,T;t[55]===i?T=t[56]:(T=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=T);let E;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==w||t[61]!==T?(E=(0,Q.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:w,onChange:T}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=w,t[61]=T,t[62]=E):E=t[62];let D;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==te||t[67]!==E||t[68]!==p?(D=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,te,E]}),t[63]=g,t[64]=y,t[65]=S,t[66]=te,t[67]=E,t[68]=p,t[69]=D):D=t[69];let O=!r.enabled,k;t[70]===i?k=t[71]:(k=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=k);let A;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==O||t[75]!==k?(A=(0,Q.jsx)(xe,{t:n,values:r.inlinePreviewMimes,disabled:O,onChange:k}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=O,t[75]=k,t[76]=A):A=t[76];let j;t[77]!==D||t[78]!==A||t[79]!==s||t[80]!==u?(j=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[s,u,D,A]}),t[77]=D,t[78]=A,t[79]=s,t[80]=u,t[81]=j):j=t[81];let M;t[82]===n.policySiteSection?M=t[83]:(M=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[82]=n.policySiteSection,t[83]=M);let N;t[84]===n.policySiteSectionHint?N=t[85]:(N=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[84]=n.policySiteSectionHint,t[85]=N);let ne;t[86]!==M||t[87]!==N?(ne=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[M,N]}),t[86]=M,t[87]=N,t[88]=ne):ne=t[88];let P;t[89]===i?P=t[90]:(P=e=>i({siteEnabled:e.target.checked}),t[89]=i,t[90]=P);let F;t[91]!==r.siteEnabled||t[92]!==P?(F=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:P}),t[91]=r.siteEnabled,t[92]=P,t[93]=F):F=t[93];let I;t[94]!==n.policySiteEnabled||t[95]!==F?(I=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[F,n.policySiteEnabled]}),t[94]=n.policySiteEnabled,t[95]=F,t[96]=I):I=t[96];let re=!r.siteEnabled,L;t[97]===i?L=t[98]:(L=e=>i({siteDefaultTtlHours:e}),t[97]=i,t[98]=L);let R;t[99]!==r.siteDefaultTtlHours||t[100]!==n.policySiteDefaultTtlHint||t[101]!==n.policySiteDefaultTtlHours||t[102]!==re||t[103]!==L?(R=(0,Q.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:re,onChange:L}),t[99]=r.siteDefaultTtlHours,t[100]=n.policySiteDefaultTtlHint,t[101]=n.policySiteDefaultTtlHours,t[102]=re,t[103]=L,t[104]=R):R=t[104];let ie=!r.siteEnabled,z;t[105]===i?z=t[106]:(z=e=>i({siteMaxTtlDays:e}),t[105]=i,t[106]=z);let ae;t[107]!==r.siteMaxTtlDays||t[108]!==n.policySiteMaxTtlDays||t[109]!==n.policySiteMaxTtlHint||t[110]!==ie||t[111]!==z?(ae=(0,Q.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:ie,onChange:z}),t[107]=r.siteMaxTtlDays,t[108]=n.policySiteMaxTtlDays,t[109]=n.policySiteMaxTtlHint,t[110]=ie,t[111]=z,t[112]=ae):ae=t[112];let B=!r.siteEnabled,oe;t[113]===i?oe=t[114]:(oe=e=>i({maxActiveSites:e}),t[113]=i,t[114]=oe);let se;t[115]!==r.maxActiveSites||t[116]!==n.policyMaxActiveSites||t[117]!==n.policyMaxActiveSitesHint||t[118]!==B||t[119]!==oe?(se=(0,Q.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:B,onChange:oe}),t[115]=r.maxActiveSites,t[116]=n.policyMaxActiveSites,t[117]=n.policyMaxActiveSitesHint,t[118]=B,t[119]=oe,t[120]=se):se=t[120];let ce=!r.siteEnabled,V;t[121]===i?V=t[122]:(V=e=>i({siteMaxRootDirSizeMb:e}),t[121]=i,t[122]=V);let H;t[123]!==r.siteMaxRootDirSizeMb||t[124]!==n.policySiteMaxRootDirSizeHint||t[125]!==n.policySiteMaxRootDirSizeMb||t[126]!==ce||t[127]!==V?(H=(0,Q.jsx)($,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:ce,onChange:V}),t[123]=r.siteMaxRootDirSizeMb,t[124]=n.policySiteMaxRootDirSizeHint,t[125]=n.policySiteMaxRootDirSizeMb,t[126]=ce,t[127]=V,t[128]=H):H=t[128];let U=!r.siteEnabled,W;t[129]===i?W=t[130]:(W=e=>i({siteMaxFileCount:e}),t[129]=i,t[130]=W);let G;t[131]!==r.siteMaxFileCount||t[132]!==n.policySiteMaxFileCount||t[133]!==n.policySiteMaxFileCountHint||t[134]!==U||t[135]!==W?(G=(0,Q.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:U,onChange:W}),t[131]=r.siteMaxFileCount,t[132]=n.policySiteMaxFileCount,t[133]=n.policySiteMaxFileCountHint,t[134]=U,t[135]=W,t[136]=G):G=t[136];let K;t[137]!==R||t[138]!==ae||t[139]!==se||t[140]!==H||t[141]!==G?(K=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[R,ae,se,H,G]}),t[137]=R,t[138]=ae,t[139]=se,t[140]=H,t[141]=G,t[142]=K):K=t[142];let q;t[143]!==ne||t[144]!==I||t[145]!==K?(q=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[ne,I,K]}),t[143]=ne,t[144]=I,t[145]=K,t[146]=q):q=t[146];let le;return t[147]!==j||t[148]!==q?(le=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[j,q]}),t[147]=j,t[148]=q,t[149]=le):le=t[149],le}function $(e){let t=(0,ue.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,d;t[0]!==n||t[1]!==r?(d=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=u(ve(),`max-w-xs font-mono text-xs`),t[3]=f):f=t[3];let p;t[4]!==s||t[5]!==o||t[6]!==l?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==p||t[13]!==a?(m=(0,Q.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:f,value:a,onChange:p}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=p,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==d||t[18]!==m||t[19]!==h?(g=(0,Q.jsxs)(`div`,{children:[d,m,h]}),t[17]=d,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function xe(e){let t=(0,ue.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let d;t[7]!==i||t[8]!==a||t[9]!==r?(d=r.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,Q.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=d):d=t[10];let f;t[11]===d?f=t[12]:(f=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d}),t[11]=d,t[12]=f);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=u(ve(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===s?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Q.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==c||t[21]!==l||t[22]!==f||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,f,g]}),t[20]=c,t[21]=l,t[22]=f,t[23]=g,t[24]=_):_=t[24],_}function Se(e){let t=(0,ue.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,sessionKey:f,agentId:p}=e,_=c===void 0?`any`:c,v=m(g(Te)),w=v.workspace,T=v.sharesSettings,E=oe(we),{data:D}=te(h(Ce)?`picker-agents-list`:null,N),O;bb0:{let e;t[0]===p?e=t[1]:(e=p?.trim(),t[0]=p,t[1]=e);let n=e;if(n){O=n;break bb0}let r;t[2]===E?r=t[3]:(r=E.trim(),t[2]=E,t[3]=r);let i=r;if(i){O=i;break bb0}if(D?.defaultId){O=D.defaultId;break bb0}if(D?.agents?.[0]?.id){O=D.agents[0].id;break bb0}O=``}let A=O,[F,I]=(0,J.useState)(A),L,R;t[4]===A?(L=t[5],R=t[6]):(L=()=>{I(A)},R=[A],t[4]=A,t[5]=L,t[6]=R),(0,J.useEffect)(L,R);let{tree:ie,loading:z,error:ae,loadRoot:B,loadChildren:se,reset:ce}=re(F,f??null),V;t[7]===a?V=t[8]:(V=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=V);let[H,U]=(0,J.useState)(V),W;t[9]!==a||t[10]!==B||t[11]!==n||t[12]!==ce||t[13]!==U?(W=()=>{if(!n){ce(),U(a?{path:a,isDirectory:!1}:null);return}B()},t[9]=a,t[10]=B,t[11]=n,t[12]=ce,t[13]=U,t[14]=W):W=t[14];let G;t[15]!==a||t[16]!==B||t[17]!==n||t[18]!==F||t[19]!==ce||t[20]!==f?(G=[n,F,f,B,ce,a],t[15]=a,t[16]=B,t[17]=n,t[18]=F,t[19]=ce,t[20]=f,t[21]=G):G=t[21],(0,J.useEffect)(W,G);let K;t[22]===se?K=t[23]:(K=e=>{se(e)},t[22]=se,t[23]=K);let q=K,le=H!==null&&(_===`any`||_===`file`&&!H.isDirectory||_===`directory`&&H.isDirectory),Y;bb1:{if(!H){Y=T.pickerHintNone;break bb1}if(_===`file`&&H.isDirectory){Y=T.pickerHintNeedsFile;break bb1}if(_===`directory`&&!H.isDirectory){Y=T.pickerHintNeedsDirectory;break bb1}Y=`${H.isDirectory?`📁`:`📄`} ${H.path}`}let de=Y,fe=D?.agents??[],X;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(y,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=u(`fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-popover outline-none`),t[25]=Z):Z=t[25];let pe;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Q.jsx)(P,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=pe):pe=t[26];let me=v.cron.refresh,he=v.cron.refresh,ge;t[27]===B?ge=t[28]:(ge=()=>void B(),t[27]=B,t[28]=ge);let _e=z&&`animate-spin`,ve;t[29]===_e?ve=t[30]:(ve=u(`size-4`,_e),t[29]=_e,t[30]=ve);let ye;t[31]===ve?ye=t[32]:(ye=(0,Q.jsx)(ne,{className:ve,"aria-hidden":!0}),t[31]=ve,t[32]=ye);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Q.jsx)(j,{className:`size-4`}),t[33]=be):be=t[33];let $;t[34]!==ae||t[35]!==w.loadError?($=ae?(0,Q.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[w.loadError,`: `,ae]}):null,t[34]=ae,t[35]=w.loadError,t[36]=$):$=t[36];let xe;t[37]!==q||t[38]!==z||t[39]!==H?.path||t[40]!==U||t[41]!==w.emptyDir||t[42]!==w.title||t[43]!==ie?(xe=z&&ie.length===0?(0,Q.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Q.jsx)(l,{className:`size-4 animate-spin`}),w.title,`…`]}):(0,Q.jsx)(M,{tree:ie,selectedPath:H?.path??null,onSelectFile:e=>U({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>U({path:e,isDirectory:t}),onExpandDir:q,onAction:void 0,emptyHint:w.emptyDir}),t[37]=q,t[38]=z,t[39]=H?.path,t[40]=U,t[41]=w.emptyDir,t[42]=w.title,t[43]=ie,t[44]=xe):xe=t[44];let Se;t[45]!==$||t[46]!==xe?(Se=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[$,xe]}),t[45]=$,t[46]=xe,t[47]=Se):Se=t[47];let Ee;t[48]===de?Ee=t[49]:(Ee=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:de}),t[48]=de,t[49]=Ee);let De;t[50]===r?De=t[51]:(De=()=>r(!1),t[50]=r,t[51]=De);let Oe;t[52]!==T.cancel||t[53]!==De?(Oe=(0,Q.jsx)(d,{type:`button`,variant:`ghost`,onClick:De,children:T.cancel}),t[52]=T.cancel,t[53]=De,t[54]=Oe):Oe=t[54];let ke=!le,Ae;t[55]!==i||t[56]!==r||t[57]!==F||t[58]!==H?(Ae=()=>{H&&(i({...H,agentId:F}),r(!1))},t[55]=i,t[56]=r,t[57]=F,t[58]=H,t[59]=Ae):Ae=t[59];let je;t[60]!==T.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Q.jsx)(d,{type:`button`,disabled:ke,onClick:Ae,children:T.pickerConfirm}),t[60]=T.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Oe,je]}),t[64]=Oe,t[65]=je,t[66]=Me):Me=t[66];let Ne;return t[67]!==Ee||t[68]!==Me?(Ne=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ee,Me]}),t[67]=Ee,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Q.jsx)(C,{open:n,onOpenChange:r,children:(0,Q.jsxs)(x,{children:[X,(0,Q.jsxs)(S,{className:Z,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[pe,(0,Q.jsx)(ee,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:T.pickerTitle}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:me,"aria-label":he,disabled:z,onClick:ge,children:ye}),(0,Q.jsx)(b,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":w.close,children:be})})]}),fe.length>0?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:T.pickerAgentLabel}),(0,Q.jsx)(o,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:F,onChange:e=>{I(e.target.value),U(null)},children:fe.map(e=>(0,Q.jsxs)(s,{value:e.id,children:[k(e,v.agentsSettings),e.id===D?.defaultId?` ★`:``]},e.id))})]}):null,Se,Ne]})]})})}function Ce(e){return e.token}function we(e){return e.agentId}function Te(e){return e.language}var Ee=[`shares`,`policy`];function De(e){let t=(e??``).trim();return Ee.includes(t)?t:`shares`}function Oe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function ke(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var Ae=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function je(){let e=(0,ue.c)(24),t=g(Ne),n=m(t).sharesSettings,r=!!h(Me),[a,o]=i(),s;e[0]===a?s=e[1]:(s=De(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let u=l;if(!r)return(0,Q.jsx)(W,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},f=Ee.map(e=>({id:e,label:d[e]})),p;e[4]!==n.subtitle||e[5]!==n.title?(p=(0,Q.jsx)(U,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=p):p=e[6];let _;e[7]!==c||e[8]!==u||e[9]!==n.tabsAria||e[10]!==f?(_=(0,Q.jsx)(le,{items:f,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=c,e[8]=u,e[9]=n.tabsAria,e[10]=f,e[11]=_):_=e[11];let v;e[12]!==c||e[13]!==r||e[14]!==t||e[15]!==n?(v=c===`shares`?(0,Q.jsx)(Pe,{t:n,language:t}):(0,Q.jsx)(ye,{hasToken:r}),e[12]=c,e[13]=r,e[14]=t,e[15]=n,e[16]=v):v=e[16];let y;e[17]!==c||e[18]!==v?(y=(0,Q.jsx)(G,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[17]=c,e[18]=v,e[19]=y):y=e[19];let b;return e[20]!==p||e[21]!==_||e[22]!==y?(b=(0,Q.jsxs)(W,{children:[p,_,y]}),e[20]=p,e[21]=_,e[22]=y,e[23]=b):b=e[23],b}function Me(e){return e.token}function Ne(e){return e.language}function Pe(e){let t=(0,ue.c)(60),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=te(`shares-list`,R,i),l;t[1]===a?.payload?.shares?l=t[2]:(l=a?.payload?.shares??[],t[1]=a?.payload?.shares,t[2]=l);let f=l,[p,m]=(0,J.useState)(!1),h;bb0:{if(p){h=f;break bb0}let e;t[3]===f?e=t[4]:(e=f.filter(ze),t[3]=f,t[4]=e),h=e}let g=h,_;t[5]===f?_=t[6]:(_=f.filter(Re),t[5]=f,t[6]=_);let v=_.length,y;t[7]===f?y=t[8]:(y=f.filter(Le),t[7]=f,t[8]=y);let b=y.length,x;t[9]===c?x=t[10]:(x=()=>void c(),t[9]=c,t[10]=x);let S;t[11]!==n||t[12]!==x?(S=(0,Q.jsx)(Ve,{t:n,onCreated:x}),t[11]=n,t[12]=x,t[13]=S):S=t[13];let ee=p?n.allSharesTitle:n.listTitle,C;t[14]===v?C=t[15]:(C=v>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[14]=v,t[15]=C);let w;t[16]!==ee||t[17]!==C?(w=(0,Q.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[ee,C]}),t[16]=ee,t[17]=C,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=()=>void c(),t[19]=c,t[20]=T);let E=s&&`animate-spin`,D;t[21]===E?D=t[22]:(D=u(`size-3.5`,E),t[21]=E,t[22]=D);let O;t[23]===D?O=t[24]:(O=(0,Q.jsx)(ne,{className:D}),t[23]=D,t[24]=O);let k;t[25]!==s||t[26]!==T||t[27]!==O?(k=(0,Q.jsx)(d,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:T,disabled:s,children:O}),t[25]=s,t[26]=T,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==b||t[30]!==p||t[31]!==n.hideExpired||t[32]!==n.showExpired?(A=b>0&&(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Ie),children:p?n.hideExpired:n.showExpired}),t[29]=b,t[30]=p,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=A):A=t[33];let j;t[34]!==k||t[35]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k,A]}),t[34]=k,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==w||t[38]!==j?(M=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[w,j]}),t[37]=w,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==a||t[41]!==o||t[42]!==g||t[43]!==s||t[44]!==r||t[45]!==c||t[46]!==n?(N=s&&!a?(0,Q.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Fe)}):o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Q.jsx)(`span`,{children:n.error}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):g.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,Q.jsx)(Ue,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[40]=a,t[41]=o,t[42]=g,t[43]=s,t[44]=r,t[45]=c,t[46]=n,t[47]=N):N=t[47];let P;t[48]!==b||t[49]!==c||t[50]!==p||t[51]!==n?(P=b>0&&p&&(0,Q.jsx)(We,{t:n,onCleaned:()=>void c()}),t[48]=b,t[49]=c,t[50]=p,t[51]=n,t[52]=P):P=t[52];let F;t[53]!==M||t[54]!==N||t[55]!==P?(F=(0,Q.jsxs)(q,{children:[M,N,P]}),t[53]=M,t[54]=N,t[55]=P,t[56]=F):F=t[56];let I;return t[57]!==F||t[58]!==S?(I=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,F]}),t[57]=F,t[58]=S,t[59]=I):I=t[59],I}function Fe(e,t){return(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(D,{className:`h-4 w-2/3`}),(0,Q.jsx)(D,{className:`mt-2 h-3 w-1/2`})]}),(0,Q.jsx)(D,{className:`h-7 w-20 rounded-md`})]})},t)}function Ie(e){return!e}function Le(e){return e.expired||e.revoked}function Re(e){return!e.expired&&!e.revoked}function ze(e){return!e.expired&&!e.revoked}var Be={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function Ve({t:e,onCreated:t}){let[n,r]=(0,J.useReducer)(E,Be),{expanded:i,path:a,isDirectory:c,agentId:f,ttlMs:p,maxViews:m,description:h,directoryMode:g,creating:_,result:v,errorMsg:y,resultDialogOpen:b,pickerOpen:x}=n,S=(0,J.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await V({path:a.trim(),ttlMs:p,maxViews:m,description:h.trim()||void 0,...f?{agentId:f}:{},...c?{kind:`directory`,directoryMode:g}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,c,f,p,m,h,g,t]),ee=(0,J.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Q.jsxs)(q,{children:[(0,Q.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:u(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:c?`📁`:`📄`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,Q.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Q.jsxs)(d,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Q.jsx)(A,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),c?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Q.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:g,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Q.jsx)(s,{value:`browse`,children:e.directoryModeBrowse}),(0,Q.jsx)(s,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Q.jsx)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:p,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Ae.map(t=>(0,Q.jsx)(s,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Q.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:m??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Q.jsx)(s,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Q.jsx)(s,{value:`1`,children:`1`}),(0,Q.jsx)(s,{value:`5`,children:`5`}),(0,Q.jsx)(s,{value:`10`,children:`10`}),(0,Q.jsx)(s,{value:`50`,children:`50`}),(0,Q.jsx)(s,{value:`100`,children:`100`})]})]})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Q.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:h,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsxs)(d,{type:`button`,disabled:_||!a.trim(),onClick:()=>void S(),children:[_?(0,Q.jsx)(l,{className:`size-4 animate-spin`}):(0,Q.jsx)(F,{className:`size-4`}),_?e.creating:e.createButton]}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,onClick:()=>{ee(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),y&&(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y})]}),(0,Q.jsx)(z,{open:b,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:v}),(0,Q.jsx)(Se,{open:x,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,Q.jsxs)(d,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Q.jsx)(F,{className:`size-4`}),e.createTitle]})}var He={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Ue({share:e,t,language:n,onRevoked:r,onExtended:i}){let[o,s]=(0,J.useReducer)(E,He),{revokeOpen:f,revoking:m,linksOpen:h,urlCopied:g,copyFailed:_,extending:v}=o,y=!e.expired&&!e.revoked,b=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,x=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,S=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await ce(e.id),r()}catch{}finally{s({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),ee=(0,J.useCallback)(async()=>{if(s({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await p(e.shareUrl)){s({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{copyFailed:!1}}),2500);return}s({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),C=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{extending:!0}});try{await L(e.id,864e5),i()}catch{}finally{s({type:`patch`,patch:{extending:!1}})}},[e.id,i]),te=`share-links-${e.id}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:u(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":h,"aria-controls":te,onClick:()=>s({type:`patch`,patch:{linksOpen:!h}}),children:[(0,Q.jsx)(O,{className:u(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,h?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),(0,Q.jsx)(A,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:u(`text-xs font-medium`,x),children:b})]}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.workspaceRelativePath}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:Oe(e.fileSize)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(H,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:ke(e.expiresAt,n)]}),(0,Q.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Q.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:y&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void ee(),children:g?(0,Q.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(c,{className:`size-3.5`})}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void C(),disabled:v,title:t.extend,children:v?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(H,{className:`size-3.5`})}),(0,Q.jsx)(d,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>s({type:`patch`,patch:{revokeOpen:!0}}),disabled:m,children:m?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(se,{className:`size-3.5`})})]})})]}),y&&h?(0,Q.jsxs)(`div`,{id:te,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Q.jsx)(ie,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),_?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(B,{reachability:e.reachability})})]}):null]}),(0,Q.jsx)(I,{open:f,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void S(),onCancel:()=>s({type:`patch`,patch:{revokeOpen:!1}})})]})}function We({t:e,onCleaned:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),o=(0,J.useCallback)(async()=>{r(!1),a(!0);try{await ae(),t()}catch{}finally{a(!1)}},[t]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsxs)(d,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(se,{className:`size-3.5`}),e.cleanExpired]})}),(0,Q.jsx)(I,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{je as SharesSettingsPanel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{o as t,r as n}from"./locale-store-xULEcFVs.js";import{Un as r}from"./index-CGbKTCST.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as s,r as c}from"./popover-select-BzdnTy3h.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./cn-JdwAhgNB.js";import{t as d}from"./button-CSEbl4zT.js";import{l as f,n as ee}from"./locale-store-xULEcFVs.js";import{i as te,n as p,o as ne,r as re,s as m,t as ie}from"./dist-BPoKqzeH.js";import{$c as ae,A as h,Aa as g,B as _,Ci as v,G as oe,H as y,Jr as se,Ko as b,M as ce,Si as x,Sl as S,Us as C,Ut as le,Va as w,W as T,Wc as E,Wl as D,Wt as ue,Yi as O,Ys as k,ai as A,cr as j,dr as M,fa as de,hl as N,ii as P,ka as fe,lr as pe,ml as me,n as he,oc as ge,pr as _e,ur as ve}from"./index-CGbKTCST.js";import{t as ye}from"./date-picker-D4zCUQJL.js";import{t as be}from"./dependency-picker-DpQAxS2k.js";var F=e(t(),1),I=n();function xe(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Se(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`,`delegateAgentId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}var L=r();function Ce(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function we(){let e=(0,I.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,L.jsx)(g,{className:`h-32 rounded-2xl`}),(0,L.jsx)(g,{className:`h-52 rounded-2xl`}),(0,L.jsx)(g,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Te(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Ee(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var De=`xopc.taskDetail.chatPanelPercent`,R=42;function Oe(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?R:Math.min(r,Math.max(n,e))}function ke(){try{let e=Number(window.localStorage.getItem(De));return Number.isFinite(e)&&e>=30&&e<=60?e:R}catch{return R}}function Ae(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`paused`:e.operationalState}function z(e){let t=(0,I.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,L.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let a;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>{let t=i?.get(e)??`unverified`;return(0,L.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,L.jsx)(t===`passed`?S:t===`failed`?N:me,{className:t===`passed`?`mt-1 size-4 shrink-0 text-success`:t===`failed`?`mt-1 size-4 shrink-0 text-danger`:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,L.jsx)(`span`,{children:e})]},e)},t[5]=i,t[6]=e),a=n.map(e),t[2]=n,t[3]=i,t[4]=a}else a=t[4];let o;return t[7]===a?o=t[8]:(o=(0,L.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function B({taskId:e,presentation:t,backgroundPath:n}){let[r]=a(),i=ee(e=>e.language),te=f(e=>e.token),p=(0,F.useMemo)(()=>oe(i),[i]),ne=w(e=>e.setPageHeader),re=w(e=>e.clearPageHeader),{data:m,error:ie,mutate:g,lastChange:b}=h(e),[ue,A]=(0,F.useState)(null),[N,P]=(0,F.useState)(!1),[me,I]=(0,F.useState)([]),[B,je]=(0,F.useState)(null),[Me,Ne]=(0,F.useState)([]),[Pe,V]=(0,F.useState)(!1),[Fe,H]=(0,F.useState)(``),[Ie,U]=(0,F.useState)(!1),[W,G]=(0,F.useState)(``),[K,Le]=(0,F.useState)(ke),[Re,ze]=(0,F.useState)(!1),Be=(0,F.useRef)(null),Ve=(0,F.useRef)(!1),He=(0,F.useRef)(!1),Ue=(0,F.useRef)(``),We=(0,F.useRef)(null),Ge=(0,F.useRef)(null),Ke=(0,F.useRef)(null),[qe,q]=(0,F.useState)(null),[Je,Ye]=(0,F.useState)(null),Xe=m?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Ze=(0,F.useMemo)(()=>x(r.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[r]);(0,F.useEffect)(()=>{A(null),q(null),V(!1),U(!1),Ye(null)},[e]),(0,F.useEffect)(()=>{let e=!0;return fe().then(t=>{e&&Ne(t.items)}).catch(()=>void 0),()=>{e=!1}},[te]),(0,F.useEffect)(()=>{if(!b||b.source===`user`)return;Ye(b);let e=window.setTimeout(()=>Ye(null),3500);return()=>window.clearTimeout(e)},[b]),(0,F.useEffect)(()=>{let t=m?.task.projectId,n=m?.dependencies??[];if(!t){Ke.current=null,je(null),I(n);return}Ke.current!==t&&(Ke.current=t,je(null));let r=!0;return de(t).then(t=>{if(!r)return;je(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});I([...i.values()])}).catch(()=>{r&&I(n)}),()=>{r=!1}},[Xe,m?.task.projectId,e]);let J=async t=>{if(m){P(!0),A(null);try{await g(await ce(e,t,m.task.version),{revalidate:!1})}catch{A(p.actionFailed)}finally{P(!1)}}},Y=async t=>{if(!m)return!1;P(!0),A(null);try{return await g(y(e,t,m.task.version),{optimisticData:Se(m,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return A(p.actionFailed),!1}finally{P(!1)}},Qe=async()=>{if(!m)return;if(Ve.current){Ve.current=!1;return}let e=Fe.trim(),t=We.current;if(xe(t,m.task.version,m.task.title,e)){q(`title`);return}if(!e||e===m.task.title){H(m.task.title),V(!1);return}await Y({title:e})&&(q(null),V(!1))},$e=async()=>{if(!m)return;if(He.current){He.current=!1;return}let e=W.trim(),t=Ge.current;if(xe(t,m.task.version,m.task.body??``,e)){q(`description`);return}if(W===Ue.current||e===(m.task.body??``).trim()){U(!1);return}await Y({body:e||null})&&(q(null),U(!1))},et=async e=>{if(!(!m||e===m.task.phase)){if(m.task.phase===`closed`){await J({type:`reopen`,phase:e===`closed`?`ready`:e});return}if(e===`closed`){await J({type:`close`,resolution:`done`});return}await J({type:`move`,phase:e})}},X=(0,F.useCallback)(e=>{Le(e);try{window.localStorage.setItem(De,String(e))}catch{}},[]),tt=(0,F.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=Be.current?.clientWidth??0;X(Oe(e.key===`Home`?R:K+(e.key===`ArrowLeft`?2:-2),t))},[K,X]),nt=(0,F.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=Be.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),ze(!0);let i=K,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=Oe((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}ze(!1),X(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[K,X]),rt=async t=>{if(m){P(!0),A(null);try{await g(await T(e,t,m.task.version),{revalidate:!1})}catch{A(p.dependencyUpdateFailed)}finally{P(!1)}}};if((0,F.useLayoutEffect)(()=>{if(t!==`modal`)return ne({startExtra:(0,L.jsx)(o,{to:Ze,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":p.backToWork,children:(0,L.jsx)(D,{className:`size-4`})}),main:m?(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:B?`${B} / ${p.taskLabel}`:p.taskLabel}),(0,L.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p.detailStatuses[Ae(m)]})]}):null,end:null}),re},[re,p.backToWork,p.detailStatuses,p.taskLabel,m,t,B,Ze,ne]),ie&&!m)return(0,L.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:p.taskNotFound});if(!m)return(0,L.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,L.jsx)(we,{})});let it=m.waits[0],at=it?.kind===`paused`?it:void 0,Z=m.receipts[0],ot=p.detailStatuses[Ae(m)],st=p.detailStatusDescriptions[Ae(m)],ct=m.task.body?.trim()||m.task.contract?.objective.trim(),lt=new Map(Z?.verification.checks.map(e=>[e.criterion,e.status])),ut=m.allowedCommands.includes(`mark_ready`),dt=m.allowedCommands.includes(`start`),ft=m.allowedCommands.includes(`add_wait`),pt=m.task.phase===`review`&&m.allowedCommands.includes(`close`),mt=m.allowedCommands.includes(`reopen`),ht=m.runs.find(e=>e.sessionKey)?.sessionKey??m.context.find(e=>e.targetKind===`session`)?.targetId,gt=m.runs.find(e=>typeof e.executorRef.agentId==`string`)?.executorRef.agentId,_t=m.task.delegateAgentId??(typeof gt==`string`?gt:void 0)??m.task.ownerId,vt=Me.find(e=>e.id===_t),yt=m.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Q=m.task.contract?.acceptanceCriteria??[],bt=Q.filter(e=>lt.get(e)===`passed`).length,xt=m.task.contract?.expectedOutputs??[],St=m.task.contract?.constraints??[],Ct=m.task.contract?.approvalRequired??[],wt=m.task.contract?.assumptions??[],Tt=m.task.contract?.risks??[],$=(...e)=>!!Je?.changedFields.some(t=>e.includes(t)),Et=e=>t===`modal`&&n?le(n,e):v(`/tasks/${e}`,Ze),Dt=m.allowedCommands.includes(`move`),Ot=e=>e!==m.task.phase&&(e===`closed`?!pt:m.task.phase===`closed`?!mt:!Dt),kt=(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ut?(0,L.jsxs)(d,{variant:`primary`,disabled:N,onClick:()=>void J({type:`mark_ready`}),children:[(0,L.jsx)(C,{className:`size-4`}),p.scheduleTask]}):null,at?(0,L.jsxs)(d,{variant:`primary`,disabled:N,onClick:()=>void J({type:`resolve_wait`,waitId:at.id}),children:[(0,L.jsx)(C,{className:`size-4`}),p.resumeTask]}):null,!it&&dt?(0,L.jsxs)(d,{variant:`primary`,disabled:N,onClick:()=>void J({type:`start`,executor:{kind:`agent`,agentId:m.task.delegateAgentId??`main`}}),children:[(0,L.jsx)(C,{className:`size-4`}),p.runTask]}):null,pt?(0,L.jsxs)(d,{variant:`primary`,disabled:N,onClick:()=>void J({type:`close`,resolution:`done`}),children:[(0,L.jsx)(S,{className:`size-4`}),p.approveTask]}):null,mt?(0,L.jsxs)(d,{variant:`primary`,disabled:N,onClick:()=>void J({type:`reopen`,phase:`ready`}),children:[(0,L.jsx)(C,{className:`size-4`}),p.reopenTask]}):null,!it&&ft?(0,L.jsxs)(d,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:N,onClick:()=>void J({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,L.jsx)(k,{className:`size-4`}),p.pauseTask]}):null,m.task.phase===`closed`?null:(0,L.jsxs)(M,{children:[(0,L.jsx)(_e,{asChild:!0,children:(0,L.jsx)(d,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:N,"aria-label":p.moreActions,children:(0,L.jsx)(ae,{className:`size-4`,"aria-hidden":!0})})}),(0,L.jsx)(ve,{children:(0,L.jsx)(j,{align:`end`,sideOffset:6,className:`z-[100] min-w-40 rounded-lg bg-surface-elevated p-1 shadow-lg`,children:(0,L.jsx)(pe,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void J({type:`close`,resolution:`cancelled`}),children:p.cancelTask})})})]})]});return(0,L.jsxs)(`div`,{ref:Be,className:`${t===`modal`?`flex h-full min-h-0 flex-col lg:flex-row`:`flex min-h-[calc(100dvh-8rem)] flex-col overflow-hidden lg:flex-row`} ${Re?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${K}%`},children:[(0,L.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,L.jsxs)(`header`,{className:u(`px-4 pb-5`,$(`title`)&&`task-detail-live-update`),children:[(0,L.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[B?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,L.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),B]}):null,(0,L.jsx)(`span`,{children:`/`}),(0,L.jsx)(`span`,{children:p.taskLabel}),Je?(0,L.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:Je.source===`agent`?i===`zh`?`Agent 刚刚更新`:`Updated by Agent`:i===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Pe?(0,L.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:Fe,onChange:e=>H(e.target.value),onBlur:()=>void Qe(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Ve.current=!0,H(m.task.title),V(!1),queueMicrotask(()=>{Ve.current=!1}))},className:`mt-3 w-full max-w-3xl rounded-lg bg-surface-hover px-3 py-2 text-2xl font-semibold leading-8 text-fg outline-none ring-2 ring-accent/30 focus:ring-accent/60`}):(0,L.jsx)(`button`,{type:`button`,className:`mt-3 block max-w-3xl rounded-lg text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{We.current={value:m.task.title,version:m.task.version},q(null),H(m.task.title),V(!0)},children:(0,L.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:m.task.title})}),qe===`title`?(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,L.jsx)(`span`,{children:i===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{H(m.task.title),q(null),V(!1)},children:i===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({title:Fe.trim()}).then(e=>{e&&(q(null),V(!1))}),children:i===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),ue?(0,L.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:ue}):null]}),(0,L.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,L.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,L.jsxs)(`section`,{className:u(`rounded-xl bg-surface-panel p-4`,$(`body`)&&`task-detail-live-update`),children:[(0,L.jsx)(`h2`,{className:`font-medium text-fg`,children:p.taskDescription}),Ie?(0,L.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:W,onChange:e=>G(e.target.value),onBlur:()=>void $e(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),He.current=!0,G(m.task.body??m.task.contract?.objective??``),U(!1),queueMicrotask(()=>{He.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,L.jsx)(`button`,{type:`button`,className:`-mx-1 mt-2 block w-[calc(100%+0.5rem)] rounded-lg px-1 py-1 text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=m.task.body??m.task.contract?.objective??``;Ue.current=e,Ge.current={value:m.task.body??``,version:m.task.version},q(null),G(e),U(!0)},children:(0,L.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:ct&&ct!==m.task.title?ct:p.noTaskDescription})}),qe===`description`?(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,L.jsx)(`span`,{children:i===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{G(m.task.body??``),q(null),U(!1)},children:i===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({body:W.trim()||null}).then(e=>{e&&(q(null),U(!1))}),children:i===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),m.attention.length>0?(0,L.jsxs)(`section`,{className:u(`rounded-xl bg-warning/10 p-4`,$(`attention`)&&`task-detail-live-update`),children:[(0,L.jsx)(`h3`,{className:`font-medium text-fg`,children:yt?p.needsAttention:p.waitingStatus}),(0,L.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:m.attention.map((e,t)=>(0,L.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,L.jsxs)(`section`,{className:u(`rounded-xl bg-surface-panel p-4`,$(`contract`)&&`task-detail-live-update`),children:[(0,L.jsx)(`h2`,{className:`font-medium text-fg`,children:p.taskDefinition}),(0,L.jsxs)(`div`,{className:`mt-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:p.successDefinition}),Q.length>0?(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:p.criteriaProgress.replace(`{{verified}}`,String(bt)).replace(`{{total}}`,String(Q.length))}):null]}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(z,{items:Q,empty:p.noDefinition,verificationByCriterion:lt})})]}),xt.length>0?(0,L.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:p.expectedOutputs}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(z,{items:xt,empty:p.noDefinition})})]}):null,St.length>0?(0,L.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:p.constraints}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(z,{items:St,empty:p.noDefinition})})]}):null,Ct.length>0?(0,L.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:p.approvalRequired}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(z,{items:Ct,empty:p.noDefinition})})]}):null,wt.length>0?(0,L.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:p.contextAssumptions}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(z,{items:wt,empty:p.noDefinition})})]}):null,Tt.length>0?(0,L.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:p.contextRisks}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(z,{items:Tt,empty:p.noDefinition})})]}):null]}),Z?(0,L.jsxs)(`section`,{className:u(`rounded-xl bg-surface-panel p-4`,$(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`font-medium text-fg`,children:p.latestResult}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg`,children:Z.summary})]}),(0,L.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[p.receiptStatuses[Z.status],` · `,p.verificationStatuses[Z.verification.status]]})]}),Z.remainingWork.length>0?(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:p.remainingWork}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(z,{items:Z.remainingWork,empty:p.noRemainingWork})})]}):null,Z.nextAction?(0,L.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:p.nextAction}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Z.nextAction})]}):null,(0,L.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(d,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void _(Z.runId,`helpful`),children:p.doneWell}),(0,L.jsx)(d,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void _(Z.runId,`not_helpful`),children:p.needsFix}),Z.evidence.filter(e=>e.uri).map(e=>(0,L.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,L.jsx)(l,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),m.receipts.length>1?(0,L.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:p.executionHistory.replace(`{{count}}`,String(m.receipts.length-1))}),(0,L.jsx)(`div`,{className:`mt-3 space-y-3`,children:m.receipts.slice(1).map(e=>(0,L.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,L.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:p.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,m.context.length>0?(0,L.jsxs)(`section`,{className:u(`rounded-xl bg-surface-panel p-4`,$(`context`)&&`task-detail-live-update`),children:[(0,L.jsx)(`h2`,{className:`font-medium text-fg`,children:p.contextUsed}),(0,L.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:m.context.map(e=>(0,L.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[p.contextRoleLabels[e.role],` · `,p.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,L.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,L.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,L.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,L.jsxs)(`section`,{className:u(`rounded-xl bg-surface-subtle p-4`,$(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,L.jsx)(`h2`,{className:`font-medium text-fg`,children:p.taskProperties}),(0,L.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,L.jsx)(`span`,{children:p.taskPhase}),(0,L.jsx)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:m.task.phase,disabled:N,onChange:e=>void et(e.target.value),children:[`backlog`,`ready`,`active`,`review`,`closed`].map(e=>(0,L.jsx)(c,{value:e,disabled:Ot(e),children:Ce(e,i)},e))})]}),(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,L.jsx)(`span`,{children:p.priority}),(0,L.jsx)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:m.task.priority,disabled:N,onChange:e=>void Y({priority:e.target.value}),children:[`low`,`normal`,`high`,`critical`].map(e=>(0,L.jsx)(c,{value:e,children:p.priorityLabels[e]},e))})]}),(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,L.jsx)(`span`,{children:p.dueDate}),(0,L.jsx)(ye,{disabled:N,value:Te(m.task.dueAt),onChange:e=>void Y({dueAt:Ee(e)}),ariaLabel:p.dueDate})]}),(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[(0,L.jsx)(`span`,{children:p.executorLabel}),(0,L.jsxs)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:m.task.delegateAgentId??``,disabled:N,onChange:e=>void Y({delegateAgentId:e.target.value||null}),children:[(0,L.jsx)(c,{value:``,children:p.unassigned}),Me.map(e=>(0,L.jsx)(c,{value:e.id,children:e.name||e.id},e.id))]})]}),B?(0,L.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,L.jsx)(`span`,{children:p.projectLabel}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,L.jsx)(E,{className:`size-3.5`}),B]})]}):null]}),(0,L.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,L.jsx)(`p`,{children:ot}),(0,L.jsx)(`p`,{children:st}),(0,L.jsx)(`p`,{className:`mt-2`,children:p.updatedAt.replace(`{{date}}`,se(m.task.updatedAt,i))})]})]}),(0,L.jsxs)(`section`,{className:u(`rounded-xl bg-surface-panel p-4`,$(`dependencies`)&&`task-detail-live-update`),children:[(0,L.jsx)(`h2`,{className:`font-medium text-fg`,children:p.taskRelations}),(0,L.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:p.dependencies}),(0,L.jsx)(be,{borderless:!0,candidates:me,selectedIds:m.dependencies.map(e=>e.id),disabled:N,onChange:e=>void rt(e),labels:{link:p.linkDependencies,linked:p.linkedDependencies,searchPlaceholder:p.dependencySearchPlaceholder,noMatches:p.noDependencyMatches,noCandidates:p.noDependencyCandidates,remove:p.removeDependency}})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:p.dependents}),m.dependents.length>0?(0,L.jsx)(`div`,{className:`space-y-1.5`,children:m.dependents.map(e=>(0,L.jsx)(o,{to:Et(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,L.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:p.noDependents})]})]})]})]})]})]}),(0,L.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(K),tabIndex:0,onPointerDown:nt,onKeyDown:tt,onDoubleClick:()=>X(R),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${Re?`bg-surface-hover`:``}`,children:(0,L.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,L.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:shrink-0`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,L.jsx)(`div`,{className:`min-w-0`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,L.jsx)(O,{agentId:_t??`main`,avatar:vt?.avatar,size:28,className:`shrink-0`}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:i===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,L.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[vt?.name??_t??p.unassigned,` · `,ot]})]})]})}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[kt,ht?(0,L.jsx)(d,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,L.jsxs)(o,{to:`/chat/${encodeURIComponent(ht)}`,children:[(0,L.jsx)(l,{className:`size-3.5`}),i===`zh`?`全屏`:`Full screen`]})}):null]})]}),ht?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,L.jsx)(he,{embedded:!0,sessionKey:ht})}):(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(ge,{className:`mx-auto size-8 text-fg-subtle`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,L.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:i===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]})}function je(){let e=(0,I.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,L.jsx)(B,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function Me(e){let t=(0,I.c)(43),{taskId:n,backgroundPath:r,onClose:i}=e,a=ee(W),o=A(U),s=A(Ie),c=A(H),l=P(Fe),u=P(V),d=o?s:0,f;t[0]!==i||t[1]!==u?(f=e=>{e||(u(null),i())},t[0]=i,t[1]=u,t[2]=f):f=t[2];let ae=a===`zh`?`关闭任务详情`:`Close task details`,h;t[3]!==i||t[4]!==u?(h=()=>{u(null),i()},t[3]=i,t[4]=u,t[5]=h):h=t[5];let g;t[6]!==ae||t[7]!==h?(g=(0,L.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":ae,onClick:h}),t[6]=ae,t[7]=h,t[8]=g):g=t[8];let _=o?`true`:`false`,v=`${d/2}px`,oe=`${d}px`,y;t[9]!==v||t[10]!==oe?(y={"--task-detail-workspace-offset":v,"--task-detail-workspace-width":oe},t[9]=v,t[10]=oe,t[11]=y):y=t[11];let se=y,ce=a===`zh`?`任务详情`:`Task details`,x;t[12]===ce?x=t[13]:(x=(0,L.jsx)(m,{className:`font-medium text-fg`,children:ce}),t[12]=ce,t[13]=x);let S=a===`zh`?`查看并操作任务详情`:`View and manage task details`,C;t[14]===S?C=t[15]:(C=(0,L.jsx)(te,{className:`sr-only`,children:S}),t[14]=S,t[15]=C);let le=a===`zh`?`关闭任务详情`:`Close task details`,w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,L.jsx)(b,{className:`size-4`,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]===le?T=t[18]:(T=(0,L.jsx)(p,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":le,children:w}),t[17]=le,t[18]=T);let E;t[19]!==x||t[20]!==C||t[21]!==T?(E=(0,L.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[x,C,T]}),t[19]=x,t[20]=C,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==r||t[24]!==n?(D=(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,L.jsx)(B,{taskId:n,presentation:`modal`,backgroundPath:r})}),t[23]=r,t[24]=n,t[25]=D):D=t[25];let O;t[26]!==E||t[27]!==D||t[28]!==_||t[29]!==se?(O=(0,L.jsxs)(re,{className:`task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl bg-surface-base shadow-float focus:outline-none`,"data-workspace-panel-open":_,style:se,onEscapeKeyDown:Pe,onInteractOutside:Ne,children:[E,D]}),t[26]=E,t[27]=D,t[28]=_,t[29]=se,t[30]=O):O=t[30];let k;t[31]!==l||t[32]!==o||t[33]!==s||t[34]!==c?(k=l?(0,L.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:o?s:0},children:(0,L.jsx)(ue,{allowOutsideChat:!0,sessionKey:c??void 0})}):null,t[31]=l,t[32]=o,t[33]=s,t[34]=c,t[35]=k):k=t[35];let j;t[36]!==O||t[37]!==k||t[38]!==g?(j=(0,L.jsxs)(ne,{children:[g,O,k]}),t[36]=O,t[37]=k,t[38]=g,t[39]=j):j=t[39];let M;return t[40]!==f||t[41]!==j?(M=(0,L.jsx)(ie,{modal:!1,open:!0,onOpenChange:f,children:j}),t[40]=f,t[41]=j,t[42]=M):M=t[42],M}function Ne(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Pe(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function V(e){return e.setPath}function Fe(e){return e.path}function H(e){return e.sessionKeyOverride}function Ie(e){return e.widthPx}function U(e){return e.open}function W(e){return e.language}export{Me as TaskDetailModal,je as TaskDetailPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{f as r,l as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,t as ee}from"./working-directory-picker-modal-D-IgcHPp.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as te}from"./cn-JdwAhgNB.js";import{t as c}from"./button-CSEbl4zT.js";import{t as l}from"./messages-3qRsLZuX.js";import{n as ne}from"./locale-store-xULEcFVs.js";import{$a as u,Aa as d,Dl as re,Ga as ie,Ha as f,Ja as ae,Jc as oe,Ka as se,Ko as ce,Qa as p,Tl as le,Ua as ue,Uc as m,Wa as de,Wo as fe,Xa as pe,Ya as me,Za as he,dl as ge,eo as _e,qa as h,ws as g,zc as ve}from"./index-CGbKTCST.js";var _=e(t(),1),v=new Set([`completed`,`failed`,`canceled`]);function y(){return new Promise(e=>window.setTimeout(e,1200))}async function ye(e,t){let n=[],r=t.wait??y;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!v.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var b=new Set([`local-recent-files`,`chromium-bookmarks`,`apple-notes`,`apple-calendar`,`apple-reminders`]);function be(e){return new Set(e.filter(e=>e.availability===`available`&&b.has(e.id)).map(e=>e.id))}var x=n(),S=[`folder_structure`,`recent_progress`,`next_steps`];function C(e){return e instanceof Error?e.message:String(e)}function xe({embedded:e=!1,onRequestClose:t}={}){let n=ne(e=>e.language),v=l(n).onboarding.workDiscovery,y=l(n).chat.workingDirectory,b=i(),[xe]=r(),Se=e||xe.get(`new`)===`1`,[w,T]=(0,_.useState)(`loading`),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(!1),[M,N]=(0,_.useState)(null),[Ce,P]=(0,_.useState)(!1),[F,we]=(0,_.useState)(``),[I,Te]=(0,_.useState)(!1),[Ee,L]=(0,_.useState)(()=>new Set),[R,De]=(0,_.useState)([]),[z,B]=(0,_.useState)(()=>new Set),[Oe,V]=(0,_.useState)([]),[H,U]=(0,_.useState)(!1),[W,G]=(0,_.useState)({current:0,total:0}),[ke,Ae]=(0,_.useState)([]),[K,je]=(0,_.useState)(()=>new Set),q=(0,_.useRef)(!1),Me=e=>{je(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,_.useEffect)(()=>{let e=!1;return window.electronAPI?.understandingSources?.catalog().then(t=>{e||(Ae(t),je(be(t)))}),()=>{e=!0}},[]);let J=(0,_.useCallback)(e=>{f.getState().updateDirectoryRun(e),k(e),e.status===`completed`?(L(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),T(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?T(`error`):T(`running`)},[]),Ne=async()=>{j(!0),N(null);try{let e=await de();if(!e.length){N(v.noCandidates);return}De(e),B(new Set([e[0].rootPath])),T(`candidates`)}catch(e){N(C(e))}finally{j(!1)}},Pe=e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Fe=(0,_.useCallback)((e,t,n)=>{f.getState().updateDirectoryRun(e),k(e),G({current:t+1,total:n}),V(n=>{let r=[...n];return r[t]=e,r}),T(`running`)},[]),Ie=(0,_.useCallback)(e=>{V(t=>t.map(t=>t?.id===e.id?e:t))},[]),Le=async()=>{let e=R.filter(e=>z.has(e.rootPath));if(!e.length)return;j(!0),N(null),V([]),G({current:1,total:e.length}),U(!0),q.current=!1;let t=!1;try{let n=await ye(e,{grantDirectory:ae,startRun:p,fetchRun:h,shouldStop:()=>q.current,onRun:(e,n,r)=>{Fe(e,n,r),t||(t=!0,f.getState().collectSources(e.id,[...K]))},onError:(t,n,r)=>{G({current:r+1,total:e.length}),N(v.folderAnalysisFailed.replace(`{{folder}}`,n.displayName).replace(`{{error}}`,C(t)))}});if(q.current)return;let r=n.find(e=>e.status===`completed`)??n.at(-1);r?J(r):T(`candidates`)}catch(e){N(C(e)),T(`candidates`)}finally{U(!1),j(!1)}},Y=o({onPicked:(0,_.useCallback)(async e=>{j(!0),N(null);try{D(await me(e)),T(`consent`)}catch(e){N(C(e)),T(`intro`)}finally{j(!1)}},[])});(0,_.useEffect)(()=>{let e=!1;return se().then(async({enabled:n,state:r})=>{if(!e){if(!n){t?t():b(`/chat`,{replace:!0});return}if(!Se&&r.activeRunId)try{let t=await h(r.activeRunId);e||J(t);return}catch{}e||T(`intro`)}}).catch(t=>{e||(N(C(t)),T(`intro`))}),()=>{e=!0}},[J,b,t,Se]),(0,_.useEffect)(()=>{if(!O||w!==`running`||H)return;let e=!1,t=async()=>{try{let t=await h(O.id);e||J(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===O.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[J,H,w,O]);let Re=async()=>{j(!0);try{await ie()}finally{t?t():b(`/chat`,{replace:!0})}},ze=async()=>{if(E){j(!0),N(null),V([]),G({current:0,total:0});try{await ae(E.canonicalRootPath);let e=await p(E.canonicalRootPath);J(e),f.getState().collectSources(e.id,[...K])}catch(e){N(C(e)),T(`consent`)}finally{j(!1)}}},X=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;b(`/chat/${encodeURIComponent(e)}${n}`)},Be=e=>{k(e),P(!1),Te(!1),L(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?T(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?T(`error`):T(`running`)},Ve=async()=>{O&&(q.current=!0,J(await ue(O.id)))},Z=async(e,t)=>{if(!O)return;await he(O.id,e.id).catch(()=>{});let r=t?`${n===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${e.actionPrompt}`:e.actionPrompt;X(O.sessionKey,r)},He=async()=>{if(O){j(!0),N(null);try{let e=O.result?.profileCandidates??[],t=await u((e.length>0?await _e(O.id,e.map(e=>({id:e.id,status:Ee.has(e.id)?`accepted`:`rejected`}))):O).id,`confirmed`);k(t),Ie(t),T(`recommendation`)}catch(e){N(C(e))}finally{j(!1)}}},Q=async e=>{if(!(!O||!F.trim())){j(!0),N(null);try{let t=await u(O.id,e,F.trim());k(t),X(t.sessionKey,F.trim())}catch(e){N(C(e)),j(!1)}}},Ue=async()=>{if(O){j(!0);try{X((await u(O.id,`dismissed`)).sessionKey)}catch(e){N(C(e)),j(!1)}}},$=O?.result?.suggestions.find(e=>e.id===O.result?.primarySuggestionId)??O?.result?.suggestions[0],We=O?.result?.suggestions.filter(e=>e.id!==$?.id)??[],Ge=e=>e===`command`?v.riskCommand:e===`file_write`?v.riskFileWrite:v.riskAnalysis,Ke=Oe.filter(e=>e?.status===`completed`),qe=e&&w===`candidates`,Je=Ke.length>1?(0,x.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,x.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:v.analysisResults}),(0,x.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ke.map(e=>{let t=R.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,x.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===O?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>Be(e),children:t},e.id)})})]}):null;return(0,x.jsxs)(`div`,{className:e?`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-base`:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,x.jsxs)(`main`,{className:e?`mx-auto flex h-full min-h-0 w-full max-w-[40rem] flex-1 flex-col px-5 py-7 sm:px-8 sm:py-9 ${qe?`overflow-hidden`:`overflow-y-auto [scrollbar-gutter:stable]`}`:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[e?null:(0,x.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,x.jsx)(fe,{className:`size-11`})}),w===`loading`?(0,x.jsxs)(`div`,{className:`mx-auto flex min-h-[26rem] w-full max-w-md flex-col items-center`,"aria-busy":!0,children:[(0,x.jsx)(d,{className:`h-8 w-64 max-w-full`}),(0,x.jsx)(d,{className:`mt-4 h-4 w-full max-w-sm`}),(0,x.jsx)(d,{className:`mt-2 h-4 w-4/5 max-w-xs`}),(0,x.jsx)(d,{className:`mt-10 h-12 w-full rounded-xl`}),(0,x.jsx)(d,{className:`mt-3 h-11 w-full rounded-xl`}),(0,x.jsx)(d,{className:`mt-5 h-4 w-3/5 max-w-56`})]}):null,w===`intro`?(0,x.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,x.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,x.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:v.title}),(0,x.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:v.subtitle})]}),(0,x.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[ke.length?(0,x.jsxs)(`div`,{className:`mb-5 rounded-xl border border-edge bg-surface-panel p-3 text-left`,children:[(0,x.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.localSourcesTitle}),(0,x.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:v.localSourcesSubtitle}),(0,x.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3`,children:ke.map(e=>{let t=K.has(e.id);return(0,x.jsxs)(`button`,{type:`button`,className:te(`flex min-h-16 flex-col items-center justify-center gap-1 rounded-lg border px-2 py-2 text-xs font-medium transition-colors`,t?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":t,onClick:()=>Me(e.id),children:[(0,x.jsx)(`span`,{className:te(`flex size-4 items-center justify-center rounded-full border`,t?`border-accent bg-accent text-white`:`border-edge`),children:t?(0,x.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),e.displayName]},e.id)})})]}):null,(0,x.jsxs)(c,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void Ne(),disabled:A||Y.picking,children:[A?(0,x.jsx)(s,{className:`size-4 animate-spin`}):(0,x.jsx)(g,{className:`size-4`}),v.quickScan]}),(0,x.jsxs)(c,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:Y.pick,disabled:A||Y.picking,children:[Y.picking?(0,x.jsx)(s,{className:`size-4 animate-spin`}):(0,x.jsx)(m,{className:`size-4`}),v.chooseFolderManually]}),(0,x.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,x.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,x.jsx)(`span`,{children:v.quickScanNote})]}),(0,x.jsx)(`button`,{type:`button`,className:`mt-4 text-sm font-medium text-accent-fg hover:underline`,onClick:()=>b(`/connectors?understanding=1&returnTo=%2Fonboarding%2Fworkspace`),children:v.connectCloudSource}),M?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:M}):null]}),(0,x.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Re(),disabled:A,children:v.skip})]}):null,w===`candidates`?(0,x.jsxs)(`section`,{className:e?`flex h-full min-h-0 flex-col`:void 0,"aria-labelledby":`work-discovery-candidates-title`,children:[(0,x.jsxs)(`div`,{className:e?`shrink-0 text-center`:`text-center`,children:[(0,x.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:v.candidatesTitle}),(0,x.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:v.candidatesSubtitle})]}),(0,x.jsx)(`div`,{className:e?`mt-5 min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1 [scrollbar-gutter:stable]`:`mt-7 space-y-2`,children:R.map((e,t)=>{let n=z.has(e.rootPath);return(0,x.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${n?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>Pe(e.rootPath),children:[(0,x.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${n?`border-accent bg-accent text-white`:`border-edge bg-surface-base text-transparent`}`,children:(0,x.jsx)(a,{className:`size-3.5`})}),(0,x.jsx)(m,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),t===0?(0,x.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:v.recommendedCandidate}):null]}),(0,x.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,x.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,x.jsx)(`span`,{children:e.projectKind===`coding`?v.codingProject:e.projectKind===`general`?v.generalProject:v.unknownProject}),e.branch?(0,x.jsx)(`span`,{children:v.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,x.jsx)(`span`,{children:v.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,x.jsxs)(`div`,{className:e?`shrink-0 border-t border-edge-subtle pt-4`:void 0,children:[(0,x.jsxs)(`div`,{className:`${e?``:`mt-5 `}flex items-start gap-2 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,x.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,x.jsx)(`span`,{children:v.multiFolderPrivacyNote})]}),M?(0,x.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:M}):null,(0,x.jsxs)(`div`,{className:`${e?`mt-4`:`mt-7`} flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,x.jsxs)(c,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:A||z.size===0,onClick:()=>void Le(),children:[A?(0,x.jsx)(s,{className:`mr-2 size-4 animate-spin`}):null,v.analyzeSelected.replace(`{{count}}`,String(z.size))]}),(0,x.jsx)(c,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:A,onClick:Y.pick,children:v.chooseFolderManually})]}),(0,x.jsx)(`button`,{type:`button`,className:`${e?`mt-3`:`mt-6`} mx-auto block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>T(`intro`),children:v.back})]})]}):null,w===`consent`&&E?(0,x.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,x.jsxs)(`div`,{className:`text-center`,children:[(0,x.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:v.selectedTitle}),(0,x.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:v.selectedSubtitle})]}),(0,x.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,x.jsx)(m,{className:`size-5 shrink-0 text-accent-fg`}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:E.displayName}),(0,x.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:E.canonicalRootPath})]}),(0,x.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:E.projectKind===`coding`?v.codingProject:E.projectKind===`general`?v.generalProject:v.unknownProject})]}),(0,x.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.localFingerprint}),(0,x.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:E.fingerprint.branch?v.branchValue.replace(`{{branch}}`,E.fingerprint.branch):v.noGitBranch})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.recentActivity}),(0,x.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:v.changedFiles.replace(`{{count}}`,String(E.fingerprint.changedFileCount))})]}),E.fingerprint.recentAreas.length>0?(0,x.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,x.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.recentAreas}),(0,x.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:E.fingerprint.recentAreas.map(e=>(0,x.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,x.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,x.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,x.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.willRead}),(0,x.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:v.willReadValue})]})]}),(0,x.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,x.jsx)(ce,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.willIgnore}),(0,x.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:v.willIgnoreValue})]})]}),(0,x.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,x.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,x.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:E.remoteModel?v.providerDisclosure.replace(`{{provider}}`,E.provider):v.localDisclosure})]})]})]}),M?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:M}):null,(0,x.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,x.jsxs)(c,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:A,onClick:()=>void ze(),children:[A?(0,x.jsx)(s,{className:`mr-2 size-4 animate-spin`}):null,v.startAnalysis]}),(0,x.jsx)(c,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:A,onClick:Y.pick,children:v.changeFolder})]}),(0,x.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Re(),children:v.skip})]}):null,w===`running`&&O?(0,x.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,x.jsxs)(`div`,{className:`text-center`,children:[(0,x.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:v.analyzingTitle}),(0,x.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:v.analyzingSubtitle}),W.total>1?(0,x.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:v.analyzingFolderProgress.replace(`{{current}}`,String(W.current)).replace(`{{total}}`,String(W.total))}):null]}),(0,x.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:S.map((e,t)=>{let n=Math.max(0,S.indexOf(O.stage??`folder_structure`)),r=t<n,i=t===n;return(0,x.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,x.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${r?`bg-accent text-white`:i?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:r?(0,x.jsx)(a,{className:`size-4`}):i?(0,x.jsx)(s,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,x.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,x.jsx)(`span`,{className:i||r?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:v.stages[e]})]},e)})}),(0,x.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:O.rootPath}),(0,x.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,x.jsx)(c,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>b(`/chat`),children:v.continueInBackground}),(0,x.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Ve(),children:v.cancelAnalysis})]})]}):null,w===`recognition`&&O?.result?(0,x.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,x.jsxs)(`div`,{className:`text-center`,children:[(0,x.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:v.recognitionEyebrow}),(0,x.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:O.result.lowConfidence?v.lowConfidenceTitle:v.recognitionTitle})]}),Je,(0,x.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,x.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:O.result.projectSummary}),(0,x.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:O.result.currentState}),!O.result.lowConfidence&&$?.evidence.length?(0,x.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:$.evidence.slice(0,3).map((e,t)=>(0,x.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,x.jsx)(ve,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,x.jsxs)(`span`,{children:[e.path?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${$.id}-recognition-${t}`))}):null]}),O.result.workThreads?.length?(0,x.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,x.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.workThreadsTitle}),(0,x.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:v.workThreadsSubtitle}),(0,x.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:O.result.workThreads.map(e=>(0,x.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:e.horizon===`current`?v.workThreadCurrent:e.horizon===`ongoing`?v.workThreadOngoing:v.workThreadLongTerm}),(0,x.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,x.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,O.result.profileCandidates?.length?(0,x.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,x.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.profileCandidatesTitle}),(0,x.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:v.profileCandidatesSubtitle}),(0,x.jsx)(`div`,{className:`mt-3 space-y-2`,children:O.result.profileCandidates.map(e=>(0,x.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,x.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:Ee.has(e.id),onChange:()=>L(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,x.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,O.result.lowConfidence?(0,x.jsxs)(`div`,{className:`mt-5`,children:[(0,x.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:O.result.contextQuestion}),(0,x.jsx)(`textarea`,{value:F,onChange:e=>we(e.target.value),placeholder:v.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,x.jsx)(c,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:A||!F.trim(),onClick:()=>void Q(`different_goal`),children:v.continueWithCorrection})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,x.jsxs)(c,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:A,onClick:()=>void He(),children:[A?(0,x.jsx)(s,{className:`size-4 animate-spin`}):(0,x.jsx)(a,{className:`size-4`}),v.confirmUnderstanding]}),(0,x.jsx)(c,{variant:`secondary`,className:`h-11 flex-1`,disabled:A,onClick:()=>P(e=>!e),children:v.notQuiteRight})]}),Ce?(0,x.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,x.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:v.correctionLabel}),(0,x.jsx)(`textarea`,{id:`work-discovery-correction`,value:F,onChange:e=>we(e.target.value),placeholder:v.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,x.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,x.jsx)(c,{variant:`ghost`,disabled:A||!F.trim(),onClick:()=>void Q(`different_goal`),children:v.differentGoal}),(0,x.jsx)(c,{variant:`primary`,disabled:A||!F.trim(),onClick:()=>void Q(`corrected`),children:v.useCorrection})]})]}):null]}),M?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:M}):null,(0,x.jsx)(`button`,{type:`button`,disabled:A,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void Ue(),children:v.openConversation})]}):null,w===`recommendation`&&O?.result&&$?(0,x.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,x.jsxs)(`div`,{className:`text-center`,children:[(0,x.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:v.understandingConfirmed}),(0,x.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:v.primaryRecommendationTitle})]}),Je,(0,x.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,x.jsx)(le,{className:`size-5`})}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:$.title}),(0,x.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:$.rationale}),(0,x.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,x.jsx)(ge,{className:`size-3.5`}),v.estimatedMinutes.replace(`{{count}}`,String($.estimatedMinutes))]}),(0,x.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ge($.risk)})]}),(0,x.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,x.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.expectedTask}),(0,x.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:$.expectedTask})]}),(0,x.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,x.jsx)(c,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void Z($,!1),children:v.startRecommendedAction}),(0,x.jsx)(c,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void Z($,!0),children:v.explainFirst})]})]})]})}),We.length>0?(0,x.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>Te(e=>!e),children:[v.otherDirections,(0,x.jsx)(re,{className:`size-4 transition-transform ${I?`rotate-180`:``}`})]}),I?(0,x.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:We.map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void Z(e,!0),children:[(0,x.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,x.jsxs)(`span`,{children:[(0,x.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,x.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedTask})]})]},e.id))}):null]}):null,(0,x.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,x.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>X(O.sessionKey),children:v.doSomethingElse}),(0,x.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{P(!0),T(`recognition`)},children:v.correctUnderstanding})]})]}):null,w===`error`&&O?(0,x.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,x.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,x.jsx)(ce,{className:`size-5`})}),(0,x.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:v.errorTitle}),(0,x.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:O.errorMessage}),(0,x.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,x.jsx)(c,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void pe(O.id).then(J),children:v.retry}),(0,x.jsx)(c,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{k(null),D(null),T(`intro`)},children:v.chooseDifferent})]}),(0,x.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>X(O.sessionKey),children:v.openConversation})]}):null]}),Y.hasNativePicker?null:(0,x.jsx)(ee,{open:Y.modalOpen,onOpenChange:Y.setModalOpen,initialAbsolutePath:E?.canonicalRootPath,onConfirm:Y.confirmPick,wd:y})]})}export{xe as WorkDiscoveryPage};