@xopcai/xopc 0.0.238 → 0.0.239

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 (79) 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-BCZ6T3y8.js → agent-avatar-dicebear-C1rtpjd7.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-KPtQudPf.js → agent-defaults-settings-panel-oW6wFuP9.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-DKQZKGCB.js → agents-V-nDPOk2.js} +1 -1
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-B_h6HVgw.js → app-management-settings-panel-CRDnRN4G.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-D07Ew40N.js → appearance-settings-BCYZIKqQ.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-_toby2SK.js → apps-page-dcvQDCvy.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-C2Ac3q6g.js → attachment-load-Bgfh7Ag2.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automations-page-Bc4Is3z0.js → automations-page-BdH131M0.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-workspace-DH-QeQ0O.js → automations-workspace-BtwzQZAR.js} +1 -1
  12. package/dist/gateway/static/root/assets/{binary-plugins-yMQJYHIQ.js → binary-plugins-BwXg9na-.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-DrNzI_0p.js → block-editor-BngtUSNv.js} +1 -1
  14. package/dist/gateway/static/root/assets/{browser-settings-page-Bv8GclZd.js → browser-settings-page-kfNOKQ2x.js} +1 -1
  15. package/dist/gateway/static/root/assets/{browser-workflows-page-D_EOs50E.js → browser-workflows-page-Ael9sxrp.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capabilities-settings-panel-gKLN0aaW.js → capabilities-settings-panel-DOymgkUM.js} +1 -1
  17. package/dist/gateway/static/root/assets/{channels-settings-Bh7BqWsN.js → channels-settings-YscUvFub.js} +1 -1
  18. package/dist/gateway/static/root/assets/{chat-terminal-dock-B7agEwma.js → chat-terminal-dock-DI0lYVKk.js} +1 -1
  19. package/dist/gateway/static/root/assets/{connectors-page-DifO0WX4.js → connectors-page-BtzCRQGz.js} +1 -1
  20. package/dist/gateway/static/root/assets/{cron-expression-bjxQQFdv.js → cron-expression-CLuvPZ3b.js} +1 -1
  21. package/dist/gateway/static/root/assets/{date-picker-C7ujLHll.js → date-picker-D4QS8Zzn.js} +1 -1
  22. package/dist/gateway/static/root/assets/{dependency-picker-rl8E7nXp.js → dependency-picker-DZn-RhEm.js} +1 -1
  23. package/dist/gateway/static/root/assets/{desktop-pet-D4GbYBcD.js → desktop-pet-C6KqTQas.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-settings-Bo34tFlD.js → desktop-pet-settings-Bov3XuPO.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-debug-page-DuPa1bVQ.js → extension-debug-page-DpeeYAjX.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-page-CB9xF3qo.js → extension-page-Cescx_be.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-CovEdmGD.js → extension-settings-page-C_ubW61U.js} +1 -1
  28. package/dist/gateway/static/root/assets/{gateway-config-api-CAaoukkR.js → gateway-config-api-BM79X1jC.js} +1 -1
  29. package/dist/gateway/static/root/assets/{gateway-settings-CesXGTe3.js → gateway-settings-GV5KAj-l.js} +1 -1
  30. package/dist/gateway/static/root/assets/{heartbeat-settings-Bu5cIcNb.js → heartbeat-settings-CZ1KeXXU.js} +1 -1
  31. package/dist/gateway/static/root/assets/{home-page-sQfx98tH.js → home-page-YdVal_8I.js} +1 -1
  32. package/dist/gateway/static/root/assets/{index-C9rUND9-.css → index-7GLgmvAm.css} +1 -1
  33. package/dist/gateway/static/root/assets/{index-C73V7tJP.js → index-DKP23eMn.js} +8 -8
  34. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CpZxPmd0.js → keyboard-shortcuts-settings-Tn7xSeVT.js} +1 -1
  35. package/dist/gateway/static/root/assets/{local-app-workbench-page-DjvHSI0e.js → local-app-workbench-page-DCt7cbvK.js} +1 -1
  36. package/dist/gateway/static/root/assets/{local-apps-page-5KTZwLbX.js → local-apps-page-Co5_qKEQ.js} +1 -1
  37. package/dist/gateway/static/root/assets/{logs-page-frYgoe2x.js → logs-page-ChfSQQSV.js} +1 -1
  38. package/dist/gateway/static/root/assets/{management-settings-9iZjSpHe.js → management-settings-DE0o5c7Y.js} +1 -1
  39. package/dist/gateway/static/root/assets/{markdown-split-C4-0M8mu.js → markdown-split-CADkGbQi.js} +1 -1
  40. package/dist/gateway/static/root/assets/{media-plugins-CjMa9GMF.js → media-plugins-mHodPaFz.js} +1 -1
  41. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-DikJ7HCm.js → mobile-pairing-wizard-43FyMswX.js} +1 -1
  42. package/dist/gateway/static/root/assets/{notes-page-CC45W2KR.js → notes-page-BMUyJStB.js} +1 -1
  43. package/dist/gateway/static/root/assets/{notes-workbench-BFreGbmY.js → notes-workbench-DjHIQneE.js} +2 -2
  44. package/dist/gateway/static/root/assets/{project-detail-page-53z9nB5L.js → project-detail-page-CXD2pVgQ.js} +1 -1
  45. package/dist/gateway/static/root/assets/{projects-page-DR7OvyAl.js → projects-page-cqKqkTwG.js} +1 -1
  46. package/dist/gateway/static/root/assets/{remote-access-hub-BkSGDDbn.js → remote-access-hub-UEinEd7d.js} +1 -1
  47. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DLv-QsQo.js → runtime-tools-settings-panel-ClCEmwPY.js} +1 -1
  48. package/dist/gateway/static/root/assets/{schema-form-DDW7aJWa.js → schema-form-0vcUqeqa.js} +1 -1
  49. package/dist/gateway/static/root/assets/{sessions-page-C-yaSuuQ.js → sessions-page-Cc6ve-qc.js} +1 -1
  50. package/dist/gateway/static/root/assets/settings-advanced-gate-_J5FSEYX.js +1 -0
  51. package/dist/gateway/static/root/assets/{settings-form-section-5NTg906_.js → settings-form-section-BkdLf_sS.js} +1 -1
  52. package/dist/gateway/static/root/assets/{settings-page-DgTYtrmh.js → settings-page-QBTaBpBn.js} +1 -1
  53. package/dist/gateway/static/root/assets/{setup-status-panel-Dm_gdAfm.js → setup-status-panel-bQcSMkVr.js} +1 -1
  54. package/dist/gateway/static/root/assets/{share-preview-page-BX2Ev7-I.js → share-preview-page-D_OuXnah.js} +1 -1
  55. package/dist/gateway/static/root/assets/{shares-settings-D2Zd9l04.js → shares-settings-DJfcpok3.js} +1 -1
  56. package/dist/gateway/static/root/assets/{skill-reload-api-BvND7xsL.js → skill-reload-api-Bbqp5HaH.js} +1 -1
  57. package/dist/gateway/static/root/assets/{skills-page-Cmqu9f_n.js → skills-page-BNcnmaTg.js} +1 -1
  58. package/dist/gateway/static/root/assets/{skills-page.utils-KOxLvm84.js → skills-page.utils-BWWcFShl.js} +1 -1
  59. package/dist/gateway/static/root/assets/{system-settings-panel-CS7cDwv2.js → system-settings-panel-BsH7b3B4.js} +1 -1
  60. package/dist/gateway/static/root/assets/{task-detail-page-COpgFG6K.js → task-detail-page-CcAhyw2Z.js} +1 -1
  61. package/dist/gateway/static/root/assets/{tunnel-api-D3h311_s.js → tunnel-api-D5-Hggt3.js} +1 -1
  62. package/dist/gateway/static/root/assets/{use-autosave-DvATIVb_.js → use-autosave-Dp1ycDa8.js} +1 -1
  63. package/dist/gateway/static/root/assets/{user-context-page-PKrbPu4w.js → user-context-page-Dd_oMNie.js} +1 -1
  64. package/dist/gateway/static/root/assets/{voice-api-key-field-C3BgRKG2.js → voice-api-key-field-DhrQXH3c.js} +1 -1
  65. package/dist/gateway/static/root/assets/{work-discovery-overlay-DHcQSZZD.js → work-discovery-overlay-B7zKAPrb.js} +1 -1
  66. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Nx6xmy_N.js → workflow-run-setup-panel-Cek9K48F.js} +1 -1
  67. package/dist/gateway/static/root/assets/{workflows-page-DBkP6B4E.js → workflows-page-T2q2Mx6H.js} +1 -1
  68. package/dist/gateway/static/root/index.html +2 -2
  69. package/dist/package.js +1 -1
  70. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  71. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  72. package/dist/src/extensions/update.js +1 -1
  73. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  74. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  75. package/dist/src/gateway/service/config-coordinator.js +1 -1
  76. package/dist/src/infra/update-restart.js +1 -1
  77. package/dist/src/infra/update-runner.js +1 -1
  78. package/package.json +4 -4
  79. package/dist/gateway/static/root/assets/settings-advanced-gate-CelrRPXt.js +0 -1
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{i as r,r as i,s as a}from"./locale-store-XDFAPNNu.js";import{Zn as o}from"./index-C73V7tJP.js";import"./skill-reload-api-BvND7xsL.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 r=a.getState().token,o=new Headers;r&&o.set(`Authorization`,`Bearer ${r}`);let s=await fetch(i(`/api/skills/upload`),{method:`POST`,headers:o,body:n});s.status===401&&a.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 n=t?`?target=${encodeURIComponent(t)}`:``,a=await r(i(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!a.ok)throw Error(await o(a))}async function l(e,t){let n=await r(i(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await o(n))}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 n=t.toString(),a=await r(i(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{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 n=t.toString(),a=await r(i(`/api/skills/marketplace${n?`?${n}`:``}`),{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 n=encodeURIComponent(e),a=new URLSearchParams;u(a,t?.provider);let s=a.toString(),c=await r(i(`/api/skills/marketplace/packages/${n}${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 r(i(`/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 n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function h(e){let t=await r(i(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let n=(await t.json()).payload;if(!n||typeof n.name!=`string`||typeof n.description!=`string`||typeof n.bodyMarkdown!=`string`||typeof n.disableModelInvocation!=`boolean`||!n.metadata||typeof n.metadata!=`object`||typeof n.metadata.name!=`string`||typeof n.metadata.description!=`string`)throw Error(`Invalid response`);return n}async function g(){let e=await r(i(`/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 r(i(`/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:r,className:i}=e,a;t[0]===r?a=t[1]:(a=S(r),t[0]=r,t[1]=a);let o=a,s=b[x(r)%b.length],c;t[2]!==i||t[3]!==s.dark||t[4]!==s.light?(c=n(`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,i),t[2]=i,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{t as n}from"./cn-JdwAhgNB.js";import{i as r,r as i,s as a}from"./locale-store-XDFAPNNu.js";import{Zn as o}from"./index-DKP23eMn.js";import"./skill-reload-api-Bbqp5HaH.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 r=a.getState().token,o=new Headers;r&&o.set(`Authorization`,`Bearer ${r}`);let s=await fetch(i(`/api/skills/upload`),{method:`POST`,headers:o,body:n});s.status===401&&a.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 n=t?`?target=${encodeURIComponent(t)}`:``,a=await r(i(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!a.ok)throw Error(await o(a))}async function l(e,t){let n=await r(i(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await o(n))}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 n=t.toString(),a=await r(i(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{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 n=t.toString(),a=await r(i(`/api/skills/marketplace${n?`?${n}`:``}`),{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 n=encodeURIComponent(e),a=new URLSearchParams;u(a,t?.provider);let s=a.toString(),c=await r(i(`/api/skills/marketplace/packages/${n}${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 r(i(`/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 n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function h(e){let t=await r(i(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let n=(await t.json()).payload;if(!n||typeof n.name!=`string`||typeof n.description!=`string`||typeof n.bodyMarkdown!=`string`||typeof n.disableModelInvocation!=`boolean`||!n.metadata||typeof n.metadata!=`object`||typeof n.metadata.name!=`string`||typeof n.metadata.description!=`string`)throw Error(`Invalid response`);return n}async function g(){let e=await r(i(`/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 r(i(`/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:r,className:i}=e,a;t[0]===r?a=t[1]:(a=S(r),t[0]=r,t[1]=a);let o=a,s=b[x(r)%b.length],c;t[2]!==i||t[3]!==s.dark||t[4]!==s.light?(c=n(`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,i),t[2]=i,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"./cn-JdwAhgNB.js";import{n as a}from"./interaction-BmQogeqz.js";import{t as o}from"./messages-B1HDp_j8.js";import{n as s}from"./locale-store-XDFAPNNu.js";import{t as c}from"./electron-env-DH5wF8X8.js";import{Dn as l,En as u,Tn as d,ml as f,ms as p,rs as m,sa as h,wn as g}from"./index-C73V7tJP.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-5NTg906_.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=o(s(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(u),[r,i]=(0,x.useState)(null),[a,c]=(0,x.useState)(!1),p=async t=>{if(!t){n(l({enabled:!1})),i(null);return}c(!0);try{let t=await g();if(t!==`granted`){i(t===`unsupported`?e.unsupported:e.denied);return}n(l({enabled:!0})),i(await d(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},m=e=>{n(l(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)(f,{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:a||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?p(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=o(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=o(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=s(e=>e.language),t=o(e),n=t.systemSettings,[l,u]=(0,x.useReducer)(h,L),{behavior:d,perms:f,loadError:g,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=d?d.platform===`win32`?n.permissionsHintWin:d.platform===`linux`?n.permissionsHintLinux:d.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:n.title}),g?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:g}):null,A?(0,C.jsx)(`p`,{className:i(`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:!d?.backgroundSupported,checked:!!d?.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:!d,checked:!!d?.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:!d,checked:!!d?.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:!d||N,checked:!!d?.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:!d,checked:!!d?.notifySoundEnabled,onChange:e=>{H({notifySoundEnabled:e.target.checked})}})]})]})]}),d&&f?(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}),d.platform===`darwin`&&!d.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:i(`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`,a.press),onClick:()=>void V(),children:[(0,C.jsx)(p,{className:i(`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(d.platform).map(({key:t,pane:o})=>{let s=F(e,f[t]),c=n.perm[t],l=f[t]===`unknown`?I(e,t,d.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 ${s.className}`,children:s.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,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:i(`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`,a.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:i(`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`,a.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:i(`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`,a.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:i(`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`,a.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,f[t],d.platform)?(0,C.jsxs)(`button`,{type:`button`,className:i(`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`,a.press),onClick:()=>void W(o),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"./cn-JdwAhgNB.js";import{n as a}from"./interaction-BmQogeqz.js";import{t as o}from"./messages-B1HDp_j8.js";import{n as s}from"./locale-store-XDFAPNNu.js";import{t as c}from"./electron-env-DH5wF8X8.js";import{Dn as l,En as u,Tn as d,ml as f,ms as p,rs as m,sa as h,wn as g}from"./index-DKP23eMn.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-BkdLf_sS.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=o(s(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(u),[r,i]=(0,x.useState)(null),[a,c]=(0,x.useState)(!1),p=async t=>{if(!t){n(l({enabled:!1})),i(null);return}c(!0);try{let t=await g();if(t!==`granted`){i(t===`unsupported`?e.unsupported:e.denied);return}n(l({enabled:!0})),i(await d(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},m=e=>{n(l(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)(f,{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:a||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?p(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=o(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=o(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=s(e=>e.language),t=o(e),n=t.systemSettings,[l,u]=(0,x.useReducer)(h,L),{behavior:d,perms:f,loadError:g,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=d?d.platform===`win32`?n.permissionsHintWin:d.platform===`linux`?n.permissionsHintLinux:d.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:n.title}),g?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:g}):null,A?(0,C.jsx)(`p`,{className:i(`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:!d?.backgroundSupported,checked:!!d?.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:!d,checked:!!d?.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:!d,checked:!!d?.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:!d||N,checked:!!d?.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:!d,checked:!!d?.notifySoundEnabled,onChange:e=>{H({notifySoundEnabled:e.target.checked})}})]})]})]}),d&&f?(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}),d.platform===`darwin`&&!d.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:i(`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`,a.press),onClick:()=>void V(),children:[(0,C.jsx)(p,{className:i(`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(d.platform).map(({key:t,pane:o})=>{let s=F(e,f[t]),c=n.perm[t],l=f[t]===`unknown`?I(e,t,d.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 ${s.className}`,children:s.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,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:i(`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`,a.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:i(`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`,a.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:i(`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`,a.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,f[t],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:i(`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`,a.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,f[t],d.platform)?(0,C.jsxs)(`button`,{type:`button`,className:i(`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`,a.press),onClick:()=>void W(o),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{n as l,r as u}from"./popover-select-DBrVS3tZ.js";import{t as d}from"./circle-check-C23XjkUj.js";import{t as f}from"./ellipsis-0k4rZLoy.js";import{t as p}from"./external-link-DjqjBmc3.js";import{d as m,p as h,t as g}from"./markdown-view-v-O3cOpk.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./cn-JdwAhgNB.js";import{t as y}from"./button-CSEbl4zT.js";import{n as ee,s as b}from"./locale-store-XDFAPNNu.js";import{t as x}from"./skeleton-BwbyijEw.js";import{i as te,n as ne,o as re,r as ie,s as ae,t as S}from"./dist-BPoKqzeH.js";import{$r as C,A as oe,Aa as w,B as T,Cc as se,Di as ce,Hr as le,I as ue,J as de,K as fe,M as pe,N as E,Os as me,Qr as he,Sn as D,Ss as O,Uc as k,W as ge,Wc as _e,Y as A,ar as j,bn as ve,cr as M,ir as N,lr as P,n as F,or as I,pa as L,qi as ye,sr as be,tt as xe,ur as Se,wc as Ce,xn as we,yl as Te,zs as Ee}from"./index-C73V7tJP.js";import{t as De}from"./date-picker-C7ujLHll.js";import{t as Oe}from"./dependency-picker-rl8E7nXp.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)(x,{className:`h-32 rounded-2xl`}),(0,B.jsx)(x,{className:`h-52 rounded-2xl`}),(0,B.jsx)(x,{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:d}=e,f;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(f=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=f):f=t[4];let p=f,m;t[5]===c?m=t[6]:(m=(0,B.jsx)(`span`,{children:c}),t[5]=c,t[6]=m);let h;t[7]===d?h=t[8]:(h=e=>d(e.target.value),t[7]=d,t[8]=h);let g;t[9]!==s||t[10]!==p?(g=V.map(e=>(0,B.jsx)(u,{value:e,disabled:p(e),children:Me(e,s)},e)),t[9]=s,t[10]=p,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==h||t[14]!==g||t[15]!==n?(_=(0,B.jsx)(l,{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:h,children:g}),t[12]=r,t[13]=h,t[14]=g,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==m||t[18]!==_?(v=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[m,_]}),t[17]=m,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 d;t[4]===a?d=t[5]:(d=H.map(e=>(0,B.jsx)(u,{value:e,children:a[e]},e)),t[4]=a,t[5]=d);let f;t[6]!==r||t[7]!==c||t[8]!==d||t[9]!==n?(f=(0,B.jsx)(l,{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:d}),t[6]=r,t[7]=c,t[8]=d,t[9]=n,t[10]=f):f=t[10];let p;return t[11]!==s||t[12]!==f?(p=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,f]}),t[11]=s,t[12]=f,t[13]=p):p=t[13],p}),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 d;t[2]===s?d=t[3]:(d=e=>s(e.target.value),t[2]=s,t[3]=d);let f;t[4]===a?f=t[5]:(f=(0,B.jsx)(u,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(nt),t[6]=o,t[7]=p);let m;t[8]!==r||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==n?(m=(0,B.jsxs)(l,{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:d,children:[f,p]}),t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=n,t[13]=m):m=t[13];let h;return t[14]!==c||t[15]!==m?(h=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,m]}),t[14]=c,t[15]=m,t[16]=h):h=t[16],h}),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`?d:t===`failed`?_e:k,{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=ee(e=>e.language),u=b(e=>e.token),_=(0,R.useMemo)(()=>A(l),[l]),x=w(e=>e.setPageHeader),te=w(e=>e.clearPageHeader),ne=C(e=>e.open),re=C(e=>e.sessionKeyOverride),ie=C(e=>e.openForSession),ae=Se(e=>e.setOpen),{data:S,error:he,mutate:D,lastChange:k,conversationLoading:_e,conversationError:De}=oe(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:_.linkDependencies,linked:_.linkedDependencies,searchPlaceholder:_.dependencySearchPlaceholder,noMatches:_.noDependencyMatches,noCandidates:_.noDependencyCandidates,remove:_.removeDependency}),[_.dependencySearchPlaceholder,_.linkDependencies,_.linkedDependencies,_.noDependencyCandidates,_.noDependencyMatches,_.removeDependency]),St=S?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Ct=(0,R.useMemo)(()=>m(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 L().then(t=>{e&&Ze(t.items)}).catch(()=>void 0),()=>{e=!1}},[u]),(0,R.useEffect)(()=>{if(!k||k.source===`user`)return;vt(k);let e=window.setTimeout(()=>vt(null),3500);return()=>window.clearTimeout(e)},[k]),(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 ye(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 D(await E(e,t,r.task.version),{revalidate:!1})}catch{V(_.actionFailed)}finally{J(n,!1)}}},[_.actionFailed,D,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 D(fe(e,t,r.task.version),{optimisticData:je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return V(_.actionFailed),!1}finally{n&&J(n,!1)}},[_.actionFailed,D,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 D(await de(e,t,n.task.version),{revalidate:!1})}catch{V(_.dependencyUpdateFailed)}finally{J(`dependencies`,!1)}}},[_.dependencyUpdateFailed,D,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 D(await T(e,t,n.task.version),{revalidate:!1})}catch{V(_.actionFailed)}finally{J(`delegateAgentId`,!1)}}},[_.actionFailed,D,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:_.actionFailed)}finally{J(`delete`,!1)}},[_.actionFailed,a,r,Ct,J,e]);if((0,R.useLayoutEffect)(()=>{if(t!==`modal`)return x({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":_.backToWork,children:(0,B.jsx)(Te,{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} / ${_.taskLabel}`:_.taskLabel}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:_.detailStatuses[Ge(S)]})]}):null,end:(0,B.jsx)(`div`,{ref:z,className:`flex min-w-0 items-center justify-end`})}),te},[te,_.backToWork,_.detailStatuses,_.taskLabel,S,t,W,Ct,x]),he&&!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:_.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=_.detailStatuses[Ge(S)],Rt=_.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`),Q=S.conversation.activeSessionKey,Kt=S.conversation.currentExecutorAgentId??S.task.delegateAgentId??S.task.ownerId,qt=Xe.find(e=>e.id===Kt),Jt=!!(Q&&ne&&re===Q),Yt=S.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Xt=S.task.contract?.acceptanceCriteria??[],Zt=Xt.filter(e=>Bt.get(e)===`passed`).length,Qt=S.task.contract?.expectedOutputs??[],$t=S.task.contract?.constraints??[],en=S.task.contract?.approvalRequired??[],tn=S.task.contract?.assumptions??[],nn=S.task.contract?.risks??[],$=(...e)=>!!_t?.changedFields.some(t=>e.includes(t)),rn=e=>t===`modal`&&n?we(n,e):h(`/tasks/${e}`,Ct),an=S.allowedCommands.includes(`move`),on=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)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`mark_ready`}),children:[(0,B.jsx)(O,{className:`size-4`}),_.scheduleTask]}):null,It?(0,B.jsxs)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`resolve_wait`,waitId:It.id}),children:[(0,B.jsx)(O,{className:`size-4`}),_.resumeTask]}):null,!Ft&&Ht&&Kt?(0,B.jsxs)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`start`,executor:{kind:`agent`,agentId:Kt}}),children:[(0,B.jsx)(O,{className:`size-4`}),_.runTask]}):null,Wt?(0,B.jsxs)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`close`,resolution:`done`}),children:[(0,B.jsx)(d,{className:`size-4`}),_.approveTask]}):null,Gt?(0,B.jsxs)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`reopen`,phase:`ready`}),children:[(0,B.jsx)(O,{className:`size-4`}),_.reopenTask]}):null,!Ft&&Ut?(0,B.jsxs)(y,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:on,onClick:()=>void Y({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,B.jsx)(me,{className:`size-4`}),_.pauseTask]}):null,(0,B.jsxs)(be,{children:[(0,B.jsx)(P,{asChild:!0,children:(0,B.jsx)(y,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:on||sn,"aria-label":_.moreActions,children:(0,B.jsx)(f,{className:`size-4`,"aria-hidden":!0})})}),(0,B.jsx)(I,{children:(0,B.jsxs)(N,{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)(j,{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),D(pe(e,cn.id,cn.version),{revalidate:!1}).catch(()=>V(_.actionFailed)).finally(()=>J(`command`,!1))},children:_.cancelActiveRun}):null,cn?(0,B.jsx)(M,{className:`my-1 h-px bg-edge`}):null,S.task.phase===`closed`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(j,{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:_.cancelTask}),(0,B.jsx)(M,{className:`my-1 h-px bg-edge`})]}),(0,B.jsx)(j,{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(_.deleteActiveTaskBlocked);return}bt(!0)},children:_.deleteTask})]})})]})]}),Q&&t!==`modal`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(y,{type:`button`,variant:`ghost`,className:v(`h-8 shrink-0 px-2 text-xs`,Jt&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":Jt,onClick:()=>{ae(Q,!1),ie(Q)},children:[(0,B.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,B.jsx)(y,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,B.jsxs)(c,{to:ve(e),children:[(0,B.jsx)(p,{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:v(`px-4 pb-5`,$(`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)(Ce,{className:`size-3.5`,"aria-hidden":!0}),W]}):null,(0,B.jsx)(`span`,{children:`/`}),(0,B.jsx)(`span`,{children:_.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:v(`rounded-xl bg-surface-panel p-4`,$(`body`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:_.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:v(`rounded-xl bg-warning/10 p-4`,$(`attention`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h3`,{className:`font-medium text-fg`,children:Yt?_.needsAttention:_.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:v(`rounded-xl bg-surface-panel p-4`,$(`contract`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:_.successDefinition}),Xt.length>0?(0,B.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:_.criteriaProgress.replace(`{{verified}}`,String(Zt)).replace(`{{total}}`,String(Xt.length))}):null]}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:Xt,empty:_.noDefinition,verificationByCriterion:Bt})})]}),Qt.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:_.expectedOutputs}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:Qt,empty:_.noDefinition})})]}):null,$t.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:_.constraints}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:$t,empty:_.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:_.approvalRequired}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:en,empty:_.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:_.contextAssumptions}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:tn,empty:_.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:_.contextRisks}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:nn,empty:_.noDefinition})})]}):null]}),Z?(0,B.jsxs)(`section`,{className:v(`rounded-xl bg-surface-panel p-4`,$(`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:_.latestResult}),(0,B.jsx)(g,{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:[_.receiptStatuses[Z.status],` · `,_.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:_.remainingWork}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsx)(U,{items:Z.remainingWork,empty:_.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:_.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)(y,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void ge(Z.runId,`helpful`),children:_.doneWell}),(0,B.jsx)(y,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void ge(Z.runId,`not_helpful`),children:_.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)(p,{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:_.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:_.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,S.context.length>0?(0,B.jsxs)(`section`,{className:v(`rounded-xl bg-surface-panel p-4`,$(`context`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:[_.contextRoleLabels[e.role],` · `,_.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:v(`rounded-xl bg-surface-subtle p-4`,$(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:an,canApprove:Wt,canReopen:Gt,language:l,label:_.taskPhase,onChange:Et}),(0,B.jsx)(Le,{value:S.task.priority,disabled:H.has(`priority`),label:_.priority,labels:_.priorityLabels,onChange:Dt}),(0,B.jsx)(Re,{value:Pe(S.task.dueAt),disabled:H.has(`dueAt`),label:_.dueDate,onChange:Ot}),(0,B.jsx)(ze,{value:S.conversation.currentExecutorAgentId??``,disabled:H.has(`delegateAgentId`),label:_.executorLabel,unassignedLabel:_.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:_.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)(Ce,{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:_.updatedAt.replace(`{{date}}`,le(S.task.updatedAt,l))})]})]}),(0,B.jsxs)(`section`,{className:v(`rounded-xl bg-surface-panel p-4`,$(`dependencies`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:_.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:_.dependents}),S.dependents.length>0?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:S.dependents.map(e=>(0,B.jsx)(c,{to:rn(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:_.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:[Kt?(0,B.jsx)(xe,{agentId:Kt,avatar:qt?.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:[qt?.name??Kt??_.unassigned,` · `,Lt]})]})]})}),t===`modal`?un:null]}),Q?(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(F,{embedded:!0,sessionKey:Q,taskId:e})}):_e?(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)(Ee,{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)(Ee,{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)(Ee,{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:_.deleteTaskTitle,description:_.deleteTaskDescription.replace(`{{title}}`,S.task.title),confirmLabel:_.confirmDeleteTask,cancelLabel:_.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=ee(K),{data:o}=oe(n),s=o?.conversation.activeSessionKey??null,l=C(tt),u=C(et),d=C($e),f=C(G),m=Se(Qe),h=he(Ze),g=he(Xe),y=l?u:0,b;t[0]!==i||t[1]!==g?(b=e=>{e||(g(null),i())},t[0]=i,t[1]=g,t[2]=b):b=t[2];let x=a===`zh`?`关闭任务详情`:`Close task details`,w;t[3]!==i||t[4]!==g?(w=()=>{g(null),i()},t[3]=i,t[4]=g,t[5]=w):w=t[5];let T;t[6]!==x||t[7]!==w?(T=(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":x,onClick:w}),t[6]=x,t[7]=w,t[8]=T):T=t[8];let ce=l?`true`:`false`,le=`${y/2}px`,ue=`${y}px`,de;t[9]!==le||t[10]!==ue?(de={"--task-detail-workspace-offset":le,"--task-detail-workspace-width":ue},t[9]=le,t[10]=ue,t[11]=de):de=t[11];let fe=de,pe=a===`zh`?`任务详情`:`Task details`,E;t[12]===pe?E=t[13]:(E=(0,B.jsx)(ae,{className:`font-medium text-fg`,children:pe}),t[12]=pe,t[13]=E);let me=a===`zh`?`查看并操作任务详情`:`View and manage task details`,O;t[14]===me?O=t[15]:(O=(0,B.jsx)(te,{className:`sr-only`,children:me}),t[14]=me,t[15]=O);let k;t[16]!==s||t[17]!==a||t[18]!==f||t[19]!==m||t[20]!==n||t[21]!==l||t[22]!==d?(k=s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:v(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,l&&d===s&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":l&&d===s,onClick:()=>{m(s,!1),f(s)},children:(0,B.jsx)(se,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(c,{to:ve(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)(p,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=s,t[17]=a,t[18]=f,t[19]=m,t[20]=n,t[21]=l,t[22]=d,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)(_,{className:`size-4`,"aria-hidden":!0}),t[24]=_e):_e=t[24];let A;t[25]===ge?A=t[26]:(A=(0,B.jsx)(ne,{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]!==E||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:[E,O,j]}),t[30]=E,t[31]=O,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==i||t[35]!==g?(N=()=>{g(null),i()},t[34]=i,t[35]=g,t[36]=N):N=t[36];let P;t[37]!==r||t[38]!==N||t[39]!==n?(P=(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]=P):P=t[40];let F;t[41]!==M||t[42]!==P||t[43]!==ce||t[44]!==fe?(F=(0,B.jsxs)(ie,{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":ce,style:fe,onEscapeKeyDown:Ye,onInteractOutside:W,children:[M,P]}),t[41]=M,t[42]=P,t[43]=ce,t[44]=fe,t[45]=F):F=t[45];let I;t[46]!==h||t[47]!==l||t[48]!==u||t[49]!==d?(I=h?(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:l?u:0},children:(0,B.jsx)(D,{allowOutsideChat:!0,sessionKey:d??void 0})}):null,t[46]=h,t[47]=l,t[48]=u,t[49]=d,t[50]=I):I=t[50];let L;t[51]!==F||t[52]!==I||t[53]!==T?(L=(0,B.jsxs)(re,{children:[T,F,I]}),t[51]=F,t[52]=I,t[53]=T,t[54]=L):L=t[54];let ye;return t[55]!==b||t[56]!==L?(ye=(0,B.jsx)(S,{modal:!1,open:!0,onOpenChange:b,children:L}),t[55]=b,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)(u,{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{n as l,r as u}from"./popover-select-DBrVS3tZ.js";import{t as d}from"./circle-check-C23XjkUj.js";import{t as f}from"./ellipsis-0k4rZLoy.js";import{t as p}from"./external-link-DjqjBmc3.js";import{d as m,p as h,t as g}from"./markdown-view-v-O3cOpk.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./cn-JdwAhgNB.js";import{t as y}from"./button-CSEbl4zT.js";import{n as ee,s as b}from"./locale-store-XDFAPNNu.js";import{t as x}from"./skeleton-BwbyijEw.js";import{i as te,n as ne,o as re,r as ie,s as ae,t as S}from"./dist-BPoKqzeH.js";import{$r as C,A as oe,Aa as w,B as T,Cc as se,Di as ce,Hr as le,I as ue,J as de,K as fe,M as pe,N as E,Os as me,Qr as he,Sn as D,Ss as O,Uc as k,W as ge,Wc as _e,Y as A,ar as j,bn as ve,cr as M,ir as N,lr as P,n as F,or as I,pa as L,qi as ye,sr as be,tt as xe,ur as Se,wc as Ce,xn as we,yl as Te,zs as Ee}from"./index-DKP23eMn.js";import{t as De}from"./date-picker-D4QS8Zzn.js";import{t as Oe}from"./dependency-picker-DZn-RhEm.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)(x,{className:`h-32 rounded-2xl`}),(0,B.jsx)(x,{className:`h-52 rounded-2xl`}),(0,B.jsx)(x,{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:d}=e,f;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(f=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=f):f=t[4];let p=f,m;t[5]===c?m=t[6]:(m=(0,B.jsx)(`span`,{children:c}),t[5]=c,t[6]=m);let h;t[7]===d?h=t[8]:(h=e=>d(e.target.value),t[7]=d,t[8]=h);let g;t[9]!==s||t[10]!==p?(g=V.map(e=>(0,B.jsx)(u,{value:e,disabled:p(e),children:Me(e,s)},e)),t[9]=s,t[10]=p,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==h||t[14]!==g||t[15]!==n?(_=(0,B.jsx)(l,{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:h,children:g}),t[12]=r,t[13]=h,t[14]=g,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==m||t[18]!==_?(v=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[m,_]}),t[17]=m,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 d;t[4]===a?d=t[5]:(d=H.map(e=>(0,B.jsx)(u,{value:e,children:a[e]},e)),t[4]=a,t[5]=d);let f;t[6]!==r||t[7]!==c||t[8]!==d||t[9]!==n?(f=(0,B.jsx)(l,{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:d}),t[6]=r,t[7]=c,t[8]=d,t[9]=n,t[10]=f):f=t[10];let p;return t[11]!==s||t[12]!==f?(p=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,f]}),t[11]=s,t[12]=f,t[13]=p):p=t[13],p}),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 d;t[2]===s?d=t[3]:(d=e=>s(e.target.value),t[2]=s,t[3]=d);let f;t[4]===a?f=t[5]:(f=(0,B.jsx)(u,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(nt),t[6]=o,t[7]=p);let m;t[8]!==r||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==n?(m=(0,B.jsxs)(l,{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:d,children:[f,p]}),t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=n,t[13]=m):m=t[13];let h;return t[14]!==c||t[15]!==m?(h=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,m]}),t[14]=c,t[15]=m,t[16]=h):h=t[16],h}),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`?d:t===`failed`?_e:k,{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=ee(e=>e.language),u=b(e=>e.token),_=(0,R.useMemo)(()=>A(l),[l]),x=w(e=>e.setPageHeader),te=w(e=>e.clearPageHeader),ne=C(e=>e.open),re=C(e=>e.sessionKeyOverride),ie=C(e=>e.openForSession),ae=Se(e=>e.setOpen),{data:S,error:he,mutate:D,lastChange:k,conversationLoading:_e,conversationError:De}=oe(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:_.linkDependencies,linked:_.linkedDependencies,searchPlaceholder:_.dependencySearchPlaceholder,noMatches:_.noDependencyMatches,noCandidates:_.noDependencyCandidates,remove:_.removeDependency}),[_.dependencySearchPlaceholder,_.linkDependencies,_.linkedDependencies,_.noDependencyCandidates,_.noDependencyMatches,_.removeDependency]),St=S?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Ct=(0,R.useMemo)(()=>m(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 L().then(t=>{e&&Ze(t.items)}).catch(()=>void 0),()=>{e=!1}},[u]),(0,R.useEffect)(()=>{if(!k||k.source===`user`)return;vt(k);let e=window.setTimeout(()=>vt(null),3500);return()=>window.clearTimeout(e)},[k]),(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 ye(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 D(await E(e,t,r.task.version),{revalidate:!1})}catch{V(_.actionFailed)}finally{J(n,!1)}}},[_.actionFailed,D,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 D(fe(e,t,r.task.version),{optimisticData:je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return V(_.actionFailed),!1}finally{n&&J(n,!1)}},[_.actionFailed,D,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 D(await de(e,t,n.task.version),{revalidate:!1})}catch{V(_.dependencyUpdateFailed)}finally{J(`dependencies`,!1)}}},[_.dependencyUpdateFailed,D,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 D(await T(e,t,n.task.version),{revalidate:!1})}catch{V(_.actionFailed)}finally{J(`delegateAgentId`,!1)}}},[_.actionFailed,D,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:_.actionFailed)}finally{J(`delete`,!1)}},[_.actionFailed,a,r,Ct,J,e]);if((0,R.useLayoutEffect)(()=>{if(t!==`modal`)return x({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":_.backToWork,children:(0,B.jsx)(Te,{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} / ${_.taskLabel}`:_.taskLabel}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:_.detailStatuses[Ge(S)]})]}):null,end:(0,B.jsx)(`div`,{ref:z,className:`flex min-w-0 items-center justify-end`})}),te},[te,_.backToWork,_.detailStatuses,_.taskLabel,S,t,W,Ct,x]),he&&!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:_.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=_.detailStatuses[Ge(S)],Rt=_.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`),Q=S.conversation.activeSessionKey,Kt=S.conversation.currentExecutorAgentId??S.task.delegateAgentId??S.task.ownerId,qt=Xe.find(e=>e.id===Kt),Jt=!!(Q&&ne&&re===Q),Yt=S.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Xt=S.task.contract?.acceptanceCriteria??[],Zt=Xt.filter(e=>Bt.get(e)===`passed`).length,Qt=S.task.contract?.expectedOutputs??[],$t=S.task.contract?.constraints??[],en=S.task.contract?.approvalRequired??[],tn=S.task.contract?.assumptions??[],nn=S.task.contract?.risks??[],$=(...e)=>!!_t?.changedFields.some(t=>e.includes(t)),rn=e=>t===`modal`&&n?we(n,e):h(`/tasks/${e}`,Ct),an=S.allowedCommands.includes(`move`),on=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)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`mark_ready`}),children:[(0,B.jsx)(O,{className:`size-4`}),_.scheduleTask]}):null,It?(0,B.jsxs)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`resolve_wait`,waitId:It.id}),children:[(0,B.jsx)(O,{className:`size-4`}),_.resumeTask]}):null,!Ft&&Ht&&Kt?(0,B.jsxs)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`start`,executor:{kind:`agent`,agentId:Kt}}),children:[(0,B.jsx)(O,{className:`size-4`}),_.runTask]}):null,Wt?(0,B.jsxs)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`close`,resolution:`done`}),children:[(0,B.jsx)(d,{className:`size-4`}),_.approveTask]}):null,Gt?(0,B.jsxs)(y,{variant:`primary`,disabled:on,onClick:()=>void Y({type:`reopen`,phase:`ready`}),children:[(0,B.jsx)(O,{className:`size-4`}),_.reopenTask]}):null,!Ft&&Ut?(0,B.jsxs)(y,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:on,onClick:()=>void Y({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,B.jsx)(me,{className:`size-4`}),_.pauseTask]}):null,(0,B.jsxs)(be,{children:[(0,B.jsx)(P,{asChild:!0,children:(0,B.jsx)(y,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:on||sn,"aria-label":_.moreActions,children:(0,B.jsx)(f,{className:`size-4`,"aria-hidden":!0})})}),(0,B.jsx)(I,{children:(0,B.jsxs)(N,{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)(j,{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),D(pe(e,cn.id,cn.version),{revalidate:!1}).catch(()=>V(_.actionFailed)).finally(()=>J(`command`,!1))},children:_.cancelActiveRun}):null,cn?(0,B.jsx)(M,{className:`my-1 h-px bg-edge`}):null,S.task.phase===`closed`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(j,{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:_.cancelTask}),(0,B.jsx)(M,{className:`my-1 h-px bg-edge`})]}),(0,B.jsx)(j,{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(_.deleteActiveTaskBlocked);return}bt(!0)},children:_.deleteTask})]})})]})]}),Q&&t!==`modal`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(y,{type:`button`,variant:`ghost`,className:v(`h-8 shrink-0 px-2 text-xs`,Jt&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":Jt,onClick:()=>{ae(Q,!1),ie(Q)},children:[(0,B.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,B.jsx)(y,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,B.jsxs)(c,{to:ve(e),children:[(0,B.jsx)(p,{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:v(`px-4 pb-5`,$(`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)(Ce,{className:`size-3.5`,"aria-hidden":!0}),W]}):null,(0,B.jsx)(`span`,{children:`/`}),(0,B.jsx)(`span`,{children:_.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:v(`rounded-xl bg-surface-panel p-4`,$(`body`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:_.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:v(`rounded-xl bg-warning/10 p-4`,$(`attention`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h3`,{className:`font-medium text-fg`,children:Yt?_.needsAttention:_.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:v(`rounded-xl bg-surface-panel p-4`,$(`contract`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:_.successDefinition}),Xt.length>0?(0,B.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:_.criteriaProgress.replace(`{{verified}}`,String(Zt)).replace(`{{total}}`,String(Xt.length))}):null]}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:Xt,empty:_.noDefinition,verificationByCriterion:Bt})})]}),Qt.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:_.expectedOutputs}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:Qt,empty:_.noDefinition})})]}):null,$t.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:_.constraints}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:$t,empty:_.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:_.approvalRequired}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:en,empty:_.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:_.contextAssumptions}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:tn,empty:_.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:_.contextRisks}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:nn,empty:_.noDefinition})})]}):null]}),Z?(0,B.jsxs)(`section`,{className:v(`rounded-xl bg-surface-panel p-4`,$(`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:_.latestResult}),(0,B.jsx)(g,{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:[_.receiptStatuses[Z.status],` · `,_.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:_.remainingWork}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsx)(U,{items:Z.remainingWork,empty:_.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:_.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)(y,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void ge(Z.runId,`helpful`),children:_.doneWell}),(0,B.jsx)(y,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void ge(Z.runId,`not_helpful`),children:_.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)(p,{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:_.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:_.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,S.context.length>0?(0,B.jsxs)(`section`,{className:v(`rounded-xl bg-surface-panel p-4`,$(`context`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:[_.contextRoleLabels[e.role],` · `,_.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:v(`rounded-xl bg-surface-subtle p-4`,$(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:an,canApprove:Wt,canReopen:Gt,language:l,label:_.taskPhase,onChange:Et}),(0,B.jsx)(Le,{value:S.task.priority,disabled:H.has(`priority`),label:_.priority,labels:_.priorityLabels,onChange:Dt}),(0,B.jsx)(Re,{value:Pe(S.task.dueAt),disabled:H.has(`dueAt`),label:_.dueDate,onChange:Ot}),(0,B.jsx)(ze,{value:S.conversation.currentExecutorAgentId??``,disabled:H.has(`delegateAgentId`),label:_.executorLabel,unassignedLabel:_.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:_.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)(Ce,{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:_.updatedAt.replace(`{{date}}`,le(S.task.updatedAt,l))})]})]}),(0,B.jsxs)(`section`,{className:v(`rounded-xl bg-surface-panel p-4`,$(`dependencies`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:_.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:_.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:_.dependents}),S.dependents.length>0?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:S.dependents.map(e=>(0,B.jsx)(c,{to:rn(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:_.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:[Kt?(0,B.jsx)(xe,{agentId:Kt,avatar:qt?.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:[qt?.name??Kt??_.unassigned,` · `,Lt]})]})]})}),t===`modal`?un:null]}),Q?(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(F,{embedded:!0,sessionKey:Q,taskId:e})}):_e?(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)(Ee,{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)(Ee,{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)(Ee,{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:_.deleteTaskTitle,description:_.deleteTaskDescription.replace(`{{title}}`,S.task.title),confirmLabel:_.confirmDeleteTask,cancelLabel:_.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=ee(K),{data:o}=oe(n),s=o?.conversation.activeSessionKey??null,l=C(tt),u=C(et),d=C($e),f=C(G),m=Se(Qe),h=he(Ze),g=he(Xe),y=l?u:0,b;t[0]!==i||t[1]!==g?(b=e=>{e||(g(null),i())},t[0]=i,t[1]=g,t[2]=b):b=t[2];let x=a===`zh`?`关闭任务详情`:`Close task details`,w;t[3]!==i||t[4]!==g?(w=()=>{g(null),i()},t[3]=i,t[4]=g,t[5]=w):w=t[5];let T;t[6]!==x||t[7]!==w?(T=(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":x,onClick:w}),t[6]=x,t[7]=w,t[8]=T):T=t[8];let ce=l?`true`:`false`,le=`${y/2}px`,ue=`${y}px`,de;t[9]!==le||t[10]!==ue?(de={"--task-detail-workspace-offset":le,"--task-detail-workspace-width":ue},t[9]=le,t[10]=ue,t[11]=de):de=t[11];let fe=de,pe=a===`zh`?`任务详情`:`Task details`,E;t[12]===pe?E=t[13]:(E=(0,B.jsx)(ae,{className:`font-medium text-fg`,children:pe}),t[12]=pe,t[13]=E);let me=a===`zh`?`查看并操作任务详情`:`View and manage task details`,O;t[14]===me?O=t[15]:(O=(0,B.jsx)(te,{className:`sr-only`,children:me}),t[14]=me,t[15]=O);let k;t[16]!==s||t[17]!==a||t[18]!==f||t[19]!==m||t[20]!==n||t[21]!==l||t[22]!==d?(k=s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:v(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,l&&d===s&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":l&&d===s,onClick:()=>{m(s,!1),f(s)},children:(0,B.jsx)(se,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(c,{to:ve(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)(p,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=s,t[17]=a,t[18]=f,t[19]=m,t[20]=n,t[21]=l,t[22]=d,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)(_,{className:`size-4`,"aria-hidden":!0}),t[24]=_e):_e=t[24];let A;t[25]===ge?A=t[26]:(A=(0,B.jsx)(ne,{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]!==E||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:[E,O,j]}),t[30]=E,t[31]=O,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==i||t[35]!==g?(N=()=>{g(null),i()},t[34]=i,t[35]=g,t[36]=N):N=t[36];let P;t[37]!==r||t[38]!==N||t[39]!==n?(P=(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]=P):P=t[40];let F;t[41]!==M||t[42]!==P||t[43]!==ce||t[44]!==fe?(F=(0,B.jsxs)(ie,{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":ce,style:fe,onEscapeKeyDown:Ye,onInteractOutside:W,children:[M,P]}),t[41]=M,t[42]=P,t[43]=ce,t[44]=fe,t[45]=F):F=t[45];let I;t[46]!==h||t[47]!==l||t[48]!==u||t[49]!==d?(I=h?(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:l?u:0},children:(0,B.jsx)(D,{allowOutsideChat:!0,sessionKey:d??void 0})}):null,t[46]=h,t[47]=l,t[48]=u,t[49]=d,t[50]=I):I=t[50];let L;t[51]!==F||t[52]!==I||t[53]!==T?(L=(0,B.jsxs)(re,{children:[T,F,I]}),t[51]=F,t[52]=I,t[53]=T,t[54]=L):L=t[54];let ye;return t[55]!==b||t[56]!==L?(ye=(0,B.jsx)(S,{modal:!1,open:!0,onOpenChange:b,children:L}),t[55]=b,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)(u,{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"./cn-JdwAhgNB.js";import{t as c}from"./button-CSEbl4zT.js";import{s as l}from"./form-field-width-DJw_jULe.js";import{t as u}from"./messages-B1HDp_j8.js";import{a as d,i as f,n as ee,r as p,s as te}from"./locale-store-XDFAPNNu.js";import{t as m}from"./skeleton-BwbyijEw.js";import{i as h}from"./vendor-swr-BIWyz7Rc.js";import{n as g,r as ne}from"./gateway-config-swr-DfMY-MLf.js";import{di as _,yo as v,ys as y}from"./index-C73V7tJP.js";import{n as re,t as ie}from"./settings-form-section-5NTg906_.js";async function b(){return(await d(p(`/api/devices`))).devices}async function x(){let e=await d(p(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersions:e.protocolVersions}}async function S(){try{return{kind:`ready`,setup:(await d(p(`/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 C(e){return d(p(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function w(e){await d(p(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function T(e,t){await d(p(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function E(e){await d(p(`/api/devices/${encodeURIComponent(e)}`),{method:`DELETE`})}var D=e(t(),1),ae=n(),O=r();function k(e){let t=(0,ae.c)(10),{language:n,label:r,section:a,className:o}=e,c;t[0]!==n||t[1]!==a?(c=v(n,a),t[0]=n,t[1]=a,t[2]=c):c=t[2];let l;t[3]===o?l=t[4]:(l=s(`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]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,O.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;return t[6]!==r||t[7]!==c||t[8]!==l?(d=(0,O.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=c,t[8]=l,t[9]=d):d=t[9],d}async function A(){let e=await f(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function j(e=`serve`){let t=await f(`/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 M(){let e=await f(`/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 oe=`https://tailscale.com/download`;function N(e){let t=(0,ae.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,O.jsx)(`a`,{href:oe,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function se({embedded:e=!1}){let t=ee(e=>e.language),n=u(t).remoteAccess.tailscale,r=(0,D.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:u(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!te(e=>e.token),[s,l]=(0,D.useState)(!1),[d,f]=(0,D.useState)(null),{data:p,mutate:g,isLoading:ne}=h(i?`exposure-status`:null,A,{refreshInterval:3e4}),v=p?.tailscale.hostname,b=p?.tailscale.active===!0,x=p?.tailscale.cliAvailable!==!1,S=v?`https://${v}/`:null,C=(0,D.useCallback)(async()=>{l(!0),f(null);try{await j(`serve`),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]),w=(0,D.useCallback)(async()=>{l(!0),f(null);try{await M(),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]);if(!i)return null;let T=(0,O.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,O.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,O.jsxs)(`li`,{className:`flex gap-2`,children:[(0,O.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,O.jsxs)(`span`,{children:[n.stepInstallBefore,(0,O.jsx)(N,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,O.jsxs)(`li`,{className:`flex gap-2`,children:[(0,O.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,O.jsx)(`span`,{children:n.stepEnable})]}),(0,O.jsxs)(`li`,{className:`flex gap-2`,children:[(0,O.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,O.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&p?.tailscale.cliAvailable===!1?(0,O.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,O.jsx)(N,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,ne&&!p?(0,O.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,O.jsx)(m,{className:`h-20 rounded-lg`}),(0,O.jsx)(m,{className:`h-20 rounded-lg`})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(ie,{children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,O.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:b?n.statusActive:n.statusOff}),S?(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(_,{text:S,labels:r})}):null,d?(0,O.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,O.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:b?(0,O.jsxs)(c,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void w(),children:[s?(0,O.jsx)(o,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,O.jsxs)(c,{type:`button`,disabled:s||!x,onClick:()=>void C(),children:[s?(0,O.jsx)(o,{className:`mr-1 size-4 animate-spin`}):(0,O.jsx)(y,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,O.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,O.jsx)(k,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?T:(0,O.jsxs)(ie,{children:[(0,O.jsx)(re,{icon:a,title:n.title,subtitle:n.subtitle}),T]})}async function ce(e){let t=await f(p(`/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 le(e){await d(p(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function P(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 ue(){return(0,D.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`)||P(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function de(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,l,`dark:border-edge`)}function fe(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 F(){let e=(0,ae.c)(85),t=ee(me),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!te(pe),l=ue(),d=ne(i).data?.payload?.config,f;e[2]===d?f=e[3]:(f=fe(d),e[2]=d,e[3]=f);let p=f,[m,h]=(0,D.useState)(``),_;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(_={busy:!1,result:null},e[4]=_):_=e[4];let[v,y]=(0,D.useState)(_),b;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(b={busy:!1,error:null},e[5]=b):b=e[5];let[x,S]=(0,D.useState)(b),C,w;e[6]!==p||e[7]!==l||e[8]!==m?(C=()=>{m||(p?h(p):l&&h(l))},w=[p,l,m],e[6]=p,e[7]=l,e[8]=m,e[9]=C,e[10]=w):(C=e[9],w=e[10]),(0,D.useEffect)(C,w);let T;bb0:{let t;e[11]===m?t=e[12]:(t=m.trim(),e[11]=m,e[12]=t);let n=t;if(n){T=n;break bb0}T=p??l??``}let E=T,k=!p&&!!l&&E===l,A;e[13]!==m||e[14]!==E?(A=async()=>{let e=m.trim()||E;if(e){y({busy:!0,result:null});try{y({busy:!1,result:await ce(e)})}catch(e){let t=e;y({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=m,e[14]=E,e[15]=A):A=e[15];let j=A,M;e[16]===E?M=e[17]:(M=async()=>{let e=E.trim();if(e){S({busy:!0,error:null});try{await le(e),await g(),S({busy:!1,error:null})}catch(e){let t=e;S({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=E,e[17]=M);let oe=M,N;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(N=async()=>{S({busy:!0,error:null});try{await le(null),await g(),h(``),y({busy:!1,result:null}),S({busy:!1,error:null})}catch(e){let t=e;S({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=N):N=e[18];let se=N;if(!i)return null;let P;e[19]!==r.subtitle||e[20]!==r.title?(P=(0,O.jsx)(re,{icon:a,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=P):P=e[21];let F;e[22]===r.urlLabel?F=e[23]:(F=(0,O.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=F);let I;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(I=s(de(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=I):I=e[24];let L;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{h(e.target.value),y({busy:!1,result:null})},e[25]=L):L=e[25];let R;e[26]!==m||e[27]!==r.urlPlaceholder||e[28]!==I?(R=(0,O.jsx)(`input`,{id:`reverse-proxy-url`,className:I,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:m,onChange:L}),e[26]=m,e[27]=r.urlPlaceholder,e[28]=I,e[29]=R):R=e[29];let z;e[30]===j?z=e[31]:(z=()=>void j(),e[30]=j,e[31]=z);let B;e[32]!==m||e[33]!==v.busy?(B=v.busy||!m.trim(),e[32]=m,e[33]=v.busy,e[34]=B):B=e[34];let V;e[35]===v.busy?V=e[36]:(V=v.busy?(0,O.jsx)(o,{className:`size-3.5 animate-spin`}):null,e[35]=v.busy,e[36]=V);let H=v.busy?r.probing:r.probeButton,U;e[37]!==z||e[38]!==B||e[39]!==V||e[40]!==H?(U=(0,O.jsxs)(c,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:z,disabled:B,children:[V,H]}),e[37]=z,e[38]=B,e[39]=V,e[40]=H,e[41]=U):U=e[41];let W;e[42]!==R||e[43]!==U?(W=(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[R,U]}),e[42]=R,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,O.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==l||e[48]!==k||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=k&&l?(0,O.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,O.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,O.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:l}),(0,O.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=l,e[48]=k,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==v.result||e[53]!==r.probeStatus?(q=v.result?(0,O.jsx)(he,{result:v.result,labels:r.probeStatus}):null,e[52]=v.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==p||e[56]!==E||e[57]!==oe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==x.busy?(J=E&&p!==E?(0,O.jsxs)(c,{type:`button`,onClick:()=>void oe(),disabled:x.busy,children:[x.busy?(0,O.jsx)(o,{className:`size-3.5 animate-spin`}):null,x.busy?r.saving:r.saveAsDefault]}):null,e[55]=p,e[56]=E,e[57]=oe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=x.busy,e[61]=J):J=e[61];let Y;e[62]!==p||e[63]!==r.clear||e[64]!==x.busy?(Y=p?(0,O.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>void se(),disabled:x.busy,children:r.clear}):null,e[62]=p,e[63]=r.clear,e[64]=x.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,O.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]===x.error?Z=e[70]:(Z=x.error?(0,O.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:x.error}):null,e[69]=x.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,O.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]!==F||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,O.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[F,W,G,K,q,X,Z,Q]}),e[73]=F,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]!==P||e[83]!==$?(ge=(0,O.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,O.jsxs)(ie,{children:[P,$]})}),e[82]=P,e[83]=$,e[84]=ge):ge=e[84],ge}function pe(e){return e.token}function me(e){return e.language}function he(e){let t=(0,ae.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,O.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,O.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,O.jsxs)(O.Fragment,{children:[` · `,(0,O.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,O.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,O.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,O.jsxs)(O.Fragment,{children:[` — `,(0,O.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,O.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 I(){return d(p(`/api/tunnel/status`))}async function L(){await d(p(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function R(){await d(p(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function z(){return d(p(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function B(e){return d(p(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function V(){let e=(await d(p(`/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 H(e){await d(p(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{C as _,V as a,F as c,k as d,w as f,x as g,b as h,L as i,se as l,T as m,H as n,z as o,S as p,R as r,B as s,I as t,A as u,E 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"./cn-JdwAhgNB.js";import{t as c}from"./button-CSEbl4zT.js";import{s as l}from"./form-field-width-DJw_jULe.js";import{t as u}from"./messages-B1HDp_j8.js";import{a as d,i as f,n as ee,r as p,s as te}from"./locale-store-XDFAPNNu.js";import{t as m}from"./skeleton-BwbyijEw.js";import{i as h}from"./vendor-swr-BIWyz7Rc.js";import{n as g,r as ne}from"./gateway-config-swr-DfMY-MLf.js";import{di as _,yo as v,ys as y}from"./index-DKP23eMn.js";import{n as re,t as ie}from"./settings-form-section-BkdLf_sS.js";async function b(){return(await d(p(`/api/devices`))).devices}async function x(){let e=await d(p(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersions:e.protocolVersions}}async function S(){try{return{kind:`ready`,setup:(await d(p(`/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 C(e){return d(p(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function w(e){await d(p(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function T(e,t){await d(p(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function E(e){await d(p(`/api/devices/${encodeURIComponent(e)}`),{method:`DELETE`})}var D=e(t(),1),ae=n(),O=r();function k(e){let t=(0,ae.c)(10),{language:n,label:r,section:a,className:o}=e,c;t[0]!==n||t[1]!==a?(c=v(n,a),t[0]=n,t[1]=a,t[2]=c):c=t[2];let l;t[3]===o?l=t[4]:(l=s(`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]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,O.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;return t[6]!==r||t[7]!==c||t[8]!==l?(d=(0,O.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=c,t[8]=l,t[9]=d):d=t[9],d}async function A(){let e=await f(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function j(e=`serve`){let t=await f(`/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 M(){let e=await f(`/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 oe=`https://tailscale.com/download`;function N(e){let t=(0,ae.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,O.jsx)(`a`,{href:oe,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function se({embedded:e=!1}){let t=ee(e=>e.language),n=u(t).remoteAccess.tailscale,r=(0,D.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:u(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!te(e=>e.token),[s,l]=(0,D.useState)(!1),[d,f]=(0,D.useState)(null),{data:p,mutate:g,isLoading:ne}=h(i?`exposure-status`:null,A,{refreshInterval:3e4}),v=p?.tailscale.hostname,b=p?.tailscale.active===!0,x=p?.tailscale.cliAvailable!==!1,S=v?`https://${v}/`:null,C=(0,D.useCallback)(async()=>{l(!0),f(null);try{await j(`serve`),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]),w=(0,D.useCallback)(async()=>{l(!0),f(null);try{await M(),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]);if(!i)return null;let T=(0,O.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,O.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,O.jsxs)(`li`,{className:`flex gap-2`,children:[(0,O.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,O.jsxs)(`span`,{children:[n.stepInstallBefore,(0,O.jsx)(N,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,O.jsxs)(`li`,{className:`flex gap-2`,children:[(0,O.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,O.jsx)(`span`,{children:n.stepEnable})]}),(0,O.jsxs)(`li`,{className:`flex gap-2`,children:[(0,O.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,O.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&p?.tailscale.cliAvailable===!1?(0,O.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,O.jsx)(N,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,ne&&!p?(0,O.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,O.jsx)(m,{className:`h-20 rounded-lg`}),(0,O.jsx)(m,{className:`h-20 rounded-lg`})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(ie,{children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,O.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:b?n.statusActive:n.statusOff}),S?(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(_,{text:S,labels:r})}):null,d?(0,O.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,O.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:b?(0,O.jsxs)(c,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void w(),children:[s?(0,O.jsx)(o,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,O.jsxs)(c,{type:`button`,disabled:s||!x,onClick:()=>void C(),children:[s?(0,O.jsx)(o,{className:`mr-1 size-4 animate-spin`}):(0,O.jsx)(y,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,O.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,O.jsx)(k,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?T:(0,O.jsxs)(ie,{children:[(0,O.jsx)(re,{icon:a,title:n.title,subtitle:n.subtitle}),T]})}async function ce(e){let t=await f(p(`/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 le(e){await d(p(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function P(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 ue(){return(0,D.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`)||P(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function de(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,l,`dark:border-edge`)}function fe(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 F(){let e=(0,ae.c)(85),t=ee(me),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!te(pe),l=ue(),d=ne(i).data?.payload?.config,f;e[2]===d?f=e[3]:(f=fe(d),e[2]=d,e[3]=f);let p=f,[m,h]=(0,D.useState)(``),_;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(_={busy:!1,result:null},e[4]=_):_=e[4];let[v,y]=(0,D.useState)(_),b;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(b={busy:!1,error:null},e[5]=b):b=e[5];let[x,S]=(0,D.useState)(b),C,w;e[6]!==p||e[7]!==l||e[8]!==m?(C=()=>{m||(p?h(p):l&&h(l))},w=[p,l,m],e[6]=p,e[7]=l,e[8]=m,e[9]=C,e[10]=w):(C=e[9],w=e[10]),(0,D.useEffect)(C,w);let T;bb0:{let t;e[11]===m?t=e[12]:(t=m.trim(),e[11]=m,e[12]=t);let n=t;if(n){T=n;break bb0}T=p??l??``}let E=T,k=!p&&!!l&&E===l,A;e[13]!==m||e[14]!==E?(A=async()=>{let e=m.trim()||E;if(e){y({busy:!0,result:null});try{y({busy:!1,result:await ce(e)})}catch(e){let t=e;y({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=m,e[14]=E,e[15]=A):A=e[15];let j=A,M;e[16]===E?M=e[17]:(M=async()=>{let e=E.trim();if(e){S({busy:!0,error:null});try{await le(e),await g(),S({busy:!1,error:null})}catch(e){let t=e;S({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=E,e[17]=M);let oe=M,N;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(N=async()=>{S({busy:!0,error:null});try{await le(null),await g(),h(``),y({busy:!1,result:null}),S({busy:!1,error:null})}catch(e){let t=e;S({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=N):N=e[18];let se=N;if(!i)return null;let P;e[19]!==r.subtitle||e[20]!==r.title?(P=(0,O.jsx)(re,{icon:a,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=P):P=e[21];let F;e[22]===r.urlLabel?F=e[23]:(F=(0,O.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=F);let I;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(I=s(de(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=I):I=e[24];let L;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{h(e.target.value),y({busy:!1,result:null})},e[25]=L):L=e[25];let R;e[26]!==m||e[27]!==r.urlPlaceholder||e[28]!==I?(R=(0,O.jsx)(`input`,{id:`reverse-proxy-url`,className:I,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:m,onChange:L}),e[26]=m,e[27]=r.urlPlaceholder,e[28]=I,e[29]=R):R=e[29];let z;e[30]===j?z=e[31]:(z=()=>void j(),e[30]=j,e[31]=z);let B;e[32]!==m||e[33]!==v.busy?(B=v.busy||!m.trim(),e[32]=m,e[33]=v.busy,e[34]=B):B=e[34];let V;e[35]===v.busy?V=e[36]:(V=v.busy?(0,O.jsx)(o,{className:`size-3.5 animate-spin`}):null,e[35]=v.busy,e[36]=V);let H=v.busy?r.probing:r.probeButton,U;e[37]!==z||e[38]!==B||e[39]!==V||e[40]!==H?(U=(0,O.jsxs)(c,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:z,disabled:B,children:[V,H]}),e[37]=z,e[38]=B,e[39]=V,e[40]=H,e[41]=U):U=e[41];let W;e[42]!==R||e[43]!==U?(W=(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[R,U]}),e[42]=R,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,O.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==l||e[48]!==k||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=k&&l?(0,O.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,O.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,O.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:l}),(0,O.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=l,e[48]=k,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==v.result||e[53]!==r.probeStatus?(q=v.result?(0,O.jsx)(he,{result:v.result,labels:r.probeStatus}):null,e[52]=v.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==p||e[56]!==E||e[57]!==oe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==x.busy?(J=E&&p!==E?(0,O.jsxs)(c,{type:`button`,onClick:()=>void oe(),disabled:x.busy,children:[x.busy?(0,O.jsx)(o,{className:`size-3.5 animate-spin`}):null,x.busy?r.saving:r.saveAsDefault]}):null,e[55]=p,e[56]=E,e[57]=oe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=x.busy,e[61]=J):J=e[61];let Y;e[62]!==p||e[63]!==r.clear||e[64]!==x.busy?(Y=p?(0,O.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>void se(),disabled:x.busy,children:r.clear}):null,e[62]=p,e[63]=r.clear,e[64]=x.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,O.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]===x.error?Z=e[70]:(Z=x.error?(0,O.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:x.error}):null,e[69]=x.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,O.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]!==F||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,O.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[F,W,G,K,q,X,Z,Q]}),e[73]=F,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]!==P||e[83]!==$?(ge=(0,O.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,O.jsxs)(ie,{children:[P,$]})}),e[82]=P,e[83]=$,e[84]=ge):ge=e[84],ge}function pe(e){return e.token}function me(e){return e.language}function he(e){let t=(0,ae.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,O.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,O.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,O.jsxs)(O.Fragment,{children:[` · `,(0,O.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,O.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,O.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,O.jsxs)(O.Fragment,{children:[` — `,(0,O.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,O.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 I(){return d(p(`/api/tunnel/status`))}async function L(){await d(p(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function R(){await d(p(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function z(){return d(p(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function B(e){return d(p(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function V(){let e=(await d(p(`/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 H(e){await d(p(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{C as _,V as a,F as c,k as d,w as f,x as g,b as h,L as i,se as l,T as m,H as n,z as o,S as p,R as r,B as s,I as t,A as u,E 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{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./locale-store-XDFAPNNu.js";import{Qc as c}from"./index-C73V7tJP.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=s(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=o(`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{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./locale-store-XDFAPNNu.js";import{Qc as c}from"./index-DKP23eMn.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=s(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=o(`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};