@xopcai/xopc 0.0.245 → 0.0.246

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 (115) 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-DRQnogaU.js → agent-avatar-dicebear-CJJzpYYS.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-CpOxGbMD.js → agent-defaults-settings-panel-0dRjnL2s.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-flnXZLaT.js → agents-je3sRGmk.js} +1 -1
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-CZl6n2xi.js → app-management-settings-panel-Cnn3i00c.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-Bglp-pn6.js → appearance-settings-BToQaw_v.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-CmsWarVB.js → apps-page-EpUZsl4h.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-G0HenUmG.js → attachment-load-BFtcib5t.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automations-page-B78bFjH2.js → automations-page-XS8wIl5o.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-workspace-BMQGmn50.js → automations-workspace-BGQdHrip.js} +1 -1
  12. package/dist/gateway/static/root/assets/{binary-plugins-BbSQmXqn.js → binary-plugins-Xs7pLHxR.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-DutTIH81.js → block-editor-BPdSzceB.js} +1 -1
  14. package/dist/gateway/static/root/assets/{browser-settings-page-CALiFKm4.js → browser-settings-page-DJGcm7rH.js} +1 -1
  15. package/dist/gateway/static/root/assets/{browser-workflows-page-DE5HPrHZ.js → browser-workflows-page-DUPPvE30.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capabilities-settings-panel-Dts7XtP3.js → capabilities-settings-panel-cl9kYilL.js} +1 -1
  17. package/dist/gateway/static/root/assets/{channels-settings-CWEd3wzh.js → channels-settings-BcIr-_GM.js} +1 -1
  18. package/dist/gateway/static/root/assets/{chat-terminal-dock-Bp1fXQm1.js → chat-terminal-dock-DKW1M6aJ.js} +1 -1
  19. package/dist/gateway/static/root/assets/{connectors-page-CQ6wVNLm.js → connectors-page-DNHqaZfX.js} +1 -1
  20. package/dist/gateway/static/root/assets/{cron-expression-B8HA5IRb.js → cron-expression-Bijb0ZQu.js} +1 -1
  21. package/dist/gateway/static/root/assets/{date-picker-DD8b7oad.js → date-picker-BZuHw-SY.js} +1 -1
  22. package/dist/gateway/static/root/assets/{dependency-picker-BC9zwIyH.js → dependency-picker-BsBD2JFY.js} +1 -1
  23. package/dist/gateway/static/root/assets/{desktop-pet-DsrsPZTW.js → desktop-pet-Ceuw3QKb.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-settings-D7gp_HNA.js → desktop-pet-settings-DctOXexM.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-debug-page-BoKbOX7x.js → extension-debug-page-BNlMPATK.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-page-BegL4FW8.js → extension-page-CK4Uvzge.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-CjPqq57s.js → extension-settings-page-CpnXXemw.js} +1 -1
  28. package/dist/gateway/static/root/assets/{gateway-config-api-DaG57o4X.js → gateway-config-api-C_mlpe-r.js} +1 -1
  29. package/dist/gateway/static/root/assets/{gateway-settings-DkJGpgm6.js → gateway-settings-DSSW17ed.js} +1 -1
  30. package/dist/gateway/static/root/assets/{heartbeat-settings-BLZ48kSU.js → heartbeat-settings-hbmIZTpg.js} +1 -1
  31. package/dist/gateway/static/root/assets/{home-page-Dtw7Ipt1.js → home-page-CaVvW77l.js} +1 -1
  32. package/dist/gateway/static/root/assets/{index-DG5CfYat.js → index-eZjksPvq.js} +9 -9
  33. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D2Has7-N.js → keyboard-shortcuts-settings-BQrDwwgi.js} +1 -1
  34. package/dist/gateway/static/root/assets/{local-app-workbench-page-BWidWY93.js → local-app-workbench-page-D3K1XmOM.js} +1 -1
  35. package/dist/gateway/static/root/assets/{local-apps-page-Bkekjoxf.js → local-apps-page-D-YWD6LS.js} +1 -1
  36. package/dist/gateway/static/root/assets/{logs-page-C5zSSgvA.js → logs-page-DvLc9l59.js} +1 -1
  37. package/dist/gateway/static/root/assets/{management-settings-B8c62vRS.js → management-settings-DsULLUUv.js} +1 -1
  38. package/dist/gateway/static/root/assets/{markdown-split-3kxTTGO7.js → markdown-split-CjqlP6IB.js} +1 -1
  39. package/dist/gateway/static/root/assets/{media-plugins-BW8J1nCG.js → media-plugins-DQL029DU.js} +1 -1
  40. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-nwQ8iUcd.js → mobile-pairing-wizard-gauprAae.js} +1 -1
  41. package/dist/gateway/static/root/assets/{notes-page-DdybD0QM.js → notes-page-AsEfLZt9.js} +1 -1
  42. package/dist/gateway/static/root/assets/{notes-workbench-IYfpy2Jx.js → notes-workbench-CI30cDh3.js} +2 -2
  43. package/dist/gateway/static/root/assets/{project-detail-page-4wjw-b7h.js → project-detail-page-jO_4I5zN.js} +1 -1
  44. package/dist/gateway/static/root/assets/{projects-page-CCMj9PeL.js → projects-page-BrTGFME0.js} +1 -1
  45. package/dist/gateway/static/root/assets/{remote-access-hub-DsBJqWIk.js → remote-access-hub-CH70D5SH.js} +1 -1
  46. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-B4IDcqx0.js → runtime-tools-settings-panel-DH6EilMV.js} +1 -1
  47. package/dist/gateway/static/root/assets/{schema-form-DiGUUjO6.js → schema-form-DYHmEZeZ.js} +1 -1
  48. package/dist/gateway/static/root/assets/{sessions-page-BwGj0t-2.js → sessions-page-hbfUNtNs.js} +1 -1
  49. package/dist/gateway/static/root/assets/settings-advanced-gate-Vg3_jua6.js +1 -0
  50. package/dist/gateway/static/root/assets/{settings-page-CVQUsAhd.js → settings-page-BHwPd_M3.js} +1 -1
  51. package/dist/gateway/static/root/assets/{setup-status-panel-CQACRh1i.js → setup-status-panel-DkcpWSss.js} +1 -1
  52. package/dist/gateway/static/root/assets/{share-preview-page-DTP1dtuS.js → share-preview-page-BjwrS03F.js} +1 -1
  53. package/dist/gateway/static/root/assets/{shares-settings-D_YPh6Rw.js → shares-settings-BL4DEt6p.js} +1 -1
  54. package/dist/gateway/static/root/assets/{skill-reload-api-B43xlJlX.js → skill-reload-api-CafhNktn.js} +1 -1
  55. package/dist/gateway/static/root/assets/{skills-page-Czpn7Y28.js → skills-page-OHyK25op.js} +1 -1
  56. package/dist/gateway/static/root/assets/{skills-page.utils-d39rm3hb.js → skills-page.utils-DQx9ulmg.js} +1 -1
  57. package/dist/gateway/static/root/assets/{system-settings-panel-CXXySCSp.js → system-settings-panel-wO7DWv4C.js} +1 -1
  58. package/dist/gateway/static/root/assets/{task-detail-page-DHiOqQMx.js → task-detail-page-anyomXsu.js} +1 -1
  59. package/dist/gateway/static/root/assets/{tunnel-api-BiBGK7O2.js → tunnel-api-CVC8BHZu.js} +1 -1
  60. package/dist/gateway/static/root/assets/{use-autosave-DjpzpeIm.js → use-autosave-DMvRu2XZ.js} +1 -1
  61. package/dist/gateway/static/root/assets/{user-context-page-1XBRV5gX.js → user-context-page-BBk9YdBn.js} +1 -1
  62. package/dist/gateway/static/root/assets/{voice-api-key-field-CUIPNmOc.js → voice-api-key-field-DuBK2NDG.js} +1 -1
  63. package/dist/gateway/static/root/assets/{work-discovery-overlay-DVNxhb1x.js → work-discovery-overlay-B7VXWpDr.js} +1 -1
  64. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-HxxFQFY7.js → workflow-run-setup-panel-BokVAsWN.js} +1 -1
  65. package/dist/gateway/static/root/assets/{workflows-page-BCgL7PRm.js → workflows-page-RUTv0yvR.js} +1 -1
  66. package/dist/gateway/static/root/index.html +1 -1
  67. package/dist/package.js +1 -1
  68. package/dist/src/agent/agent-manager.js +4 -4
  69. package/dist/src/agent/background-review/run-background-review.js +1 -1
  70. package/dist/src/agent/embedded/model-runtime.js +1 -1
  71. package/dist/src/agent/embedded/run-for-session.js +1 -1
  72. package/dist/src/agent/image/tool-model-config.js +1 -1
  73. package/dist/src/agent/ipc/inbox.js +1 -1
  74. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  75. package/dist/src/agent/service.js +2 -2
  76. package/dist/src/agent/session/session-inspector.js +1 -1
  77. package/dist/src/agent/skills/hub-lock.js +1 -1
  78. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  79. package/dist/src/ai-assist/text-assist.js +1 -1
  80. package/dist/src/auth/credentials.js +2 -2
  81. package/dist/src/auth/profiles/store.js +1 -1
  82. package/dist/src/auth/sync-provider-auth.js +2 -2
  83. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  84. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  85. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  86. package/dist/src/cli/commands/models.js +1 -1
  87. package/dist/src/config/index.js +4 -4
  88. package/dist/src/config/loader.js +1 -1
  89. package/dist/src/config/models-json.js +1 -1
  90. package/dist/src/extensions/lockfile.js +1 -1
  91. package/dist/src/extensions/update.js +1 -1
  92. package/dist/src/gateway/agents-admin.js +1 -1
  93. package/dist/src/gateway/file-path-classifier.js +1 -1
  94. package/dist/src/gateway/heartbeat/service.js +1 -1
  95. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  96. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  97. package/dist/src/gateway/hono/routes/models.js +1 -1
  98. package/dist/src/gateway/service/config-coordinator.js +2 -2
  99. package/dist/src/gateway/service.js +4 -4
  100. package/dist/src/heartbeat/index.js +1 -1
  101. package/dist/src/infra/update-runner.js +1 -1
  102. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  103. package/dist/src/providers/index.js +2 -2
  104. package/dist/src/providers/model-registry.js +1 -1
  105. package/dist/src/providers/register-runtime-providers.js +1 -1
  106. package/dist/src/share/hosted-session-share.js +1 -1
  107. package/dist/src/tui/tui-startup-resources.js +1 -1
  108. package/dist/src/tui/tui.js +1 -1
  109. package/dist/src/voice/realtime/agentEngine.d.ts +1 -1
  110. package/dist/src/voice/realtime/runtime.d.ts +3 -68
  111. package/dist/src/voice/realtime/runtime.types.d.ts +69 -0
  112. package/dist/src/voice/realtime/runtime.types.js +1 -0
  113. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  114. package/package.json +3 -3
  115. package/dist/gateway/static/root/assets/settings-advanced-gate-BJCfUghk.js +0 -1
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{i as n,r,s as i}from"./locale-store-CBoCuIMx.js";import{t as a}from"./cn-JdwAhgNB.js";import{Zt as o}from"./index-DG5CfYat.js";import"./skill-reload-api-B43xlJlX.js";async function s(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`),n.append(`target`,t.target??`global`);let a=i.getState().token,o=new Headers;a&&o.set(`Authorization`,`Bearer ${a}`);let s=await fetch(r(`/api/skills/upload`),{method:`POST`,headers:o,body:n});s.status===401&&i.getState().onUnauthorized();let c=await s.json().catch(()=>({}));if(!s.ok)throw Error(c.error||`HTTP ${s.status}`);if(!c.payload?.skillId)throw Error(`Invalid response`);return c.payload}async function c(e,t){let i=t?`?target=${encodeURIComponent(t)}`:``,a=await n(r(`/api/skills/${encodeURIComponent(e)}${i}`),{method:`DELETE`});if(!a.ok)throw Error(await o(a))}async function l(e,t){let i=await n(r(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!i.ok)throw Error(await o(i))}function u(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function d(e){let t=new URLSearchParams;u(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let i=t.toString(),a=await n(r(`/api/skills/marketplace/categories${i?`?${i}`:``}`),{cache:`no-store`});if(!a.ok)throw Error(await o(a));let s=await a.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function f(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),u(t,e.provider);let i=t.toString(),a=await n(r(`/api/skills/marketplace${i?`?${i}`:``}`),{cache:`no-store`,signal:e.signal});if(!a.ok)throw Error(await o(a));let s=await a.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function p(e,t){let i=encodeURIComponent(e),a=new URLSearchParams;u(a,t?.provider);let s=a.toString(),c=await n(r(`/api/skills/marketplace/packages/${i}${s?`?${s}`:``}`),{cache:`no-store`});if(!c.ok)throw Error(await o(c));let l=(await c.json()).payload;if(!l?.name||!l.skillDocPreview||typeof l.skillDocPreview.name!=`string`||typeof l.skillDocPreview.description!=`string`||typeof l.skillDocPreview.bodyMarkdown!=`string`||typeof l.skillDocPreview.disableModelInvocation!=`boolean`||!l.skillDocPreview.metadata||typeof l.skillDocPreview.metadata!=`object`||typeof l.skillDocPreview.metadata.name!=`string`||typeof l.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return l}async function m(e){let t=await n(r(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:`global`,...e})});if(!t.ok)throw Error(await o(t));let i=await t.json();if(!i.payload?.skillId)throw Error(i.error||`Invalid response`);return i.payload}async function h(e){let t=await n(r(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let i=(await t.json()).payload;if(!i||typeof i.name!=`string`||typeof i.description!=`string`||typeof i.bodyMarkdown!=`string`||typeof i.disableModelInvocation!=`boolean`||!i.metadata||typeof i.metadata!=`object`||typeof i.metadata.name!=`string`||typeof i.metadata.description!=`string`)throw Error(`Invalid response`);return i}async function g(){let e=await n(r(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function _(){let e=await n(r(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}var v=e(),y=t(),b=[{light:`bg-sky-100 text-sky-800`,dark:`dark:bg-sky-950/55 dark:text-sky-200`},{light:`bg-violet-100 text-violet-800`,dark:`dark:bg-violet-950/55 dark:text-violet-200`},{light:`bg-emerald-100 text-emerald-800`,dark:`dark:bg-emerald-950/55 dark:text-emerald-200`},{light:`bg-orange-100 text-orange-800`,dark:`dark:bg-orange-950/55 dark:text-orange-200`},{light:`bg-rose-100 text-rose-800`,dark:`dark:bg-rose-950/55 dark:text-rose-200`},{light:`bg-amber-100 text-amber-900`,dark:`dark:bg-amber-950/55 dark:text-amber-200`},{light:`bg-cyan-100 text-cyan-800`,dark:`dark:bg-cyan-950/55 dark:text-cyan-200`},{light:`bg-indigo-100 text-indigo-800`,dark:`dark:bg-indigo-950/55 dark:text-indigo-200`},{light:`bg-fuchsia-100 text-fuchsia-800`,dark:`dark:bg-fuchsia-950/55 dark:text-fuchsia-200`},{light:`bg-teal-100 text-teal-800`,dark:`dark:bg-teal-950/55 dark:text-teal-200`}];function x(e){let t=0;for(let n=0;n<e.length;n+=1)t=Math.imul(31,t)+e.charCodeAt(n)|0;return Math.abs(t)}function S(e){let t=e.trim();if(!t)return`?`;let n=t.match(/[\p{L}\p{N}]/u);return n?n[0].toLocaleUpperCase(`en-US`):t[0]}function C(e){let t=(0,v.c)(9),{name:n,className:r}=e,i;t[0]===n?i=t[1]:(i=S(n),t[0]=n,t[1]=i);let o=i,s=b[x(n)%b.length],c;t[2]!==r||t[3]!==s.dark||t[4]!==s.light?(c=a(`flex size-11 shrink-0 items-center justify-center rounded-xl font-semibold tracking-tight shadow-surface`,`text-[1.05rem] ring-1 ring-inset ring-black/[0.06] dark:ring-white/[0.1]`,`transition-[transform,box-shadow] duration-200 ease-out group-hover:ring-black/[0.1] dark:group-hover:ring-white/[0.14]`,`group-hover:-translate-y-px`,s.light,s.dark,r),t[2]=r,t[3]=s.dark,t[4]=s.light,t[5]=c):c=t[5];let l;return t[6]!==o||t[7]!==c?(l=(0,y.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}var w=`https://skillhub.cn`,T=`https://clawhub.ai`;function E(e){let t=e.trim();return t?`${w}/skills/${encodeURIComponent(t)}`:null}function D(e){let t=e.trim();return t?`${T}/${encodeURIComponent(t)}`:null}function O(e,t){return e===`skillhub`?E(t):e===`clawhub`?D(t):null}function k(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function A(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function j(e){return e.filter(e=>e.type!==`collision`)}function M(e){let t=[e.kind];return e.label?.trim()&&t.push(e.label.trim()),e.package?.trim()&&t.push(e.package.trim()),e.formula?.trim()&&t.push(e.formula.trim()),e.module?.trim()&&t.push(e.module.trim()),e.url?.trim()&&t.push(e.url.trim()),t.join(` · `)}function N(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}export{s as _,O as a,c,g as d,_ as f,l as g,m as h,k as i,d as l,h as m,M as n,N as o,f as p,A as r,C as s,j as t,p as u};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{i as n,r,s as i}from"./locale-store-CBoCuIMx.js";import{t as a}from"./cn-JdwAhgNB.js";import{Zt as o}from"./index-eZjksPvq.js";import"./skill-reload-api-CafhNktn.js";async function s(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`),n.append(`target`,t.target??`global`);let a=i.getState().token,o=new Headers;a&&o.set(`Authorization`,`Bearer ${a}`);let s=await fetch(r(`/api/skills/upload`),{method:`POST`,headers:o,body:n});s.status===401&&i.getState().onUnauthorized();let c=await s.json().catch(()=>({}));if(!s.ok)throw Error(c.error||`HTTP ${s.status}`);if(!c.payload?.skillId)throw Error(`Invalid response`);return c.payload}async function c(e,t){let i=t?`?target=${encodeURIComponent(t)}`:``,a=await n(r(`/api/skills/${encodeURIComponent(e)}${i}`),{method:`DELETE`});if(!a.ok)throw Error(await o(a))}async function l(e,t){let i=await n(r(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!i.ok)throw Error(await o(i))}function u(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function d(e){let t=new URLSearchParams;u(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let i=t.toString(),a=await n(r(`/api/skills/marketplace/categories${i?`?${i}`:``}`),{cache:`no-store`});if(!a.ok)throw Error(await o(a));let s=await a.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function f(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),u(t,e.provider);let i=t.toString(),a=await n(r(`/api/skills/marketplace${i?`?${i}`:``}`),{cache:`no-store`,signal:e.signal});if(!a.ok)throw Error(await o(a));let s=await a.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function p(e,t){let i=encodeURIComponent(e),a=new URLSearchParams;u(a,t?.provider);let s=a.toString(),c=await n(r(`/api/skills/marketplace/packages/${i}${s?`?${s}`:``}`),{cache:`no-store`});if(!c.ok)throw Error(await o(c));let l=(await c.json()).payload;if(!l?.name||!l.skillDocPreview||typeof l.skillDocPreview.name!=`string`||typeof l.skillDocPreview.description!=`string`||typeof l.skillDocPreview.bodyMarkdown!=`string`||typeof l.skillDocPreview.disableModelInvocation!=`boolean`||!l.skillDocPreview.metadata||typeof l.skillDocPreview.metadata!=`object`||typeof l.skillDocPreview.metadata.name!=`string`||typeof l.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return l}async function m(e){let t=await n(r(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:`global`,...e})});if(!t.ok)throw Error(await o(t));let i=await t.json();if(!i.payload?.skillId)throw Error(i.error||`Invalid response`);return i.payload}async function h(e){let t=await n(r(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let i=(await t.json()).payload;if(!i||typeof i.name!=`string`||typeof i.description!=`string`||typeof i.bodyMarkdown!=`string`||typeof i.disableModelInvocation!=`boolean`||!i.metadata||typeof i.metadata!=`object`||typeof i.metadata.name!=`string`||typeof i.metadata.description!=`string`)throw Error(`Invalid response`);return i}async function g(){let e=await n(r(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function _(){let e=await n(r(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}var v=e(),y=t(),b=[{light:`bg-sky-100 text-sky-800`,dark:`dark:bg-sky-950/55 dark:text-sky-200`},{light:`bg-violet-100 text-violet-800`,dark:`dark:bg-violet-950/55 dark:text-violet-200`},{light:`bg-emerald-100 text-emerald-800`,dark:`dark:bg-emerald-950/55 dark:text-emerald-200`},{light:`bg-orange-100 text-orange-800`,dark:`dark:bg-orange-950/55 dark:text-orange-200`},{light:`bg-rose-100 text-rose-800`,dark:`dark:bg-rose-950/55 dark:text-rose-200`},{light:`bg-amber-100 text-amber-900`,dark:`dark:bg-amber-950/55 dark:text-amber-200`},{light:`bg-cyan-100 text-cyan-800`,dark:`dark:bg-cyan-950/55 dark:text-cyan-200`},{light:`bg-indigo-100 text-indigo-800`,dark:`dark:bg-indigo-950/55 dark:text-indigo-200`},{light:`bg-fuchsia-100 text-fuchsia-800`,dark:`dark:bg-fuchsia-950/55 dark:text-fuchsia-200`},{light:`bg-teal-100 text-teal-800`,dark:`dark:bg-teal-950/55 dark:text-teal-200`}];function x(e){let t=0;for(let n=0;n<e.length;n+=1)t=Math.imul(31,t)+e.charCodeAt(n)|0;return Math.abs(t)}function S(e){let t=e.trim();if(!t)return`?`;let n=t.match(/[\p{L}\p{N}]/u);return n?n[0].toLocaleUpperCase(`en-US`):t[0]}function C(e){let t=(0,v.c)(9),{name:n,className:r}=e,i;t[0]===n?i=t[1]:(i=S(n),t[0]=n,t[1]=i);let o=i,s=b[x(n)%b.length],c;t[2]!==r||t[3]!==s.dark||t[4]!==s.light?(c=a(`flex size-11 shrink-0 items-center justify-center rounded-xl font-semibold tracking-tight shadow-surface`,`text-[1.05rem] ring-1 ring-inset ring-black/[0.06] dark:ring-white/[0.1]`,`transition-[transform,box-shadow] duration-200 ease-out group-hover:ring-black/[0.1] dark:group-hover:ring-white/[0.14]`,`group-hover:-translate-y-px`,s.light,s.dark,r),t[2]=r,t[3]=s.dark,t[4]=s.light,t[5]=c):c=t[5];let l;return t[6]!==o||t[7]!==c?(l=(0,y.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}var w=`https://skillhub.cn`,T=`https://clawhub.ai`;function E(e){let t=e.trim();return t?`${w}/skills/${encodeURIComponent(t)}`:null}function D(e){let t=e.trim();return t?`${T}/${encodeURIComponent(t)}`:null}function O(e,t){return e===`skillhub`?E(t):e===`clawhub`?D(t):null}function k(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function A(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function j(e){return e.filter(e=>e.type!==`collision`)}function M(e){let t=[e.kind];return e.label?.trim()&&t.push(e.label.trim()),e.package?.trim()&&t.push(e.package.trim()),e.formula?.trim()&&t.push(e.formula.trim()),e.module?.trim()&&t.push(e.module.trim()),e.url?.trim()&&t.push(e.url.trim()),t.join(` · `)}function N(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}export{s as _,O as a,c,g as d,_ as f,l as g,m as h,k as i,d as l,h as m,M as n,N as o,f as p,A as r,C as s,j as t,p as u};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./external-link-DjqjBmc3.js";import{t as i}from"./messages-BbdwoxVo.js";import{n as a}from"./locale-store-CBoCuIMx.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./interaction-BmQogeqz.js";import{t as c}from"./electron-env-DH5wF8X8.js";import{Dt as l,Et as u,Li as d,Ot as f,Tt as p,Us as m,Yl as h,ec as g}from"./index-DG5CfYat.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-DjWzRk4z.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!c()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=i(a(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(l),[r,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(!1),d=async t=>{if(!t){n(f({enabled:!1})),o(null);return}c(!0);try{let t=await p();if(t!==`granted`){o(t===`unsupported`?e.unsupported:e.denied);return}n(f({enabled:!0})),o(await u(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},m=e=>{n(f(e))};return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:e.pageTitle}),(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(h,{className:`size-4 text-accent`,strokeWidth:1.75}),e.title]}),(0,C.jsx)(`p`,{className:`mb-4 text-sm text-fg-muted`,children:e.description}),(0,C.jsx)(`div`,{className:`space-y-2`,children:[[`enabled`,e.enabled,e.enabledDesc],[`completed`,e.completed,e.completedDesc],[`failed`,e.failedRuns,e.failedRunsDesc]].map(([e,n,r])=>(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,C.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:s||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?d(t.target.checked):m({[e]:t.target.checked})}})]},e))}),r?(0,C.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,role:`status`,children:r}):null,(0,C.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:e.limitation})]})]})}async function T(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function E(e,t,n){return e.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var A=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function j(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||A.has(e)?t===`unknown`:!1}function M(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:A.has(e)?t===`denied`:!0}var N=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function P(e){return e===`linux`?N:N.filter(t=>!t.platforms||t.platforms.includes(e))}function F(e,t){let n=i(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function I(e,t,n){let r=i(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var L={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function R(){let e=a(e=>e.language),t=i(e),n=t.systemSettings,[l,u]=(0,x.useReducer)(d,L),{behavior:f,perms:p,loadError:h,permFeedback:A,permBusy:N,refreshing:R}=l,z=typeof window<`u`?window.electronAPI?.system:void 0,B=(0,x.useCallback)(async e=>{if(z){u({type:`patch`,patch:{loadError:null}});try{u({type:`patch`,patch:{behavior:await z.getBehavior(),perms:await z.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:n.refreshDone}:{}}})}catch(t){u({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[z,n.refreshDone]),V=(0,x.useCallback)(async()=>{if(!(R||N)){u({type:`patch`,patch:{refreshing:!0}});try{await B({showRefreshFeedback:!0})}finally{u({type:`patch`,patch:{refreshing:!1}})}}},[B,N,R]);if((0,x.useEffect)(()=>{let e=new Set([n.refreshDone,n.openSettingsDone,n.openSettingsFailed,n.desktopNotify.testShown]);if(!A||!e.has(A))return;let t=window.setTimeout(()=>{u({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(t)},[A,n.openSettingsDone,n.openSettingsFailed,n.refreshDone,n.desktopNotify.testShown]),(0,x.useEffect)(()=>{c()&&z&&B()},[z,B]),!c()||!z)return(0,C.jsx)(w,{});let H=async e=>{try{let{behavior:t}=await z.setBehavior(e);u({type:`patch`,patch:{behavior:t}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},U=async e=>{if(!e){await H({notifyEnabled:!1});return}u({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(n.desktopNotify.testTitle,n.desktopNotify.testBody);if(e===`unsupported`){u({type:`patch`,patch:{permFeedback:n.notificationsFeedback.unsupported}});return}if(e===`denied`){u({type:`patch`,patch:{permFeedback:n.desktopNotify.denied}});return}if(e==="default"){u({type:`patch`,patch:{permFeedback:n.notificationsFeedback.default}});return}await H({notifyEnabled:!0}),u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:n.desktopNotify.testShown}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},W=async e=>{u({type:`patch`,patch:{permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{(await z.openPrivacy(e)).ok?u({type:`patch`,patch:{permFeedback:n.openSettingsDone}}):u({type:`patch`,patch:{permFeedback:n.openSettingsFailed}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},G=async()=>{u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestMicrophone(),t=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:E(e,t,n.permFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},K=async()=>{if(z.requestAccessibility){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestAccessibility();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:D(e,n.accessibilityFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(z.requestNotifications){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestNotifications();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:O(e,n.notificationsFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},J=async()=>{if(z.requestScreen){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestScreen();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:k(e,n.screenFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},Y=f?f.platform===`win32`?n.permissionsHintWin:f.platform===`linux`?n.permissionsHintLinux:f.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:n.title}),h?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:h}):null,A?(0,C.jsx)(`p`,{className:o(`text-sm`,A===n.refreshDone||A===n.openSettingsDone||A===n.permFeedback.granted||A===n.permFeedback.alreadyGranted||A===n.accessibilityFeedback.granted||A===n.accessibilityFeedback.alreadyGranted||A===n.notificationsFeedback.granted||A===n.notificationsFeedback.alreadyGranted||A===n.screenFeedback.granted||A===n.screenFeedback.alreadyGranted||A===n.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:A}):null,(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(m,{className:`size-4 text-accent`,strokeWidth:1.75}),n.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.endpointToolsSettings.mobileAccess.flow.background}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.endpointToolsSettings.mobileAccess.flow.sleep})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f?.backgroundSupported,checked:!!f?.runInBackground,onChange:e=>void H({runInBackground:e.target.checked})})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.openAtLogin,onChange:e=>{H({openAtLogin:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.keepAwakePreferred,onChange:e=>{H({keepAwakePreferred:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f||N,checked:!!f?.notifyEnabled,onChange:e=>{U(e.target.checked)}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.notifySoundEnabled,onChange:e=>{H({notifySoundEnabled:e.target.checked})}})]})]})]}),f&&p?(0,C.jsxs)(`section`,{className:y(),children:[(0,C.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:Y}),f.platform===`darwin`&&!f.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:n.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:R||N,"aria-busy":R,className:o(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,s.press),onClick:()=>void V(),children:[(0,C.jsx)(g,{className:o(`size-3.5`,R&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),R?n.refreshing:n.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(f.platform).map(({key:t,pane:i})=>{let a=F(e,p[t]),c=n.perm[t],l=p[t]===`unknown`?I(e,t,f.platform):null;return c?(0,C.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:c.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${a.className}`,children:a.label}),l?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[t===`notifications`&&j(t,p[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:o(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,p[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:o(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,p[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:o(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,p[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:o(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,p[t],f.platform)?(0,C.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,s.press),onClick:()=>void W(i),children:[n.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},t):null})})]}):null]})}export{R as SystemSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./external-link-DjqjBmc3.js";import{t as i}from"./messages-BbdwoxVo.js";import{n as a}from"./locale-store-CBoCuIMx.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./interaction-BmQogeqz.js";import{t as c}from"./electron-env-DH5wF8X8.js";import{Dt as l,Et as u,Li as d,Ot as f,Tt as p,Us as m,Yl as h,ec as g}from"./index-eZjksPvq.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-DjWzRk4z.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!c()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=i(a(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(l),[r,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(!1),d=async t=>{if(!t){n(f({enabled:!1})),o(null);return}c(!0);try{let t=await p();if(t!==`granted`){o(t===`unsupported`?e.unsupported:e.denied);return}n(f({enabled:!0})),o(await u(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},m=e=>{n(f(e))};return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:e.pageTitle}),(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(h,{className:`size-4 text-accent`,strokeWidth:1.75}),e.title]}),(0,C.jsx)(`p`,{className:`mb-4 text-sm text-fg-muted`,children:e.description}),(0,C.jsx)(`div`,{className:`space-y-2`,children:[[`enabled`,e.enabled,e.enabledDesc],[`completed`,e.completed,e.completedDesc],[`failed`,e.failedRuns,e.failedRunsDesc]].map(([e,n,r])=>(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,C.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:s||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?d(t.target.checked):m({[e]:t.target.checked})}})]},e))}),r?(0,C.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,role:`status`,children:r}):null,(0,C.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:e.limitation})]})]})}async function T(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function E(e,t,n){return e.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var A=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function j(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||A.has(e)?t===`unknown`:!1}function M(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:A.has(e)?t===`denied`:!0}var N=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function P(e){return e===`linux`?N:N.filter(t=>!t.platforms||t.platforms.includes(e))}function F(e,t){let n=i(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function I(e,t,n){let r=i(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var L={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function R(){let e=a(e=>e.language),t=i(e),n=t.systemSettings,[l,u]=(0,x.useReducer)(d,L),{behavior:f,perms:p,loadError:h,permFeedback:A,permBusy:N,refreshing:R}=l,z=typeof window<`u`?window.electronAPI?.system:void 0,B=(0,x.useCallback)(async e=>{if(z){u({type:`patch`,patch:{loadError:null}});try{u({type:`patch`,patch:{behavior:await z.getBehavior(),perms:await z.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:n.refreshDone}:{}}})}catch(t){u({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[z,n.refreshDone]),V=(0,x.useCallback)(async()=>{if(!(R||N)){u({type:`patch`,patch:{refreshing:!0}});try{await B({showRefreshFeedback:!0})}finally{u({type:`patch`,patch:{refreshing:!1}})}}},[B,N,R]);if((0,x.useEffect)(()=>{let e=new Set([n.refreshDone,n.openSettingsDone,n.openSettingsFailed,n.desktopNotify.testShown]);if(!A||!e.has(A))return;let t=window.setTimeout(()=>{u({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(t)},[A,n.openSettingsDone,n.openSettingsFailed,n.refreshDone,n.desktopNotify.testShown]),(0,x.useEffect)(()=>{c()&&z&&B()},[z,B]),!c()||!z)return(0,C.jsx)(w,{});let H=async e=>{try{let{behavior:t}=await z.setBehavior(e);u({type:`patch`,patch:{behavior:t}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},U=async e=>{if(!e){await H({notifyEnabled:!1});return}u({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(n.desktopNotify.testTitle,n.desktopNotify.testBody);if(e===`unsupported`){u({type:`patch`,patch:{permFeedback:n.notificationsFeedback.unsupported}});return}if(e===`denied`){u({type:`patch`,patch:{permFeedback:n.desktopNotify.denied}});return}if(e==="default"){u({type:`patch`,patch:{permFeedback:n.notificationsFeedback.default}});return}await H({notifyEnabled:!0}),u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:n.desktopNotify.testShown}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},W=async e=>{u({type:`patch`,patch:{permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{(await z.openPrivacy(e)).ok?u({type:`patch`,patch:{permFeedback:n.openSettingsDone}}):u({type:`patch`,patch:{permFeedback:n.openSettingsFailed}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},G=async()=>{u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestMicrophone(),t=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:E(e,t,n.permFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}},K=async()=>{if(z.requestAccessibility){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestAccessibility();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:D(e,n.accessibilityFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(z.requestNotifications){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestNotifications();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:O(e,n.notificationsFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},J=async()=>{if(z.requestScreen){u({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),u({type:`patch`,patch:{loadError:null}});try{let e=await z.requestScreen();u({type:`patch`,patch:{perms:await z.getPermissions()}}),u({type:`patch`,patch:{permFeedback:k(e,n.screenFeedback)}})}catch(e){u({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{permBusy:!1}})}}},Y=f?f.platform===`win32`?n.permissionsHintWin:f.platform===`linux`?n.permissionsHintLinux:f.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:n.title}),h?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:h}):null,A?(0,C.jsx)(`p`,{className:o(`text-sm`,A===n.refreshDone||A===n.openSettingsDone||A===n.permFeedback.granted||A===n.permFeedback.alreadyGranted||A===n.accessibilityFeedback.granted||A===n.accessibilityFeedback.alreadyGranted||A===n.notificationsFeedback.granted||A===n.notificationsFeedback.alreadyGranted||A===n.screenFeedback.granted||A===n.screenFeedback.alreadyGranted||A===n.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:A}):null,(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(m,{className:`size-4 text-accent`,strokeWidth:1.75}),n.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.endpointToolsSettings.mobileAccess.flow.background}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.endpointToolsSettings.mobileAccess.flow.sleep})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f?.backgroundSupported,checked:!!f?.runInBackground,onChange:e=>void H({runInBackground:e.target.checked})})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.openAtLogin,onChange:e=>{H({openAtLogin:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.keepAwakePreferred,onChange:e=>{H({keepAwakePreferred:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f||N,checked:!!f?.notifyEnabled,onChange:e=>{U(e.target.checked)}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.notifySoundEnabled,onChange:e=>{H({notifySoundEnabled:e.target.checked})}})]})]})]}),f&&p?(0,C.jsxs)(`section`,{className:y(),children:[(0,C.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:Y}),f.platform===`darwin`&&!f.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:n.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:R||N,"aria-busy":R,className:o(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,s.press),onClick:()=>void V(),children:[(0,C.jsx)(g,{className:o(`size-3.5`,R&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),R?n.refreshing:n.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(f.platform).map(({key:t,pane:i})=>{let a=F(e,p[t]),c=n.perm[t],l=p[t]===`unknown`?I(e,t,f.platform):null;return c?(0,C.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:c.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${a.className}`,children:a.label}),l?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[t===`notifications`&&j(t,p[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:o(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,p[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:o(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,p[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:o(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,p[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:o(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,p[t],f.platform)?(0,C.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,s.press),onClick:()=>void W(i),children:[n.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},t):null})})]}):null]})}export{R as SystemSettingsPanel};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{d as a,l as o,p as s,t as c}from"./chunk-KS7C4IRE-BaASWQor.js";import{i as l,n as u,o as d,r as f,s as p,t as m}from"./dist-CpzYSoz7.js";import{n as h,r as g}from"./popover-select-C-Hj-nXR.js";import{t as _}from"./circle-check-C23XjkUj.js";import{t as v}from"./ellipsis-0k4rZLoy.js";import{t as ee}from"./external-link-DjqjBmc3.js";import{d as te,p as ne,t as y}from"./markdown-view-BXsHghJd.js";import{t as re}from"./folder-open-CyzJ19I9.js";import{t as ie}from"./x-B_N4OPjy.js";import{n as ae,s as oe}from"./locale-store-CBoCuIMx.js";import{t as b}from"./cn-JdwAhgNB.js";import{t as x}from"./button-CtTvuElV.js";import{t as S}from"./skeleton-BwbyijEw.js";import{Ct as se,Gi as C,Go as ce,Ho as le,Jo as ue,Or as w,P as de,Pn as fe,Qo as pe,Sc as T,Si as me,Tl as E,Wo as D,al as he,an as O,cc as k,cn as ge,cs as _e,eu as A,gr as j,in as M,is as N,kr as P,ln as F,ls as I,n as ve,ns as L,oa as ye,on as be,os as xe,pc as Se,ri as Ce,sn as we,ss as Te,wl as Ee}from"./index-DG5CfYat.js";import{t as De}from"./date-picker-DD8b7oad.js";import{t as Oe}from"./dependency-picker-BC9zwIyH.js";var R=e(t(),1),ke=e(n(),1),z=r();function Ae(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function je(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`]){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 B=i();function Me(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Ne(){let e=(0,z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,B.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,B.jsx)(S,{className:`h-32 rounded-2xl`}),(0,B.jsx)(S,{className:`h-52 rounded-2xl`}),(0,B.jsx)(S,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Pe(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Fe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var V=[`backlog`,`ready`,`active`,`review`,`closed`],H=[`low`,`normal`,`high`,`critical`],Ie=(0,R.memo)(function(e){let t=(0,z.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:c,onChange:l}=e,u;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(u=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=u):u=t[4];let d=u,f;t[5]===c?f=t[6]:(f=(0,B.jsx)(`span`,{children:c}),t[5]=c,t[6]=f);let p;t[7]===l?p=t[8]:(p=e=>l(e.target.value),t[7]=l,t[8]=p);let m;t[9]!==s||t[10]!==d?(m=V.map(e=>(0,B.jsx)(g,{value:e,disabled:d(e),children:Me(e,s)},e)),t[9]=s,t[10]=d,t[11]=m):m=t[11];let _;t[12]!==r||t[13]!==p||t[14]!==m||t[15]!==n?(_=(0,B.jsx)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:p,children:m}),t[12]=r,t[13]=p,t[14]=m,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==f||t[18]!==_?(v=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[f,_]}),t[17]=f,t[18]=_,t[19]=v):v=t[19],v}),Le=(0,R.memo)(function(e){let t=(0,z.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=e=>o(e.target.value),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=H.map(e=>(0,B.jsx)(g,{value:e,children:a[e]},e)),t[4]=a,t[5]=l);let u;t[6]!==r||t[7]!==c||t[8]!==l||t[9]!==n?(u=(0,B.jsx)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:c,children:l}),t[6]=r,t[7]=c,t[8]=l,t[9]=n,t[10]=u):u=t[10];let d;return t[11]!==s||t[12]!==u?(d=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,u]}),t[11]=s,t[12]=u,t[13]=d):d=t[13],d}),Re=(0,R.memo)(function(e){let t=(0,z.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,B.jsx)(De,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),ze=(0,R.memo)(function(e){let t=(0,z.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=c);let l;t[2]===s?l=t[3]:(l=e=>s(e.target.value),t[2]=s,t[3]=l);let u;t[4]===a?u=t[5]:(u=(0,B.jsx)(g,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=u);let d;t[6]===o?d=t[7]:(d=o.map(nt),t[6]=o,t[7]=d);let f;t[8]!==r||t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==n?(f=(0,B.jsxs)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:l,children:[u,d]}),t[8]=r,t[9]=l,t[10]=u,t[11]=d,t[12]=n,t[13]=f):f=t[13];let p;return t[14]!==c||t[15]!==f?(p=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,f]}),t[14]=c,t[15]=f,t[16]=p):p=t[16],p}),Be=(0,R.memo)(function(e){let t=(0,z.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(rt),t[0]=r,t[1]=s);let c;return t[2]!==n||t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,B.jsx)(Oe,{borderless:!0,candidates:n,selectedIds:s,disabled:i,onChange:o,labels:a}),t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),Ve=`xopc.taskDetail.chatPanelPercent`,He=42;function Ue(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?He:Math.min(r,Math.max(n,e))}function We(){try{let e=Number(window.localStorage.getItem(Ve));return Number.isFinite(e)&&e>=30&&e<=60?e:He}catch{return He}}function Ge(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 U(e){let t=(0,z.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,B.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,B.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,B.jsx)(t===`passed`?_:t===`failed`?E:Ee,{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,B.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,B.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Ke({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=s(),a=o(),l=ae(e=>e.language),u=oe(e=>e.token),d=(0,R.useMemo)(()=>I(l),[l]),f=ye(e=>e.setPageHeader),p=ye(e=>e.clearPageHeader),m=P(e=>e.open),h=P(e=>e.sessionKeyOverride),g=P(e=>e.openForSession),ie=fe(e=>e.setOpen),{data:S,error:se,mutate:w,lastChange:E,conversationLoading:Ee,conversationError:De}=le(e),[Oe,z]=(0,R.useState)(null),[Me,V]=(0,R.useState)(null),[H,Ke]=(0,R.useState)(()=>new Set),[qe,Je]=(0,R.useState)([]),[W,Ye]=(0,R.useState)(null),[Xe,Ze]=(0,R.useState)([]),[Qe,G]=(0,R.useState)(!1),[$e,et]=(0,R.useState)(``),[tt,K]=(0,R.useState)(!1),[nt,rt]=(0,R.useState)(``),[it,at]=(0,R.useState)(We),[ot,st]=(0,R.useState)(!1),ct=(0,R.useRef)(null),lt=(0,R.useRef)(!1),ut=(0,R.useRef)(!1),dt=(0,R.useRef)(``),ft=(0,R.useRef)(null),pt=(0,R.useRef)(null),mt=(0,R.useRef)(null),ht=(0,R.useRef)(S),[gt,q]=(0,R.useState)(null),[_t,vt]=(0,R.useState)(null),[yt,bt]=(0,R.useState)(!1),xt=(0,R.useMemo)(()=>({link:d.linkDependencies,linked:d.linkedDependencies,searchPlaceholder:d.dependencySearchPlaceholder,noMatches:d.noDependencyMatches,noCandidates:d.noDependencyCandidates,remove:d.removeDependency}),[d.dependencySearchPlaceholder,d.linkDependencies,d.linkedDependencies,d.noDependencyCandidates,d.noDependencyMatches,d.removeDependency]),St=S?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Ct=(0,R.useMemo)(()=>te(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);ht.current=S;let J=(0,R.useCallback)((e,t)=>{Ke(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,R.useEffect)(()=>{V(null),q(null),G(!1),K(!1),vt(null),bt(!1)},[e]),(0,R.useEffect)(()=>{let e=!0;return C().then(t=>{e&&Ze(t.items)}).catch(()=>void 0),()=>{e=!1}},[u]),(0,R.useEffect)(()=>{if(!E||E.source===`user`)return;vt(E);let e=window.setTimeout(()=>vt(null),3500);return()=>window.clearTimeout(e)},[E]),(0,R.useEffect)(()=>{let t=S?.task.projectId,n=S?.dependencies??[];if(!t){mt.current=null,Ye(null),Je(n);return}mt.current!==t&&(mt.current=t,Ye(null));let r=!0;return me(t).then(t=>{if(!r)return;Ye(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});Je([...i.values()])}).catch(()=>{r&&Je(n)}),()=>{r=!1}},[St,S?.task.projectId,e]);let Y=(0,R.useCallback)(async(t,n=`command`)=>{let r=ht.current;if(r){J(n,!0),V(null);try{await w(await ce(e,t,r.task.version),{revalidate:!1})}catch{V(d.actionFailed)}finally{J(n,!1)}}},[d.actionFailed,w,J,e]),X=(0,R.useCallback)(async(t,n)=>{let r=ht.current;if(!r)return!1;n&&J(n,!0),V(null);try{return await w(N(e,t,r.task.version),{optimisticData:je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return V(d.actionFailed),!1}finally{n&&J(n,!1)}},[d.actionFailed,w,J,e]),wt=async()=>{if(!S)return;if(lt.current){lt.current=!1;return}let e=$e.trim(),t=ft.current;if(Ae(t,S.task.version,S.task.title,e)){q(`title`);return}if(!e||e===S.task.title){et(S.task.title),G(!1);return}await X({title:e})&&(q(null),G(!1))},Tt=async()=>{if(!S)return;if(ut.current){ut.current=!1;return}let e=nt.trim(),t=pt.current;if(Ae(t,S.task.version,S.task.body??``,e)){q(`description`);return}if(nt===dt.current||e===(S.task.body??``).trim()){K(!1);return}await X({body:e||null})&&(q(null),K(!1))},Et=(0,R.useCallback)(async e=>{let t=ht.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await Y({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await Y({type:`close`,resolution:`done`},`phase`);return}await Y({type:`move`,phase:e},`phase`)}},[Y]),Dt=(0,R.useCallback)(e=>{X({priority:e},`priority`)},[X]),Ot=(0,R.useCallback)(e=>{X({dueAt:Fe(e)},`dueAt`)},[X]),kt=(0,R.useCallback)(e=>{at(e);try{window.localStorage.setItem(Ve,String(e))}catch{}},[]),At=(0,R.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=ct.current?.clientWidth??0;kt(Ue(e.key===`Home`?He:it+(e.key===`ArrowLeft`?2:-2),t))},[it,kt]),jt=(0,R.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=ct.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),st(!0);let i=it,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=Ue((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{}st(!1),kt(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)},[it,kt]),Mt=(0,R.useCallback)(async t=>{let n=ht.current;if(n){J(`dependencies`,!0),V(null);try{await w(await xe(e,t,n.task.version),{revalidate:!1})}catch{V(d.dependencyUpdateFailed)}finally{J(`dependencies`,!1)}}},[d.dependencyUpdateFailed,w,J,e]),Nt=(0,R.useCallback)(async t=>{let n=ht.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){J(`delegateAgentId`,!0),V(null);try{await w(await pe(e,t,n.task.version),{revalidate:!1})}catch{V(d.actionFailed)}finally{J(`delegateAgentId`,!1)}}},[d.actionFailed,w,J,e]),Pt=(0,R.useCallback)(async()=>{J(`delete`,!0),V(null);try{await ue(e),r?r():a(Ct,{replace:!0})}catch(e){V(e instanceof Error?e.message:d.actionFailed)}finally{J(`delete`,!1)}},[d.actionFailed,a,r,Ct,J,e]);if((0,R.useLayoutEffect)(()=>{if(t!==`modal`)return f({startExtra:(0,B.jsx)(c,{to:Ct,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":d.backToWork,children:(0,B.jsx)(A,{className:`size-4`})}),main:S?(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:W?`${W} / ${d.taskLabel}`:d.taskLabel}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:d.detailStatuses[Ge(S)]})]}):null,end:(0,B.jsx)(`div`,{ref:z,className:`flex min-w-0 items-center justify-end`})}),p},[p,d.backToWork,d.detailStatuses,d.taskLabel,S,t,W,Ct,f]),se&&!S)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:d.taskNotFound});if(!S)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,B.jsx)(Ne,{})});let Ft=S.waits[0],It=Ft?.kind===`paused`?Ft:void 0,Z=S.receipts[0],Lt=d.detailStatuses[Ge(S)],Rt=d.detailStatusDescriptions[Ge(S)],zt=S.task.body?.trim()||S.task.contract?.objective.trim(),Bt=new Map(Z?.verification.checks.map(e=>[e.criterion,e.status])),Vt=S.allowedCommands.includes(`mark_ready`),Ht=S.allowedCommands.includes(`start`),Ut=S.allowedCommands.includes(`add_wait`),Wt=S.task.phase===`review`&&S.allowedCommands.includes(`close`),Gt=S.allowedCommands.includes(`reopen`),Kt=S.conversation.activeSessionKey,qt=S.conversation.currentExecutorAgentId??S.task.delegateAgentId??S.task.ownerId,Jt=Xe.find(e=>e.id===qt),Yt=!!(Kt&&m&&h===Kt),Xt=S.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Zt=S.task.contract?.acceptanceCriteria??[],Qt=Zt.filter(e=>Bt.get(e)===`passed`).length,$t=S.task.contract?.expectedOutputs??[],en=S.task.contract?.constraints??[],tn=S.task.contract?.approvalRequired??[],nn=S.task.contract?.assumptions??[],rn=S.task.contract?.risks??[],Q=(...e)=>!!_t?.changedFields.some(t=>e.includes(t)),an=e=>t===`modal`&&n?_e(n,e):ne(`/tasks/${e}`,Ct),on=S.allowedCommands.includes(`move`),$=H.has(`command`),sn=H.has(`delete`),cn=S.runs.find(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),ln=cn!==void 0,un=(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Vt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`mark_ready`}),children:[(0,B.jsx)(k,{className:`size-4`}),d.scheduleTask]}):null,It?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`resolve_wait`,waitId:It.id}),children:[(0,B.jsx)(k,{className:`size-4`}),d.resumeTask]}):null,!Ft&&Ht&&qt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`start`,executor:{kind:`agent`,agentId:qt}}),children:[(0,B.jsx)(k,{className:`size-4`}),d.runTask]}):null,Wt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`close`,resolution:`done`}),children:[(0,B.jsx)(_,{className:`size-4`}),d.approveTask]}):null,Gt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`reopen`,phase:`ready`}),children:[(0,B.jsx)(k,{className:`size-4`}),d.reopenTask]}):null,!Ft&&Ut?(0,B.jsxs)(x,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:$,onClick:()=>void Y({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,B.jsx)(Se,{className:`size-4`}),d.pauseTask]}):null,(0,B.jsxs)(we,{children:[(0,B.jsx)(F,{asChild:!0,children:(0,B.jsx)(x,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||sn,"aria-label":d.moreActions,children:(0,B.jsx)(v,{className:`size-4`,"aria-hidden":!0})})}),(0,B.jsx)(be,{children:(0,B.jsxs)(M,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[cn?(0,B.jsx)(O,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{J(`command`,!0),V(null),w(D(e,cn.id,cn.version),{revalidate:!1}).catch(()=>V(d.actionFailed)).finally(()=>J(`command`,!1))},children:d.cancelActiveRun}):null,cn?(0,B.jsx)(ge,{className:`my-1 h-px bg-edge`}):null,S.task.phase===`closed`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(O,{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 Y({type:`close`,resolution:`cancelled`}),children:d.cancelTask}),(0,B.jsx)(ge,{className:`my-1 h-px bg-edge`})]}),(0,B.jsx)(O,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{if(ln){V(d.deleteActiveTaskBlocked);return}bt(!0)},children:d.deleteTask})]})})]})]}),Kt&&t!==`modal`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(x,{type:`button`,variant:`ghost`,className:b(`h-8 shrink-0 px-2 text-xs`,Yt&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":Yt,onClick:()=>{ie(Kt,!1),g(Kt)},children:[(0,B.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,B.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,B.jsxs)(c,{to:Te(e),children:[(0,B.jsx)(ee,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]});return(0,B.jsxs)(`div`,{ref:ct,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`} ${ot?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${it}%`},children:[t===`page`&&Oe?(0,ke.createPortal)(un,Oe):null,(0,B.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,B.jsxs)(`header`,{className:b(`px-4 pb-5`,Q(`title`)&&`task-detail-live-update`),children:[(0,B.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[W?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),W]}):null,(0,B.jsx)(`span`,{children:`/`}),(0,B.jsx)(`span`,{children:d.taskLabel}),_t?(0,B.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:_t.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Qe?(0,B.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:$e,onChange:e=>et(e.target.value),onBlur:()=>void wt(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),lt.current=!0,et(S.task.title),G(!1),queueMicrotask(()=>{lt.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,B.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:()=>{ft.current={value:S.task.title,version:S.task.version},q(null),et(S.task.title),G(!0)},children:(0,B.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:S.task.title})}),gt===`title`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{et(S.task.title),q(null),G(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void X({title:$e.trim()}).then(e=>{e&&(q(null),G(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),Me?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:Me}):null]}),(0,B.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,B.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`body`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskDescription}),tt?(0,B.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:nt,onChange:e=>rt(e.target.value),onBlur:()=>void Tt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ut.current=!0,rt(S.task.body??S.task.contract?.objective??``),K(!1),queueMicrotask(()=>{ut.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,B.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=S.task.body??S.task.contract?.objective??``;dt.current=e,pt.current={value:S.task.body??``,version:S.task.version},q(null),rt(e),K(!0)},children:(0,B.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:zt&&zt!==S.task.title?zt:d.noTaskDescription})}),gt===`description`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{rt(S.task.body??``),q(null),K(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void X({body:nt.trim()||null}).then(e=>{e&&(q(null),K(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),S.attention.length>0?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h3`,{className:`font-medium text-fg`,children:Xt?d.needsAttention:d.waitingStatus}),(0,B.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:S.attention.map((e,t)=>(0,B.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`contract`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskDefinition}),(0,B.jsxs)(`div`,{className:`mt-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:d.successDefinition}),Zt.length>0?(0,B.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:d.criteriaProgress.replace(`{{verified}}`,String(Qt)).replace(`{{total}}`,String(Zt.length))}):null]}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:Zt,empty:d.noDefinition,verificationByCriterion:Bt})})]}),$t.length>0?(0,B.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:d.expectedOutputs}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:$t,empty:d.noDefinition})})]}):null,en.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.constraints}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:en,empty:d.noDefinition})})]}):null,tn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.approvalRequired}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:tn,empty:d.noDefinition})})]}):null,nn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.contextAssumptions}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:nn,empty:d.noDefinition})})]}):null,rn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.contextRisks}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:rn,empty:d.noDefinition})})]}):null]}),Z?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.latestResult}),(0,B.jsx)(y,{content:Z.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,B.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[d.receiptStatuses[Z.status],` · `,d.verificationStatuses[Z.verification.status]]})]}),Z.remainingWork.length>0?(0,B.jsxs)(`div`,{className:`mt-4`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:d.remainingWork}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsx)(U,{items:Z.remainingWork,empty:d.noRemainingWork})})]}):null,Z.nextAction?(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.nextAction}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Z.nextAction})]}):null,(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(x,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void L(Z.runId,`helpful`),children:d.doneWell}),(0,B.jsx)(x,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void L(Z.runId,`not_helpful`),children:d.needsFix}),Z.evidence.filter(e=>e.uri).map(e=>(0,B.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,B.jsx)(ee,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),S.receipts.length>1?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:d.executionHistory.replace(`{{count}}`,String(S.receipts.length-1))}),(0,B.jsx)(`div`,{className:`mt-3 space-y-3`,children:S.receipts.slice(1).map(e=>(0,B.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:d.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,S.context.length>0?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`context`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.contextUsed}),(0,B.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:S.context.map(e=>(0,B.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,B.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[d.contextRoleLabels[e.role],` · `,d.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,B.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,B.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,B.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-subtle p-4`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskProperties}),(0,B.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(Ie,{value:S.task.phase,disabled:H.has(`phase`),canMove:on,canApprove:Wt,canReopen:Gt,language:l,label:d.taskPhase,onChange:Et}),(0,B.jsx)(Le,{value:S.task.priority,disabled:H.has(`priority`),label:d.priority,labels:d.priorityLabels,onChange:Dt}),(0,B.jsx)(Re,{value:Pe(S.task.dueAt),disabled:H.has(`dueAt`),label:d.dueDate,onChange:Ot}),(0,B.jsx)(ze,{value:S.conversation.currentExecutorAgentId??``,disabled:H.has(`delegateAgentId`),label:d.executorLabel,unassignedLabel:d.unassigned,agents:Xe,onChange:Nt}),W?(0,B.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,B.jsx)(`span`,{children:d.projectLabel}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,B.jsx)(he,{className:`size-3.5`}),W]})]}):null]}),(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,B.jsx)(`p`,{children:Lt}),(0,B.jsx)(`p`,{children:Rt}),(0,B.jsx)(`p`,{className:`mt-2`,children:d.updatedAt.replace(`{{date}}`,j(S.task.updatedAt,l))})]})]}),(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskRelations}),(0,B.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:d.dependencies}),(0,B.jsx)(Be,{candidates:qe,selected:S.dependencies,disabled:H.has(`dependencies`),labels:xt,onChange:Mt})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:d.dependents}),S.dependents.length>0?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:S.dependents.map(e=>(0,B.jsx)(c,{to:an(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,B.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:d.noDependents})]})]})]})]})]})]}),(0,B.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":l===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(it),tabIndex:0,onPointerDown:jt,onKeyDown:At,onDoubleClick:()=>kt(He),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 ${ot?`bg-surface-hover`:``}`,children:(0,B.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,B.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,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,B.jsx)(`div`,{className:`min-w-0`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[qt?(0,B.jsx)(de,{agentId:qt,avatar:Jt?.avatar,size:28,className:`shrink-0`}):null,(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,B.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[Jt?.name??qt??d.unassigned,` · `,Lt]})]})]})}),t===`modal`?un:null]}),Kt?(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(ve,{embedded:!0,sessionKey:Kt,taskId:e})}):Ee?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(T,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):De?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(T,{className:`mx-auto size-8 text-danger`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:De instanceof Error?De.message:String(De)})]})}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(T,{className:`mx-auto size-8 text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]}),(0,B.jsx)(Ce,{open:yt,title:d.deleteTaskTitle,description:d.deleteTaskDescription.replace(`{{title}}`,S.task.title),confirmLabel:d.confirmDeleteTask,cancelLabel:d.keepTask,destructive:!0,onConfirm:()=>{bt(!1),Pt()},onCancel:()=>bt(!1)})]})}function qe(){let e=(0,z.c)(2),{taskId:t}=a(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,B.jsx)(Ke,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function Je(e){let t=(0,z.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=ae(K),{data:o}=le(n),s=o?.conversation.activeSessionKey??null,h=P(tt),g=P(et),_=P($e),v=P(G),te=fe(Qe),ne=w(Ze),y=w(Xe),oe=h?g:0,x;t[0]!==i||t[1]!==y?(x=e=>{e||(y(null),i())},t[0]=i,t[1]=y,t[2]=x):x=t[2];let S=a===`zh`?`关闭任务详情`:`Close task details`,C;t[3]!==i||t[4]!==y?(C=()=>{y(null),i()},t[3]=i,t[4]=y,t[5]=C):C=t[5];let ce;t[6]!==S||t[7]!==C?(ce=(0,B.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":S,onClick:C}),t[6]=S,t[7]=C,t[8]=ce):ce=t[8];let ue=h?`true`:`false`,de=`${oe/2}px`,pe=`${oe}px`,T;t[9]!==de||t[10]!==pe?(T={"--task-detail-workspace-offset":de,"--task-detail-workspace-width":pe},t[9]=de,t[10]=pe,t[11]=T):T=t[11];let me=T,E=a===`zh`?`任务详情`:`Task details`,D;t[12]===E?D=t[13]:(D=(0,B.jsx)(p,{className:`font-medium text-fg`,children:E}),t[12]=E,t[13]=D);let he=a===`zh`?`查看并操作任务详情`:`View and manage task details`,O;t[14]===he?O=t[15]:(O=(0,B.jsx)(l,{className:`sr-only`,children:he}),t[14]=he,t[15]=O);let k;t[16]!==s||t[17]!==a||t[18]!==v||t[19]!==te||t[20]!==n||t[21]!==h||t[22]!==_?(k=s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:b(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,h&&_===s&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":h&&_===s,onClick:()=>{te(s,!1),v(s)},children:(0,B.jsx)(re,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(c,{to:Te(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,B.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=s,t[17]=a,t[18]=v,t[19]=te,t[20]=n,t[21]=h,t[22]=_,t[23]=k):k=t[23];let ge=a===`zh`?`关闭任务详情`:`Close task details`,_e;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,B.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),t[24]=_e):_e=t[24];let A;t[25]===ge?A=t[26]:(A=(0,B.jsx)(u,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":ge,children:_e}),t[25]=ge,t[26]=A);let j;t[27]!==k||t[28]!==A?(j=(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[k,A]}),t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;t[30]!==D||t[31]!==O||t[32]!==j?(M=(0,B.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[D,O,j]}),t[30]=D,t[31]=O,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==i||t[35]!==y?(N=()=>{y(null),i()},t[34]=i,t[35]=y,t[36]=N):N=t[36];let F;t[37]!==r||t[38]!==N||t[39]!==n?(F=(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,B.jsx)(Ke,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:N})}),t[37]=r,t[38]=N,t[39]=n,t[40]=F):F=t[40];let I;t[41]!==M||t[42]!==F||t[43]!==ue||t[44]!==me?(I=(0,B.jsxs)(f,{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":ue,style:me,onEscapeKeyDown:Ye,onInteractOutside:W,children:[M,F]}),t[41]=M,t[42]=F,t[43]=ue,t[44]=me,t[45]=I):I=t[45];let ve;t[46]!==ne||t[47]!==h||t[48]!==g||t[49]!==_?(ve=ne?(0,B.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:h?g:0},children:(0,B.jsx)(se,{allowOutsideChat:!0,sessionKey:_??void 0})}):null,t[46]=ne,t[47]=h,t[48]=g,t[49]=_,t[50]=ve):ve=t[50];let L;t[51]!==I||t[52]!==ve||t[53]!==ce?(L=(0,B.jsxs)(d,{children:[ce,I,ve]}),t[51]=I,t[52]=ve,t[53]=ce,t[54]=L):L=t[54];let ye;return t[55]!==x||t[56]!==L?(ye=(0,B.jsx)(m,{modal:!1,open:!0,onOpenChange:x,children:L}),t[55]=x,t[56]=L,t[57]=ye):ye=t[57],ye}function W(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Ye(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Xe(e){return e.setPath}function Ze(e){return e.path}function Qe(e){return e.setOpen}function G(e){return e.openForSession}function $e(e){return e.sessionKeyOverride}function et(e){return e.widthPx}function tt(e){return e.open}function K(e){return e.language}function nt(e){return(0,B.jsx)(g,{value:e.id,children:e.name||e.id},e.id)}function rt(e){return e.id}export{Je as TaskDetailModal,qe as TaskDetailPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{d as a,l as o,p as s,t as c}from"./chunk-KS7C4IRE-BaASWQor.js";import{i as l,n as u,o as d,r as f,s as p,t as m}from"./dist-CpzYSoz7.js";import{n as h,r as g}from"./popover-select-C-Hj-nXR.js";import{t as _}from"./circle-check-C23XjkUj.js";import{t as v}from"./ellipsis-0k4rZLoy.js";import{t as ee}from"./external-link-DjqjBmc3.js";import{d as te,p as ne,t as y}from"./markdown-view-BXsHghJd.js";import{t as re}from"./folder-open-CyzJ19I9.js";import{t as ie}from"./x-B_N4OPjy.js";import{n as ae,s as oe}from"./locale-store-CBoCuIMx.js";import{t as b}from"./cn-JdwAhgNB.js";import{t as x}from"./button-CtTvuElV.js";import{t as S}from"./skeleton-BwbyijEw.js";import{Ct as se,Gi as C,Go as ce,Ho as le,Jo as ue,Or as w,P as de,Pn as fe,Qo as pe,Sc as T,Si as me,Tl as E,Wo as D,al as he,an as O,cc as k,cn as ge,cs as _e,eu as A,gr as j,in as M,is as N,kr as P,ln as F,ls as I,n as ve,ns as L,oa as ye,on as be,os as xe,pc as Se,ri as Ce,sn as we,ss as Te,wl as Ee}from"./index-eZjksPvq.js";import{t as De}from"./date-picker-BZuHw-SY.js";import{t as Oe}from"./dependency-picker-BsBD2JFY.js";var R=e(t(),1),ke=e(n(),1),z=r();function Ae(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function je(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`]){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 B=i();function Me(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Ne(){let e=(0,z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,B.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,B.jsx)(S,{className:`h-32 rounded-2xl`}),(0,B.jsx)(S,{className:`h-52 rounded-2xl`}),(0,B.jsx)(S,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Pe(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Fe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var V=[`backlog`,`ready`,`active`,`review`,`closed`],H=[`low`,`normal`,`high`,`critical`],Ie=(0,R.memo)(function(e){let t=(0,z.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:c,onChange:l}=e,u;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(u=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=u):u=t[4];let d=u,f;t[5]===c?f=t[6]:(f=(0,B.jsx)(`span`,{children:c}),t[5]=c,t[6]=f);let p;t[7]===l?p=t[8]:(p=e=>l(e.target.value),t[7]=l,t[8]=p);let m;t[9]!==s||t[10]!==d?(m=V.map(e=>(0,B.jsx)(g,{value:e,disabled:d(e),children:Me(e,s)},e)),t[9]=s,t[10]=d,t[11]=m):m=t[11];let _;t[12]!==r||t[13]!==p||t[14]!==m||t[15]!==n?(_=(0,B.jsx)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:p,children:m}),t[12]=r,t[13]=p,t[14]=m,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==f||t[18]!==_?(v=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[f,_]}),t[17]=f,t[18]=_,t[19]=v):v=t[19],v}),Le=(0,R.memo)(function(e){let t=(0,z.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=e=>o(e.target.value),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=H.map(e=>(0,B.jsx)(g,{value:e,children:a[e]},e)),t[4]=a,t[5]=l);let u;t[6]!==r||t[7]!==c||t[8]!==l||t[9]!==n?(u=(0,B.jsx)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:c,children:l}),t[6]=r,t[7]=c,t[8]=l,t[9]=n,t[10]=u):u=t[10];let d;return t[11]!==s||t[12]!==u?(d=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,u]}),t[11]=s,t[12]=u,t[13]=d):d=t[13],d}),Re=(0,R.memo)(function(e){let t=(0,z.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,B.jsx)(De,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),ze=(0,R.memo)(function(e){let t=(0,z.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=c);let l;t[2]===s?l=t[3]:(l=e=>s(e.target.value),t[2]=s,t[3]=l);let u;t[4]===a?u=t[5]:(u=(0,B.jsx)(g,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=u);let d;t[6]===o?d=t[7]:(d=o.map(nt),t[6]=o,t[7]=d);let f;t[8]!==r||t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==n?(f=(0,B.jsxs)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:l,children:[u,d]}),t[8]=r,t[9]=l,t[10]=u,t[11]=d,t[12]=n,t[13]=f):f=t[13];let p;return t[14]!==c||t[15]!==f?(p=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,f]}),t[14]=c,t[15]=f,t[16]=p):p=t[16],p}),Be=(0,R.memo)(function(e){let t=(0,z.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(rt),t[0]=r,t[1]=s);let c;return t[2]!==n||t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,B.jsx)(Oe,{borderless:!0,candidates:n,selectedIds:s,disabled:i,onChange:o,labels:a}),t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),Ve=`xopc.taskDetail.chatPanelPercent`,He=42;function Ue(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?He:Math.min(r,Math.max(n,e))}function We(){try{let e=Number(window.localStorage.getItem(Ve));return Number.isFinite(e)&&e>=30&&e<=60?e:He}catch{return He}}function Ge(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 U(e){let t=(0,z.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,B.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,B.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,B.jsx)(t===`passed`?_:t===`failed`?E:Ee,{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,B.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,B.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Ke({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=s(),a=o(),l=ae(e=>e.language),u=oe(e=>e.token),d=(0,R.useMemo)(()=>I(l),[l]),f=ye(e=>e.setPageHeader),p=ye(e=>e.clearPageHeader),m=P(e=>e.open),h=P(e=>e.sessionKeyOverride),g=P(e=>e.openForSession),ie=fe(e=>e.setOpen),{data:S,error:se,mutate:w,lastChange:E,conversationLoading:Ee,conversationError:De}=le(e),[Oe,z]=(0,R.useState)(null),[Me,V]=(0,R.useState)(null),[H,Ke]=(0,R.useState)(()=>new Set),[qe,Je]=(0,R.useState)([]),[W,Ye]=(0,R.useState)(null),[Xe,Ze]=(0,R.useState)([]),[Qe,G]=(0,R.useState)(!1),[$e,et]=(0,R.useState)(``),[tt,K]=(0,R.useState)(!1),[nt,rt]=(0,R.useState)(``),[it,at]=(0,R.useState)(We),[ot,st]=(0,R.useState)(!1),ct=(0,R.useRef)(null),lt=(0,R.useRef)(!1),ut=(0,R.useRef)(!1),dt=(0,R.useRef)(``),ft=(0,R.useRef)(null),pt=(0,R.useRef)(null),mt=(0,R.useRef)(null),ht=(0,R.useRef)(S),[gt,q]=(0,R.useState)(null),[_t,vt]=(0,R.useState)(null),[yt,bt]=(0,R.useState)(!1),xt=(0,R.useMemo)(()=>({link:d.linkDependencies,linked:d.linkedDependencies,searchPlaceholder:d.dependencySearchPlaceholder,noMatches:d.noDependencyMatches,noCandidates:d.noDependencyCandidates,remove:d.removeDependency}),[d.dependencySearchPlaceholder,d.linkDependencies,d.linkedDependencies,d.noDependencyCandidates,d.noDependencyMatches,d.removeDependency]),St=S?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Ct=(0,R.useMemo)(()=>te(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);ht.current=S;let J=(0,R.useCallback)((e,t)=>{Ke(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,R.useEffect)(()=>{V(null),q(null),G(!1),K(!1),vt(null),bt(!1)},[e]),(0,R.useEffect)(()=>{let e=!0;return C().then(t=>{e&&Ze(t.items)}).catch(()=>void 0),()=>{e=!1}},[u]),(0,R.useEffect)(()=>{if(!E||E.source===`user`)return;vt(E);let e=window.setTimeout(()=>vt(null),3500);return()=>window.clearTimeout(e)},[E]),(0,R.useEffect)(()=>{let t=S?.task.projectId,n=S?.dependencies??[];if(!t){mt.current=null,Ye(null),Je(n);return}mt.current!==t&&(mt.current=t,Ye(null));let r=!0;return me(t).then(t=>{if(!r)return;Ye(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});Je([...i.values()])}).catch(()=>{r&&Je(n)}),()=>{r=!1}},[St,S?.task.projectId,e]);let Y=(0,R.useCallback)(async(t,n=`command`)=>{let r=ht.current;if(r){J(n,!0),V(null);try{await w(await ce(e,t,r.task.version),{revalidate:!1})}catch{V(d.actionFailed)}finally{J(n,!1)}}},[d.actionFailed,w,J,e]),X=(0,R.useCallback)(async(t,n)=>{let r=ht.current;if(!r)return!1;n&&J(n,!0),V(null);try{return await w(N(e,t,r.task.version),{optimisticData:je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return V(d.actionFailed),!1}finally{n&&J(n,!1)}},[d.actionFailed,w,J,e]),wt=async()=>{if(!S)return;if(lt.current){lt.current=!1;return}let e=$e.trim(),t=ft.current;if(Ae(t,S.task.version,S.task.title,e)){q(`title`);return}if(!e||e===S.task.title){et(S.task.title),G(!1);return}await X({title:e})&&(q(null),G(!1))},Tt=async()=>{if(!S)return;if(ut.current){ut.current=!1;return}let e=nt.trim(),t=pt.current;if(Ae(t,S.task.version,S.task.body??``,e)){q(`description`);return}if(nt===dt.current||e===(S.task.body??``).trim()){K(!1);return}await X({body:e||null})&&(q(null),K(!1))},Et=(0,R.useCallback)(async e=>{let t=ht.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await Y({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await Y({type:`close`,resolution:`done`},`phase`);return}await Y({type:`move`,phase:e},`phase`)}},[Y]),Dt=(0,R.useCallback)(e=>{X({priority:e},`priority`)},[X]),Ot=(0,R.useCallback)(e=>{X({dueAt:Fe(e)},`dueAt`)},[X]),kt=(0,R.useCallback)(e=>{at(e);try{window.localStorage.setItem(Ve,String(e))}catch{}},[]),At=(0,R.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=ct.current?.clientWidth??0;kt(Ue(e.key===`Home`?He:it+(e.key===`ArrowLeft`?2:-2),t))},[it,kt]),jt=(0,R.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=ct.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),st(!0);let i=it,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=Ue((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{}st(!1),kt(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)},[it,kt]),Mt=(0,R.useCallback)(async t=>{let n=ht.current;if(n){J(`dependencies`,!0),V(null);try{await w(await xe(e,t,n.task.version),{revalidate:!1})}catch{V(d.dependencyUpdateFailed)}finally{J(`dependencies`,!1)}}},[d.dependencyUpdateFailed,w,J,e]),Nt=(0,R.useCallback)(async t=>{let n=ht.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){J(`delegateAgentId`,!0),V(null);try{await w(await pe(e,t,n.task.version),{revalidate:!1})}catch{V(d.actionFailed)}finally{J(`delegateAgentId`,!1)}}},[d.actionFailed,w,J,e]),Pt=(0,R.useCallback)(async()=>{J(`delete`,!0),V(null);try{await ue(e),r?r():a(Ct,{replace:!0})}catch(e){V(e instanceof Error?e.message:d.actionFailed)}finally{J(`delete`,!1)}},[d.actionFailed,a,r,Ct,J,e]);if((0,R.useLayoutEffect)(()=>{if(t!==`modal`)return f({startExtra:(0,B.jsx)(c,{to:Ct,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":d.backToWork,children:(0,B.jsx)(A,{className:`size-4`})}),main:S?(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:W?`${W} / ${d.taskLabel}`:d.taskLabel}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:d.detailStatuses[Ge(S)]})]}):null,end:(0,B.jsx)(`div`,{ref:z,className:`flex min-w-0 items-center justify-end`})}),p},[p,d.backToWork,d.detailStatuses,d.taskLabel,S,t,W,Ct,f]),se&&!S)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:d.taskNotFound});if(!S)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,B.jsx)(Ne,{})});let Ft=S.waits[0],It=Ft?.kind===`paused`?Ft:void 0,Z=S.receipts[0],Lt=d.detailStatuses[Ge(S)],Rt=d.detailStatusDescriptions[Ge(S)],zt=S.task.body?.trim()||S.task.contract?.objective.trim(),Bt=new Map(Z?.verification.checks.map(e=>[e.criterion,e.status])),Vt=S.allowedCommands.includes(`mark_ready`),Ht=S.allowedCommands.includes(`start`),Ut=S.allowedCommands.includes(`add_wait`),Wt=S.task.phase===`review`&&S.allowedCommands.includes(`close`),Gt=S.allowedCommands.includes(`reopen`),Kt=S.conversation.activeSessionKey,qt=S.conversation.currentExecutorAgentId??S.task.delegateAgentId??S.task.ownerId,Jt=Xe.find(e=>e.id===qt),Yt=!!(Kt&&m&&h===Kt),Xt=S.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Zt=S.task.contract?.acceptanceCriteria??[],Qt=Zt.filter(e=>Bt.get(e)===`passed`).length,$t=S.task.contract?.expectedOutputs??[],en=S.task.contract?.constraints??[],tn=S.task.contract?.approvalRequired??[],nn=S.task.contract?.assumptions??[],rn=S.task.contract?.risks??[],Q=(...e)=>!!_t?.changedFields.some(t=>e.includes(t)),an=e=>t===`modal`&&n?_e(n,e):ne(`/tasks/${e}`,Ct),on=S.allowedCommands.includes(`move`),$=H.has(`command`),sn=H.has(`delete`),cn=S.runs.find(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),ln=cn!==void 0,un=(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Vt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`mark_ready`}),children:[(0,B.jsx)(k,{className:`size-4`}),d.scheduleTask]}):null,It?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`resolve_wait`,waitId:It.id}),children:[(0,B.jsx)(k,{className:`size-4`}),d.resumeTask]}):null,!Ft&&Ht&&qt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`start`,executor:{kind:`agent`,agentId:qt}}),children:[(0,B.jsx)(k,{className:`size-4`}),d.runTask]}):null,Wt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`close`,resolution:`done`}),children:[(0,B.jsx)(_,{className:`size-4`}),d.approveTask]}):null,Gt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`reopen`,phase:`ready`}),children:[(0,B.jsx)(k,{className:`size-4`}),d.reopenTask]}):null,!Ft&&Ut?(0,B.jsxs)(x,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:$,onClick:()=>void Y({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,B.jsx)(Se,{className:`size-4`}),d.pauseTask]}):null,(0,B.jsxs)(we,{children:[(0,B.jsx)(F,{asChild:!0,children:(0,B.jsx)(x,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||sn,"aria-label":d.moreActions,children:(0,B.jsx)(v,{className:`size-4`,"aria-hidden":!0})})}),(0,B.jsx)(be,{children:(0,B.jsxs)(M,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[cn?(0,B.jsx)(O,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{J(`command`,!0),V(null),w(D(e,cn.id,cn.version),{revalidate:!1}).catch(()=>V(d.actionFailed)).finally(()=>J(`command`,!1))},children:d.cancelActiveRun}):null,cn?(0,B.jsx)(ge,{className:`my-1 h-px bg-edge`}):null,S.task.phase===`closed`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(O,{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 Y({type:`close`,resolution:`cancelled`}),children:d.cancelTask}),(0,B.jsx)(ge,{className:`my-1 h-px bg-edge`})]}),(0,B.jsx)(O,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{if(ln){V(d.deleteActiveTaskBlocked);return}bt(!0)},children:d.deleteTask})]})})]})]}),Kt&&t!==`modal`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(x,{type:`button`,variant:`ghost`,className:b(`h-8 shrink-0 px-2 text-xs`,Yt&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":Yt,onClick:()=>{ie(Kt,!1),g(Kt)},children:[(0,B.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,B.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,B.jsxs)(c,{to:Te(e),children:[(0,B.jsx)(ee,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]});return(0,B.jsxs)(`div`,{ref:ct,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`} ${ot?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${it}%`},children:[t===`page`&&Oe?(0,ke.createPortal)(un,Oe):null,(0,B.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,B.jsxs)(`header`,{className:b(`px-4 pb-5`,Q(`title`)&&`task-detail-live-update`),children:[(0,B.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[W?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),W]}):null,(0,B.jsx)(`span`,{children:`/`}),(0,B.jsx)(`span`,{children:d.taskLabel}),_t?(0,B.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:_t.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Qe?(0,B.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:$e,onChange:e=>et(e.target.value),onBlur:()=>void wt(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),lt.current=!0,et(S.task.title),G(!1),queueMicrotask(()=>{lt.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,B.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:()=>{ft.current={value:S.task.title,version:S.task.version},q(null),et(S.task.title),G(!0)},children:(0,B.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:S.task.title})}),gt===`title`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{et(S.task.title),q(null),G(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void X({title:$e.trim()}).then(e=>{e&&(q(null),G(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),Me?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:Me}):null]}),(0,B.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,B.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`body`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskDescription}),tt?(0,B.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:nt,onChange:e=>rt(e.target.value),onBlur:()=>void Tt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ut.current=!0,rt(S.task.body??S.task.contract?.objective??``),K(!1),queueMicrotask(()=>{ut.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,B.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=S.task.body??S.task.contract?.objective??``;dt.current=e,pt.current={value:S.task.body??``,version:S.task.version},q(null),rt(e),K(!0)},children:(0,B.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:zt&&zt!==S.task.title?zt:d.noTaskDescription})}),gt===`description`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{rt(S.task.body??``),q(null),K(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void X({body:nt.trim()||null}).then(e=>{e&&(q(null),K(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),S.attention.length>0?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h3`,{className:`font-medium text-fg`,children:Xt?d.needsAttention:d.waitingStatus}),(0,B.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:S.attention.map((e,t)=>(0,B.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`contract`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskDefinition}),(0,B.jsxs)(`div`,{className:`mt-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:d.successDefinition}),Zt.length>0?(0,B.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:d.criteriaProgress.replace(`{{verified}}`,String(Qt)).replace(`{{total}}`,String(Zt.length))}):null]}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:Zt,empty:d.noDefinition,verificationByCriterion:Bt})})]}),$t.length>0?(0,B.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:d.expectedOutputs}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:$t,empty:d.noDefinition})})]}):null,en.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.constraints}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:en,empty:d.noDefinition})})]}):null,tn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.approvalRequired}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:tn,empty:d.noDefinition})})]}):null,nn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.contextAssumptions}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:nn,empty:d.noDefinition})})]}):null,rn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.contextRisks}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:rn,empty:d.noDefinition})})]}):null]}),Z?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.latestResult}),(0,B.jsx)(y,{content:Z.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,B.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[d.receiptStatuses[Z.status],` · `,d.verificationStatuses[Z.verification.status]]})]}),Z.remainingWork.length>0?(0,B.jsxs)(`div`,{className:`mt-4`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:d.remainingWork}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsx)(U,{items:Z.remainingWork,empty:d.noRemainingWork})})]}):null,Z.nextAction?(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.nextAction}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Z.nextAction})]}):null,(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(x,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void L(Z.runId,`helpful`),children:d.doneWell}),(0,B.jsx)(x,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void L(Z.runId,`not_helpful`),children:d.needsFix}),Z.evidence.filter(e=>e.uri).map(e=>(0,B.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,B.jsx)(ee,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),S.receipts.length>1?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:d.executionHistory.replace(`{{count}}`,String(S.receipts.length-1))}),(0,B.jsx)(`div`,{className:`mt-3 space-y-3`,children:S.receipts.slice(1).map(e=>(0,B.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:d.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,S.context.length>0?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`context`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.contextUsed}),(0,B.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:S.context.map(e=>(0,B.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,B.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[d.contextRoleLabels[e.role],` · `,d.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,B.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,B.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,B.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-subtle p-4`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskProperties}),(0,B.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(Ie,{value:S.task.phase,disabled:H.has(`phase`),canMove:on,canApprove:Wt,canReopen:Gt,language:l,label:d.taskPhase,onChange:Et}),(0,B.jsx)(Le,{value:S.task.priority,disabled:H.has(`priority`),label:d.priority,labels:d.priorityLabels,onChange:Dt}),(0,B.jsx)(Re,{value:Pe(S.task.dueAt),disabled:H.has(`dueAt`),label:d.dueDate,onChange:Ot}),(0,B.jsx)(ze,{value:S.conversation.currentExecutorAgentId??``,disabled:H.has(`delegateAgentId`),label:d.executorLabel,unassignedLabel:d.unassigned,agents:Xe,onChange:Nt}),W?(0,B.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,B.jsx)(`span`,{children:d.projectLabel}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,B.jsx)(he,{className:`size-3.5`}),W]})]}):null]}),(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,B.jsx)(`p`,{children:Lt}),(0,B.jsx)(`p`,{children:Rt}),(0,B.jsx)(`p`,{className:`mt-2`,children:d.updatedAt.replace(`{{date}}`,j(S.task.updatedAt,l))})]})]}),(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskRelations}),(0,B.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:d.dependencies}),(0,B.jsx)(Be,{candidates:qe,selected:S.dependencies,disabled:H.has(`dependencies`),labels:xt,onChange:Mt})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:d.dependents}),S.dependents.length>0?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:S.dependents.map(e=>(0,B.jsx)(c,{to:an(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,B.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:d.noDependents})]})]})]})]})]})]}),(0,B.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":l===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(it),tabIndex:0,onPointerDown:jt,onKeyDown:At,onDoubleClick:()=>kt(He),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 ${ot?`bg-surface-hover`:``}`,children:(0,B.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,B.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,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,B.jsx)(`div`,{className:`min-w-0`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[qt?(0,B.jsx)(de,{agentId:qt,avatar:Jt?.avatar,size:28,className:`shrink-0`}):null,(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,B.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[Jt?.name??qt??d.unassigned,` · `,Lt]})]})]})}),t===`modal`?un:null]}),Kt?(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(ve,{embedded:!0,sessionKey:Kt,taskId:e})}):Ee?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(T,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):De?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(T,{className:`mx-auto size-8 text-danger`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:De instanceof Error?De.message:String(De)})]})}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(T,{className:`mx-auto size-8 text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]}),(0,B.jsx)(Ce,{open:yt,title:d.deleteTaskTitle,description:d.deleteTaskDescription.replace(`{{title}}`,S.task.title),confirmLabel:d.confirmDeleteTask,cancelLabel:d.keepTask,destructive:!0,onConfirm:()=>{bt(!1),Pt()},onCancel:()=>bt(!1)})]})}function qe(){let e=(0,z.c)(2),{taskId:t}=a(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,B.jsx)(Ke,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function Je(e){let t=(0,z.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=ae(K),{data:o}=le(n),s=o?.conversation.activeSessionKey??null,h=P(tt),g=P(et),_=P($e),v=P(G),te=fe(Qe),ne=w(Ze),y=w(Xe),oe=h?g:0,x;t[0]!==i||t[1]!==y?(x=e=>{e||(y(null),i())},t[0]=i,t[1]=y,t[2]=x):x=t[2];let S=a===`zh`?`关闭任务详情`:`Close task details`,C;t[3]!==i||t[4]!==y?(C=()=>{y(null),i()},t[3]=i,t[4]=y,t[5]=C):C=t[5];let ce;t[6]!==S||t[7]!==C?(ce=(0,B.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":S,onClick:C}),t[6]=S,t[7]=C,t[8]=ce):ce=t[8];let ue=h?`true`:`false`,de=`${oe/2}px`,pe=`${oe}px`,T;t[9]!==de||t[10]!==pe?(T={"--task-detail-workspace-offset":de,"--task-detail-workspace-width":pe},t[9]=de,t[10]=pe,t[11]=T):T=t[11];let me=T,E=a===`zh`?`任务详情`:`Task details`,D;t[12]===E?D=t[13]:(D=(0,B.jsx)(p,{className:`font-medium text-fg`,children:E}),t[12]=E,t[13]=D);let he=a===`zh`?`查看并操作任务详情`:`View and manage task details`,O;t[14]===he?O=t[15]:(O=(0,B.jsx)(l,{className:`sr-only`,children:he}),t[14]=he,t[15]=O);let k;t[16]!==s||t[17]!==a||t[18]!==v||t[19]!==te||t[20]!==n||t[21]!==h||t[22]!==_?(k=s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:b(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,h&&_===s&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":h&&_===s,onClick:()=>{te(s,!1),v(s)},children:(0,B.jsx)(re,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(c,{to:Te(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,B.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=s,t[17]=a,t[18]=v,t[19]=te,t[20]=n,t[21]=h,t[22]=_,t[23]=k):k=t[23];let ge=a===`zh`?`关闭任务详情`:`Close task details`,_e;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,B.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),t[24]=_e):_e=t[24];let A;t[25]===ge?A=t[26]:(A=(0,B.jsx)(u,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":ge,children:_e}),t[25]=ge,t[26]=A);let j;t[27]!==k||t[28]!==A?(j=(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[k,A]}),t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;t[30]!==D||t[31]!==O||t[32]!==j?(M=(0,B.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[D,O,j]}),t[30]=D,t[31]=O,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==i||t[35]!==y?(N=()=>{y(null),i()},t[34]=i,t[35]=y,t[36]=N):N=t[36];let F;t[37]!==r||t[38]!==N||t[39]!==n?(F=(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,B.jsx)(Ke,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:N})}),t[37]=r,t[38]=N,t[39]=n,t[40]=F):F=t[40];let I;t[41]!==M||t[42]!==F||t[43]!==ue||t[44]!==me?(I=(0,B.jsxs)(f,{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":ue,style:me,onEscapeKeyDown:Ye,onInteractOutside:W,children:[M,F]}),t[41]=M,t[42]=F,t[43]=ue,t[44]=me,t[45]=I):I=t[45];let ve;t[46]!==ne||t[47]!==h||t[48]!==g||t[49]!==_?(ve=ne?(0,B.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:h?g:0},children:(0,B.jsx)(se,{allowOutsideChat:!0,sessionKey:_??void 0})}):null,t[46]=ne,t[47]=h,t[48]=g,t[49]=_,t[50]=ve):ve=t[50];let L;t[51]!==I||t[52]!==ve||t[53]!==ce?(L=(0,B.jsxs)(d,{children:[ce,I,ve]}),t[51]=I,t[52]=ve,t[53]=ce,t[54]=L):L=t[54];let ye;return t[55]!==x||t[56]!==L?(ye=(0,B.jsx)(m,{modal:!1,open:!0,onOpenChange:x,children:L}),t[55]=x,t[56]=L,t[57]=ye):ye=t[57],ye}function W(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Ye(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Xe(e){return e.setPath}function Ze(e){return e.path}function Qe(e){return e.setOpen}function G(e){return e.openForSession}function $e(e){return e.sessionKeyOverride}function et(e){return e.widthPx}function tt(e){return e.open}function K(e){return e.language}function nt(e){return(0,B.jsx)(g,{value:e.id,children:e.name||e.id},e.id)}function rt(e){return e.id}export{Je as TaskDetailModal,qe as TaskDetailPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./external-link-DjqjBmc3.js";import{t as a}from"./globe-DSSGFWFn.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-BbdwoxVo.js";import{a as c,i as l,n as u,r as d,s as ee}from"./locale-store-CBoCuIMx.js";import{t as f}from"./cn-JdwAhgNB.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{t as m}from"./button-CtTvuElV.js";import{n as h,r as g}from"./gateway-config-swr-826dipyU.js";import{s as _}from"./form-field-width-DJw_jULe.js";import{t as v}from"./skeleton-BwbyijEw.js";import{Hr as y,Ya as b,ac as x}from"./index-DG5CfYat.js";import{n as te,t as ne}from"./settings-form-section-DjWzRk4z.js";async function S(){return(await c(d(`/api/devices`))).devices}async function C(){let e=await c(d(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersions:e.protocolVersions}}async function w(){try{return{kind:`ready`,setup:(await c(d(`/api/device-pairing/setups`),{method:`POST`,body:JSON.stringify({protocolVersion:3})})).setup}}catch(e){if(e.body?.error?.code===`NO_SECURE_ROUTE`)return{kind:`needs-secure-route`};throw e}}async function T(e){return c(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function E(e){await c(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function D(e,t){await c(d(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function O(e){await c(d(`/api/devices/${encodeURIComponent(e)}`),{method:`DELETE`})}var k=e(t(),1),re=n(),A=r();function j(e){let t=(0,re.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=b(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=f(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,o),t[3]=o,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,A.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,A.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}async function M(){let e=await l(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function ie(e=`serve`){let t=await l(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function N(){let e=await l(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var ae=`https://tailscale.com/download`;function P(e){let t=(0,re.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,A.jsx)(`a`,{href:ae,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function oe({embedded:e=!1}){let t=u(e=>e.language),n=s(t).remoteAccess.tailscale,r=(0,k.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:s(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!ee(e=>e.token),[c,l]=(0,k.useState)(!1),[d,f]=(0,k.useState)(null),{data:h,mutate:g,isLoading:_}=p(i?`exposure-status`:null,M,{refreshInterval:3e4}),b=h?.tailscale.hostname,S=h?.tailscale.active===!0,C=h?.tailscale.cliAvailable!==!1,w=b?`https://${b}/`:null,T=(0,k.useCallback)(async()=>{l(!0),f(null);try{await ie(`serve`),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]),E=(0,k.useCallback)(async()=>{l(!0),f(null);try{await N(),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]);if(!i)return null;let D=(0,A.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,A.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,A.jsxs)(`span`,{children:[n.stepInstallBefore,(0,A.jsx)(P,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,A.jsx)(`span`,{children:n.stepEnable})]}),(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,A.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&h?.tailscale.cliAvailable===!1?(0,A.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,A.jsx)(P,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,_&&!h?(0,A.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,A.jsx)(v,{className:`h-20 rounded-lg`}),(0,A.jsx)(v,{className:`h-20 rounded-lg`})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(ne,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S?n.statusActive:n.statusOff}),w?(0,A.jsx)(`div`,{className:`mt-3`,children:(0,A.jsx)(y,{text:w,labels:r})}):null,d?(0,A.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,A.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:S?(0,A.jsxs)(m,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void E(),children:[c?(0,A.jsx)(o,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,A.jsxs)(m,{type:`button`,disabled:c||!C,onClick:()=>void T(),children:[c?(0,A.jsx)(o,{className:`mr-1 size-4 animate-spin`}):(0,A.jsx)(x,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,A.jsx)(j,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?D:(0,A.jsxs)(ne,{children:[(0,A.jsx)(te,{icon:a,title:n.title,subtitle:n.subtitle}),D]})}async function se(e){let t=await l(d(`/api/tunnel/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function ce(e){await c(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function F(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function le(){return(0,k.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||F(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function ue(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function de(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.gateway;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.publicUrl;return typeof n==`string`&&n.trim()?n.trim():null}function I(){let e=(0,re.c)(85),t=u(pe),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!ee(fe),c=le(),l=g(i).data?.payload?.config,d;e[2]===l?d=e[3]:(d=de(l),e[2]=l,e[3]=d);let p=d,[_,v]=(0,k.useState)(``),y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y={busy:!1,result:null},e[4]=y):y=e[4];let[b,x]=(0,k.useState)(y),S;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(S={busy:!1,error:null},e[5]=S):S=e[5];let[C,w]=(0,k.useState)(S),T,E;e[6]!==p||e[7]!==c||e[8]!==_?(T=()=>{_||(p?v(p):c&&v(c))},E=[p,c,_],e[6]=p,e[7]=c,e[8]=_,e[9]=T,e[10]=E):(T=e[9],E=e[10]),(0,k.useEffect)(T,E);let D;bb0:{let t;e[11]===_?t=e[12]:(t=_.trim(),e[11]=_,e[12]=t);let n=t;if(n){D=n;break bb0}D=p??c??``}let O=D,j=!p&&!!c&&O===c,M;e[13]!==_||e[14]!==O?(M=async()=>{let e=_.trim()||O;if(e){x({busy:!0,result:null});try{x({busy:!1,result:await se(e)})}catch(e){let t=e;x({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=_,e[14]=O,e[15]=M):M=e[15];let ie=M,N;e[16]===O?N=e[17]:(N=async()=>{let e=O.trim();if(e){w({busy:!0,error:null});try{await ce(e),await h(),w({busy:!1,error:null})}catch(e){let t=e;w({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=O,e[17]=N);let ae=N,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{w({busy:!0,error:null});try{await ce(null),await h(),v(``),x({busy:!1,result:null}),w({busy:!1,error:null})}catch(e){let t=e;w({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=P):P=e[18];let oe=P;if(!i)return null;let F;e[19]!==r.subtitle||e[20]!==r.title?(F=(0,A.jsx)(te,{icon:a,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=F):F=e[21];let I;e[22]===r.urlLabel?I=e[23]:(I=(0,A.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=I);let L;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=f(ue(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=L):L=e[24];let R;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{v(e.target.value),x({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==_||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,A.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:_,onChange:R}),e[26]=_,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===ie?B=e[31]:(B=()=>void ie(),e[30]=ie,e[31]=B);let V;e[32]!==_||e[33]!==b.busy?(V=b.busy||!_.trim(),e[32]=_,e[33]=b.busy,e[34]=V):V=e[34];let H;e[35]===b.busy?H=e[36]:(H=b.busy?(0,A.jsx)(o,{className:`size-3.5 animate-spin`}):null,e[35]=b.busy,e[36]=H);let he=b.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,A.jsxs)(m,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:B,disabled:V,children:[H,he]}),e[37]=B,e[38]=V,e[39]=H,e[40]=he,e[41]=U):U=e[41];let W;e[42]!==z||e[43]!==U?(W=(0,A.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[z,U]}),e[42]=z,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==c||e[48]!==j||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=j&&c?(0,A.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,A.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,A.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:c}),(0,A.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=c,e[48]=j,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==b.result||e[53]!==r.probeStatus?(q=b.result?(0,A.jsx)(me,{result:b.result,labels:r.probeStatus}):null,e[52]=b.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==p||e[56]!==O||e[57]!==ae||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==C.busy?(J=O&&p!==O?(0,A.jsxs)(m,{type:`button`,onClick:()=>void ae(),disabled:C.busy,children:[C.busy?(0,A.jsx)(o,{className:`size-3.5 animate-spin`}):null,C.busy?r.saving:r.saveAsDefault]}):null,e[55]=p,e[56]=O,e[57]=ae,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=C.busy,e[61]=J):J=e[61];let Y;e[62]!==p||e[63]!==r.clear||e[64]!==C.busy?(Y=p?(0,A.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>void oe(),disabled:C.busy,children:r.clear}):null,e[62]=p,e[63]=r.clear,e[64]=C.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,A.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[J,Y]}),e[66]=J,e[67]=Y,e[68]=X):X=e[68];let Z;e[69]===C.error?Z=e[70]:(Z=C.error?(0,A.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:C.error}):null,e[69]=C.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,A.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:r.certWarning}),e[71]=r.certWarning,e[72]=Q);let $;e[73]!==I||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,A.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[I,W,G,K,q,X,Z,Q]}),e[73]=I,e[74]=W,e[75]=G,e[76]=K,e[77]=q,e[78]=X,e[79]=Z,e[80]=Q,e[81]=$):$=e[81];let ge;return e[82]!==F||e[83]!==$?(ge=(0,A.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,A.jsxs)(ne,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function fe(e){return e.token}function pe(e){return e.language}function me(e){let t=(0,re.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,A.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,A.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.gatewayReady||t[5]!==n.gatewayReady?(a=n.gatewayReady?(0,A.jsxs)(A.Fragment,{children:[` · `,(0,A.jsx)(`span`,{children:r.gatewayReady})]}):null,t[4]=r.gatewayReady,t[5]=n.gatewayReady,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,A.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,A.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,A.jsxs)(A.Fragment,{children:[` — `,(0,A.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,A.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}async function L(){return c(d(`/api/tunnel/status`))}async function R(){await c(d(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function z(){await c(d(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function B(){return c(d(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function V(e){return c(d(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function H(){let e=(await c(d(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function he(e){await c(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{T as _,H as a,I as c,j as d,E as f,C as g,S as h,R as i,oe as l,D as m,he as n,B as o,w as p,z as r,V as s,L as t,M as u,O as v};
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"./external-link-DjqjBmc3.js";import{t as a}from"./globe-DSSGFWFn.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-BbdwoxVo.js";import{a as c,i as l,n as u,r as d,s as ee}from"./locale-store-CBoCuIMx.js";import{t as f}from"./cn-JdwAhgNB.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{t as m}from"./button-CtTvuElV.js";import{n as h,r as g}from"./gateway-config-swr-826dipyU.js";import{s as _}from"./form-field-width-DJw_jULe.js";import{t as v}from"./skeleton-BwbyijEw.js";import{Hr as y,Ya as b,ac as x}from"./index-eZjksPvq.js";import{n as te,t as ne}from"./settings-form-section-DjWzRk4z.js";async function S(){return(await c(d(`/api/devices`))).devices}async function C(){let e=await c(d(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersions:e.protocolVersions}}async function w(){try{return{kind:`ready`,setup:(await c(d(`/api/device-pairing/setups`),{method:`POST`,body:JSON.stringify({protocolVersion:3})})).setup}}catch(e){if(e.body?.error?.code===`NO_SECURE_ROUTE`)return{kind:`needs-secure-route`};throw e}}async function T(e){return c(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function E(e){await c(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function D(e,t){await c(d(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function O(e){await c(d(`/api/devices/${encodeURIComponent(e)}`),{method:`DELETE`})}var k=e(t(),1),re=n(),A=r();function j(e){let t=(0,re.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=b(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=f(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,o),t[3]=o,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,A.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,A.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}async function M(){let e=await l(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function ie(e=`serve`){let t=await l(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function N(){let e=await l(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var ae=`https://tailscale.com/download`;function P(e){let t=(0,re.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,A.jsx)(`a`,{href:ae,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function oe({embedded:e=!1}){let t=u(e=>e.language),n=s(t).remoteAccess.tailscale,r=(0,k.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:s(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!ee(e=>e.token),[c,l]=(0,k.useState)(!1),[d,f]=(0,k.useState)(null),{data:h,mutate:g,isLoading:_}=p(i?`exposure-status`:null,M,{refreshInterval:3e4}),b=h?.tailscale.hostname,S=h?.tailscale.active===!0,C=h?.tailscale.cliAvailable!==!1,w=b?`https://${b}/`:null,T=(0,k.useCallback)(async()=>{l(!0),f(null);try{await ie(`serve`),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]),E=(0,k.useCallback)(async()=>{l(!0),f(null);try{await N(),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]);if(!i)return null;let D=(0,A.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,A.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,A.jsxs)(`span`,{children:[n.stepInstallBefore,(0,A.jsx)(P,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,A.jsx)(`span`,{children:n.stepEnable})]}),(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,A.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&h?.tailscale.cliAvailable===!1?(0,A.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,A.jsx)(P,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,_&&!h?(0,A.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,A.jsx)(v,{className:`h-20 rounded-lg`}),(0,A.jsx)(v,{className:`h-20 rounded-lg`})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(ne,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S?n.statusActive:n.statusOff}),w?(0,A.jsx)(`div`,{className:`mt-3`,children:(0,A.jsx)(y,{text:w,labels:r})}):null,d?(0,A.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,A.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:S?(0,A.jsxs)(m,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void E(),children:[c?(0,A.jsx)(o,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,A.jsxs)(m,{type:`button`,disabled:c||!C,onClick:()=>void T(),children:[c?(0,A.jsx)(o,{className:`mr-1 size-4 animate-spin`}):(0,A.jsx)(x,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,A.jsx)(j,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?D:(0,A.jsxs)(ne,{children:[(0,A.jsx)(te,{icon:a,title:n.title,subtitle:n.subtitle}),D]})}async function se(e){let t=await l(d(`/api/tunnel/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function ce(e){await c(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function F(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function le(){return(0,k.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||F(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function ue(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function de(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.gateway;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.publicUrl;return typeof n==`string`&&n.trim()?n.trim():null}function I(){let e=(0,re.c)(85),t=u(pe),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!ee(fe),c=le(),l=g(i).data?.payload?.config,d;e[2]===l?d=e[3]:(d=de(l),e[2]=l,e[3]=d);let p=d,[_,v]=(0,k.useState)(``),y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y={busy:!1,result:null},e[4]=y):y=e[4];let[b,x]=(0,k.useState)(y),S;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(S={busy:!1,error:null},e[5]=S):S=e[5];let[C,w]=(0,k.useState)(S),T,E;e[6]!==p||e[7]!==c||e[8]!==_?(T=()=>{_||(p?v(p):c&&v(c))},E=[p,c,_],e[6]=p,e[7]=c,e[8]=_,e[9]=T,e[10]=E):(T=e[9],E=e[10]),(0,k.useEffect)(T,E);let D;bb0:{let t;e[11]===_?t=e[12]:(t=_.trim(),e[11]=_,e[12]=t);let n=t;if(n){D=n;break bb0}D=p??c??``}let O=D,j=!p&&!!c&&O===c,M;e[13]!==_||e[14]!==O?(M=async()=>{let e=_.trim()||O;if(e){x({busy:!0,result:null});try{x({busy:!1,result:await se(e)})}catch(e){let t=e;x({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=_,e[14]=O,e[15]=M):M=e[15];let ie=M,N;e[16]===O?N=e[17]:(N=async()=>{let e=O.trim();if(e){w({busy:!0,error:null});try{await ce(e),await h(),w({busy:!1,error:null})}catch(e){let t=e;w({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=O,e[17]=N);let ae=N,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{w({busy:!0,error:null});try{await ce(null),await h(),v(``),x({busy:!1,result:null}),w({busy:!1,error:null})}catch(e){let t=e;w({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=P):P=e[18];let oe=P;if(!i)return null;let F;e[19]!==r.subtitle||e[20]!==r.title?(F=(0,A.jsx)(te,{icon:a,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=F):F=e[21];let I;e[22]===r.urlLabel?I=e[23]:(I=(0,A.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=I);let L;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=f(ue(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=L):L=e[24];let R;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{v(e.target.value),x({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==_||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,A.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:_,onChange:R}),e[26]=_,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===ie?B=e[31]:(B=()=>void ie(),e[30]=ie,e[31]=B);let V;e[32]!==_||e[33]!==b.busy?(V=b.busy||!_.trim(),e[32]=_,e[33]=b.busy,e[34]=V):V=e[34];let H;e[35]===b.busy?H=e[36]:(H=b.busy?(0,A.jsx)(o,{className:`size-3.5 animate-spin`}):null,e[35]=b.busy,e[36]=H);let he=b.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,A.jsxs)(m,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:B,disabled:V,children:[H,he]}),e[37]=B,e[38]=V,e[39]=H,e[40]=he,e[41]=U):U=e[41];let W;e[42]!==z||e[43]!==U?(W=(0,A.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[z,U]}),e[42]=z,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==c||e[48]!==j||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=j&&c?(0,A.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,A.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,A.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:c}),(0,A.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=c,e[48]=j,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==b.result||e[53]!==r.probeStatus?(q=b.result?(0,A.jsx)(me,{result:b.result,labels:r.probeStatus}):null,e[52]=b.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==p||e[56]!==O||e[57]!==ae||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==C.busy?(J=O&&p!==O?(0,A.jsxs)(m,{type:`button`,onClick:()=>void ae(),disabled:C.busy,children:[C.busy?(0,A.jsx)(o,{className:`size-3.5 animate-spin`}):null,C.busy?r.saving:r.saveAsDefault]}):null,e[55]=p,e[56]=O,e[57]=ae,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=C.busy,e[61]=J):J=e[61];let Y;e[62]!==p||e[63]!==r.clear||e[64]!==C.busy?(Y=p?(0,A.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>void oe(),disabled:C.busy,children:r.clear}):null,e[62]=p,e[63]=r.clear,e[64]=C.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,A.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[J,Y]}),e[66]=J,e[67]=Y,e[68]=X):X=e[68];let Z;e[69]===C.error?Z=e[70]:(Z=C.error?(0,A.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:C.error}):null,e[69]=C.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,A.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:r.certWarning}),e[71]=r.certWarning,e[72]=Q);let $;e[73]!==I||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,A.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[I,W,G,K,q,X,Z,Q]}),e[73]=I,e[74]=W,e[75]=G,e[76]=K,e[77]=q,e[78]=X,e[79]=Z,e[80]=Q,e[81]=$):$=e[81];let ge;return e[82]!==F||e[83]!==$?(ge=(0,A.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,A.jsxs)(ne,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function fe(e){return e.token}function pe(e){return e.language}function me(e){let t=(0,re.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,A.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,A.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.gatewayReady||t[5]!==n.gatewayReady?(a=n.gatewayReady?(0,A.jsxs)(A.Fragment,{children:[` · `,(0,A.jsx)(`span`,{children:r.gatewayReady})]}):null,t[4]=r.gatewayReady,t[5]=n.gatewayReady,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,A.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,A.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,A.jsxs)(A.Fragment,{children:[` — `,(0,A.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,A.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}async function L(){return c(d(`/api/tunnel/status`))}async function R(){await c(d(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function z(){await c(d(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function B(){return c(d(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function V(e){return c(d(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function H(){let e=(await c(d(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function he(e){await c(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{T as _,H as a,I as c,j as d,E as f,C as g,S as h,R as i,oe as l,D as m,he as n,B as o,w as p,z as r,V as s,L as t,M as u,O as v};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./check-DUBLcKHA.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{n as o}from"./locale-store-CBoCuIMx.js";import{t as s}from"./cn-JdwAhgNB.js";import{Nl as c}from"./index-DG5CfYat.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=o(f)===`zh`,m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:p?`自动保存`:`Autosave`,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=s(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(a,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};
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"./check-DUBLcKHA.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{n as o}from"./locale-store-CBoCuIMx.js";import{t as s}from"./cn-JdwAhgNB.js";import{Nl as c}from"./index-eZjksPvq.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=o(f)===`zh`,m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:p?`自动保存`:`Autosave`,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=s(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(a,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};