@xopcai/xopc 0.0.241 → 0.0.242
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CLnbVm9G.js → activity-store-MU5XrVv8.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DuBewmbW.js → agent-avatar-dicebear-B_Wc0wuL.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-DbdgX6AA.js → agent-defaults-settings-panel-Cf7U2aUi.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-BX3uRVm4.js → agents-Ce9oOnwE.js} +1 -1
- package/dist/gateway/static/root/assets/{api-DjBZe303.js → api-DLyc8BQp.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D8evZyFQ.js → app-management-settings-panel-CACOOS-a.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-B-iul0RG.js → appearance-settings-DB5gEQhN.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CoZd_cZu.js → apps-page-BaTFOCmR.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Cfk1lwBo.js → attachment-load-CYnYIyLr.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BTSGvaeS.js → automations-page-ChTflpmA.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-C8RRKT-a.js → automations-workspace-DK6EreCr.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-ChZyZK45.js → binary-plugins-BjbLfNwG.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DCH9b2Ht.js → block-editor-DgAs5aJc.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-D1GPwIfx.js → browser-settings-page-CHStw5UW.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-jvfcgFG-.js → browser-workflow-inputs-DGQxD0vD.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-DrHW7XNi.js → browser-workflows-page-B9gfdd7L.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-CrXB1Q-l.js → capabilities-settings-panel-JGH6Kfkr.js} +6 -6
- package/dist/gateway/static/root/assets/{channels-settings-DWMSYaNZ.js → channels-settings-YkUaaWkY.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-CC9MFway.js → channels-status-swr-TkU42f-W.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DeeZrVbV.js → chat-terminal-dock-CWMPcnoN.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-DXTl1fNB.js → connectors-page-BI0FG3gA.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-expression-CiqQOeQ3.js → cron-expression-3h3rR0cf.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-CGAMGPfU.js → date-picker-Bz1sLBEx.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-CxWeUTsc.js → dependency-picker-p9DWR8uU.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-C3QmYO75.js → desktop-pet-D1TDB_gR.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CAADkWYy.js → desktop-pet-settings-DWPZpoB7.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-FQXjDJ8P.js → extension-debug-page-BrRbK2rJ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BJE1D5Ji.js → extension-page-CD65czfS.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-5Ik2tNry.js → extension-settings-page-BRDDKhpi.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-cTj71t2a.js → gateway-config-api-CjbBsr5M.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-Bxe_R-JH.js → gateway-config-swr-HT7sLeO9.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-KXBUjNcx.js → gateway-settings-BQjmfYD4.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DJG-I0wW.js → gateway-startup-retry-iBCtaAuT.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-C8cVzIcs.js → heartbeat-settings-BzZxLgrw.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-NdWtBda5.js → home-page--9fKq0mL.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-Dc_ojQuj.js → image-generation-api-dj9TNEn2.js} +1 -1
- package/dist/gateway/static/root/assets/index-D499B1qS.css +2 -0
- package/dist/gateway/static/root/assets/{index-7i2P3312.js → index-J3FsIvTs.js} +8 -8
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-pOKl7blR.js → keyboard-shortcuts-settings-BEnuEPD3.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-C_j_od5f.js → local-app-workbench-page-FqG00zS1.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-Bi6wwKgm.js → local-apps-page-DXQtppWq.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-C5wr3_pc.js → locale-store-DVzTJSj2.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-D6PDZEVP.js → logs-page-c6CfZ8PA.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-DGlVizWi.js → management-settings-DIpBMWrA.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-CXP5zBx_.js → markdown-split-BFHyGwNF.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-D6LxlDxr.js → markdown-view-DR3yVwtV.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BsENGLr2.js → media-plugins-BjjMxC5_.js} +1 -1
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-DcEz7qcX.js → mobile-pairing-wizard-CHnXZTwb.js} +1 -1
- package/dist/gateway/static/root/assets/models-hub-cache-DiXjKuuY.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-D2EqpDyo.js → notes-page-BbvtelJa.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-DIR37b-K.js +4 -0
- package/dist/gateway/static/root/assets/{oauth-api-C5NVcsKE.js → oauth-api-BB-VYJ5j.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DMhf1rdz.js → product-open-page-CRm9Q66h.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-DDHi0Y4Q.js → project-detail-page-DHiLTiRW.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-CVMFKpmu.js → projects-page-God7NCcI.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-FXdFaoWM.js → registry-api-DXsR8oGN.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-B74aErBY.js → remote-access-hub-YpF0-mx2.js} +1 -1
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DoEfLjPB.js +5 -0
- package/dist/gateway/static/root/assets/{schema-form-BUzdHWx6.js → schema-form-BsqpbBDv.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-D2wmGNZE.js → sessions-page-CP8O1TxR.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DzdbK3j9.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-C0OBLqpu.js → settings-page-CE7ZcCTK.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-NpLQkFCh.js → setup-status-panel-CGlne9i0.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BtbPYaYC.js → share-preview-page-Bn0qMX8V.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-rf8f1OGq.js → shares-settings-B7NeVl4g.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DDTmi4a7.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-CYk8pN97.js → skills-page-dRkeYh5P.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-DGjnz-NG.js → skills-page.utils--q8p7MAn.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DmCRSvtd.js → system-settings-panel-C0ZCuCM4.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-6a2RdDl2.js → task-detail-page-yiMzii2b.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DUko1ZnE.js → theme-store-Cth-eChE.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-Chfiba_x.js → tunnel-api-CC3jOB4n.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-W_P8Kiv4.js → use-autosave-PSV89QuQ.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-Vtwg7fQc.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BZD0j1jc.js → voice-api-key-field-DXWdJ8cR.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-BO6A8V3Z.js → voice-config-api-BDoeXgww.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BfwEoOGL.js → work-discovery-overlay-BV_Jj5iD.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-X7Z5_lRX.js → workflow-run-setup-panel-DNHbWGPq.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-BklMzkg8.js → workflows-page-BkFIbMrz.js} +2 -2
- package/dist/gateway/static/root/index.html +11 -11
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/skills/installer.d.ts +1 -0
- package/dist/src/agent/skills/installer.js +9 -6
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +5 -1
- package/dist/src/config/schema.js +5 -3
- package/dist/src/extensions/install.js +1 -1
- package/dist/src/gateway/hono/routes/runtime-tools.js +7 -1
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/runtime-tools/archive.js +17 -3
- package/dist/src/runtime-tools/command.d.ts +1 -0
- package/dist/src/runtime-tools/command.js +29 -8
- package/dist/src/runtime-tools/environment.d.ts +1 -0
- package/dist/src/runtime-tools/environment.js +11 -16
- package/dist/src/runtime-tools/install-lock.d.ts +1 -1
- package/dist/src/runtime-tools/install-lock.js +34 -21
- package/dist/src/runtime-tools/manager.d.ts +1 -1
- package/dist/src/runtime-tools/manager.js +99 -64
- package/dist/src/runtime-tools/manifest-store.d.ts +2 -0
- package/dist/src/runtime-tools/manifest-store.js +29 -8
- package/dist/src/runtime-tools/paths.d.ts +2 -1
- package/dist/src/runtime-tools/paths.js +19 -8
- package/dist/src/runtime-tools/probe.d.ts +2 -0
- package/dist/src/runtime-tools/probe.js +13 -1
- package/dist/src/runtime-tools/prune.js +21 -7
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/index-DTo3IcbW.css +0 -2
- package/dist/gateway/static/root/assets/models-hub-cache-Y7GUjxHx.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-Bu0a83Oj.js +0 -4
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-Bv-akndY.js +0 -5
- package/dist/gateway/static/root/assets/settings-advanced-gate-CYCCUMEt.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BkvclZ_o.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-SeOHP6XO.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-
|
|
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-DVzTJSj2.js";import{Xn as o}from"./index-J3FsIvTs.js";import"./skill-reload-api-DDTmi4a7.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-_tYhRAHD.js";import{n as s}from"./locale-store-C5wr3_pc.js";import{t as c}from"./electron-env-DH5wF8X8.js";import{Bl as l,Cn as u,En as d,Fa as f,Ns as p,Tn as m,Ws as h,wn as g}from"./index-7i2P3312.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-DjWzRk4z.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!c()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=o(s(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(m),[r,i]=(0,x.useState)(null),[a,c]=(0,x.useState)(!1),f=async t=>{if(!t){n(d({enabled:!1})),i(null);return}c(!0);try{let t=await u();if(t!==`granted`){i(t===`unsupported`?e.unsupported:e.denied);return}n(d({enabled:!0})),i(await g(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},p=e=>{n(d(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)(l,{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`?f(t.target.checked):p({[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)(f,L),{behavior:d,perms:m,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)(p,{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&&m?(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)(h,{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,m[t]),c=n.perm[t],l=m[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,m[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,m[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,m[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,m[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,m[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-_tYhRAHD.js";import{n as s}from"./locale-store-DVzTJSj2.js";import{t as c}from"./electron-env-DH5wF8X8.js";import{Bl as l,Cn as u,En as d,Fa as f,Ns as p,Tn as m,Ws as h,wn as g}from"./index-J3FsIvTs.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-DjWzRk4z.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!c()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=o(s(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(m),[r,i]=(0,x.useState)(null),[a,c]=(0,x.useState)(!1),f=async t=>{if(!t){n(d({enabled:!1})),i(null);return}c(!0);try{let t=await u();if(t!==`granted`){i(t===`unsupported`?e.unsupported:e.denied);return}n(d({enabled:!0})),i(await g(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!1)}},p=e=>{n(d(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)(l,{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`?f(t.target.checked):p({[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)(f,L),{behavior:d,perms:m,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)(p,{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&&m?(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)(h,{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,m[t]),c=n.perm[t],l=m[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,m[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,m[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,m[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,m[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,m[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-DrILF6mR.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-D6LxlDxr.js";import{t as _}from"./folder-open-CyzJ19I9.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./cn-JdwAhgNB.js";import{t as b}from"./button-CSEbl4zT.js";import{n as ee,s as x}from"./locale-store-C5wr3_pc.js";import{t as S}from"./skeleton-BwbyijEw.js";import{i as te,n as ne,o as re,r as ie,s as ae,t as C}from"./dist-BPoKqzeH.js";import{A as oe,B as w,Di as se,Gl as T,I as ce,J as le,K as ue,M as de,N as fe,Nr as pe,Oi as E,Qs as D,Ua as O,W as me,Xc as k,Y as A,ar as he,bn as ge,cr as j,et as M,gl as N,hi as P,hl as F,ir as I,n as L,oo as R,or as _e,pc as ve,rc as ye,rr as be,sr as xe,ta as Se,xa as Ce,xn as we,yn as Te}from"./index-7i2P3312.js";import{t as Ee}from"./date-picker-CGAMGPfU.js";import{t as De}from"./dependency-picker-CxWeUTsc.js";var z=e(t(),1),Oe=e(n(),1),B=r();function ke(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Ae(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 V=i();function je(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Me(){let e=(0,B.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,V.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,V.jsx)(S,{className:`h-32 rounded-2xl`}),(0,V.jsx)(S,{className:`h-52 rounded-2xl`}),(0,V.jsx)(S,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Ne(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Pe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var H=[`backlog`,`ready`,`active`,`review`,`closed`],U=[`low`,`normal`,`high`,`critical`],Fe=(0,z.memo)(function(e){let t=(0,B.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,V.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=H.map(e=>(0,V.jsx)(u,{value:e,disabled:p(e),children:je(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,V.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,V.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}),Ie=(0,z.memo)(function(e){let t=(0,B.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,V.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=U.map(e=>(0,V.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,V.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,V.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}),Le=(0,z.memo)(function(e){let t=(0,B.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,V.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,V.jsx)(Ee,{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,V.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}),Re=(0,z.memo)(function(e){let t=(0,B.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,V.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,V.jsx)(u,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(tt),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,V.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,V.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}),ze=(0,z.memo)(function(e){let t=(0,B.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(nt),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,V.jsx)(De,{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)),Be=`xopc.taskDetail.chatPanelPercent`,Ve=42;function He(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?Ve:Math.min(r,Math.max(n,e))}function Ue(){try{let e=Number(window.localStorage.getItem(Be));return Number.isFinite(e)&&e>=30&&e<=60?e:Ve}catch{return Ve}}function We(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 W(e){let t=(0,B.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,V.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,V.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,V.jsx)(t===`passed`?d:t===`failed`?N:F,{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,V.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,V.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Ge({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=s(),a=o(),l=ee(e=>e.language),u=x(e=>e.token),v=(0,z.useMemo)(()=>A(l),[l]),S=R(e=>e.setPageHeader),te=R(e=>e.clearPageHeader),ne=E(e=>e.open),re=E(e=>e.sessionKeyOverride),ie=E(e=>e.openForSession),ae=pe(e=>e.setOpen),{data:C,error:se,mutate:N,lastChange:F,conversationLoading:we,conversationError:Ee}=oe(e),[De,B]=(0,z.useState)(null),[je,H]=(0,z.useState)(null),[U,Ge]=(0,z.useState)(()=>new Set),[Ke,qe]=(0,z.useState)([]),[G,Je]=(0,z.useState)(null),[Ye,Xe]=(0,z.useState)([]),[Ze,K]=(0,z.useState)(!1),[Qe,$e]=(0,z.useState)(``),[et,q]=(0,z.useState)(!1),[tt,nt]=(0,z.useState)(``),[rt,it]=(0,z.useState)(Ue),[at,ot]=(0,z.useState)(!1),st=(0,z.useRef)(null),ct=(0,z.useRef)(!1),lt=(0,z.useRef)(!1),ut=(0,z.useRef)(``),dt=(0,z.useRef)(null),ft=(0,z.useRef)(null),pt=(0,z.useRef)(null),mt=(0,z.useRef)(C),[ht,J]=(0,z.useState)(null),[gt,_t]=(0,z.useState)(null),[vt,yt]=(0,z.useState)(!1),bt=(0,z.useMemo)(()=>({link:v.linkDependencies,linked:v.linkedDependencies,searchPlaceholder:v.dependencySearchPlaceholder,noMatches:v.noDependencyMatches,noCandidates:v.noDependencyCandidates,remove:v.removeDependency}),[v.dependencySearchPlaceholder,v.linkDependencies,v.linkedDependencies,v.noDependencyCandidates,v.noDependencyMatches,v.removeDependency]),xt=C?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,St=(0,z.useMemo)(()=>m(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);mt.current=C;let Y=(0,z.useCallback)((e,t)=>{Ge(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,z.useEffect)(()=>{H(null),J(null),K(!1),q(!1),_t(null),yt(!1)},[e]),(0,z.useEffect)(()=>{let e=!0;return O().then(t=>{e&&Xe(t.items)}).catch(()=>void 0),()=>{e=!1}},[u]),(0,z.useEffect)(()=>{if(!F||F.source===`user`)return;_t(F);let e=window.setTimeout(()=>_t(null),3500);return()=>window.clearTimeout(e)},[F]),(0,z.useEffect)(()=>{let t=C?.task.projectId,n=C?.dependencies??[];if(!t){pt.current=null,Je(null),qe(n);return}pt.current!==t&&(pt.current=t,Je(null));let r=!0;return Ce(t).then(t=>{if(!r)return;Je(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});qe([...i.values()])}).catch(()=>{r&&qe(n)}),()=>{r=!1}},[xt,C?.task.projectId,e]);let X=(0,z.useCallback)(async(t,n=`command`)=>{let r=mt.current;if(r){Y(n,!0),H(null);try{await N(await fe(e,t,r.task.version),{revalidate:!1})}catch{H(v.actionFailed)}finally{Y(n,!1)}}},[v.actionFailed,N,Y,e]),Z=(0,z.useCallback)(async(t,n)=>{let r=mt.current;if(!r)return!1;n&&Y(n,!0),H(null);try{return await N(ue(e,t,r.task.version),{optimisticData:Ae(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return H(v.actionFailed),!1}finally{n&&Y(n,!1)}},[v.actionFailed,N,Y,e]),Ct=async()=>{if(!C)return;if(ct.current){ct.current=!1;return}let e=Qe.trim(),t=dt.current;if(ke(t,C.task.version,C.task.title,e)){J(`title`);return}if(!e||e===C.task.title){$e(C.task.title),K(!1);return}await Z({title:e})&&(J(null),K(!1))},wt=async()=>{if(!C)return;if(lt.current){lt.current=!1;return}let e=tt.trim(),t=ft.current;if(ke(t,C.task.version,C.task.body??``,e)){J(`description`);return}if(tt===ut.current||e===(C.task.body??``).trim()){q(!1);return}await Z({body:e||null})&&(J(null),q(!1))},Tt=(0,z.useCallback)(async e=>{let t=mt.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await X({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await X({type:`close`,resolution:`done`},`phase`);return}await X({type:`move`,phase:e},`phase`)}},[X]),Et=(0,z.useCallback)(e=>{Z({priority:e},`priority`)},[Z]),Dt=(0,z.useCallback)(e=>{Z({dueAt:Pe(e)},`dueAt`)},[Z]),Ot=(0,z.useCallback)(e=>{it(e);try{window.localStorage.setItem(Be,String(e))}catch{}},[]),kt=(0,z.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=st.current?.clientWidth??0;Ot(He(e.key===`Home`?Ve:rt+(e.key===`ArrowLeft`?2:-2),t))},[rt,Ot]),At=(0,z.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=st.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),ot(!0);let i=rt,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=He((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{}ot(!1),Ot(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)},[rt,Ot]),jt=(0,z.useCallback)(async t=>{let n=mt.current;if(n){Y(`dependencies`,!0),H(null);try{await N(await le(e,t,n.task.version),{revalidate:!1})}catch{H(v.dependencyUpdateFailed)}finally{Y(`dependencies`,!1)}}},[v.dependencyUpdateFailed,N,Y,e]),Mt=(0,z.useCallback)(async t=>{let n=mt.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){Y(`delegateAgentId`,!0),H(null);try{await N(await w(e,t,n.task.version),{revalidate:!1})}catch{H(v.actionFailed)}finally{Y(`delegateAgentId`,!1)}}},[v.actionFailed,N,Y,e]),Nt=(0,z.useCallback)(async()=>{Y(`delete`,!0),H(null);try{await ce(e),r?r():a(St,{replace:!0})}catch(e){H(e instanceof Error?e.message:v.actionFailed)}finally{Y(`delete`,!1)}},[v.actionFailed,a,r,St,Y,e]);if((0,z.useLayoutEffect)(()=>{if(t!==`modal`)return S({startExtra:(0,V.jsx)(c,{to:St,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":v.backToWork,children:(0,V.jsx)(T,{className:`size-4`})}),main:C?(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:G?`${G} / ${v.taskLabel}`:v.taskLabel}),(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:v.detailStatuses[We(C)]})]}):null,end:(0,V.jsx)(`div`,{ref:B,className:`flex min-w-0 items-center justify-end`})}),te},[te,v.backToWork,v.detailStatuses,v.taskLabel,C,t,G,St,S]),se&&!C)return(0,V.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:v.taskNotFound});if(!C)return(0,V.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,V.jsx)(Me,{})});let Pt=C.waits[0],Ft=Pt?.kind===`paused`?Pt:void 0,Q=C.receipts[0],It=v.detailStatuses[We(C)],Lt=v.detailStatusDescriptions[We(C)],Rt=C.task.body?.trim()||C.task.contract?.objective.trim(),zt=new Map(Q?.verification.checks.map(e=>[e.criterion,e.status])),Bt=C.allowedCommands.includes(`mark_ready`),Vt=C.allowedCommands.includes(`start`),Ht=C.allowedCommands.includes(`add_wait`),Ut=C.task.phase===`review`&&C.allowedCommands.includes(`close`),Wt=C.allowedCommands.includes(`reopen`),Gt=C.conversation.activeSessionKey,Kt=C.conversation.currentExecutorAgentId??C.task.delegateAgentId??C.task.ownerId,qt=Ye.find(e=>e.id===Kt),Jt=!!(Gt&&ne&&re===Gt),Yt=C.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Xt=C.task.contract?.acceptanceCriteria??[],Zt=Xt.filter(e=>zt.get(e)===`passed`).length,Qt=C.task.contract?.expectedOutputs??[],$t=C.task.contract?.constraints??[],en=C.task.contract?.approvalRequired??[],tn=C.task.contract?.assumptions??[],nn=C.task.contract?.risks??[],$=(...e)=>!!gt?.changedFields.some(t=>e.includes(t)),rn=e=>t===`modal`&&n?ge(n,e):h(`/tasks/${e}`,St),an=C.allowedCommands.includes(`move`),on=U.has(`command`),sn=U.has(`delete`),cn=C.runs.find(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),ln=cn!==void 0,un=(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Bt?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`mark_ready`}),children:[(0,V.jsx)(D,{className:`size-4`}),v.scheduleTask]}):null,Ft?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`resolve_wait`,waitId:Ft.id}),children:[(0,V.jsx)(D,{className:`size-4`}),v.resumeTask]}):null,!Pt&&Vt&&Kt?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`start`,executor:{kind:`agent`,agentId:Kt}}),children:[(0,V.jsx)(D,{className:`size-4`}),v.runTask]}):null,Ut?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`close`,resolution:`done`}),children:[(0,V.jsx)(d,{className:`size-4`}),v.approveTask]}):null,Wt?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`reopen`,phase:`ready`}),children:[(0,V.jsx)(D,{className:`size-4`}),v.reopenTask]}):null,!Pt&&Ht?(0,V.jsxs)(b,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:on,onClick:()=>void X({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,V.jsx)(ye,{className:`size-4`}),v.pauseTask]}):null,(0,V.jsxs)(_e,{children:[(0,V.jsx)(j,{asChild:!0,children:(0,V.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:on||sn,"aria-label":v.moreActions,children:(0,V.jsx)(f,{className:`size-4`,"aria-hidden":!0})})}),(0,V.jsx)(he,{children:(0,V.jsxs)(be,{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,V.jsx)(I,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{Y(`command`,!0),H(null),N(de(e,cn.id,cn.version),{revalidate:!1}).catch(()=>H(v.actionFailed)).finally(()=>Y(`command`,!1))},children:v.cancelActiveRun}):null,cn?(0,V.jsx)(xe,{className:`my-1 h-px bg-edge`}):null,C.task.phase===`closed`?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(I,{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 X({type:`close`,resolution:`cancelled`}),children:v.cancelTask}),(0,V.jsx)(xe,{className:`my-1 h-px bg-edge`})]}),(0,V.jsx)(I,{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){H(v.deleteActiveTaskBlocked);return}yt(!0)},children:v.deleteTask})]})})]})]}),Gt&&t!==`modal`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(b,{type:`button`,variant:`ghost`,className:y(`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(Gt,!1),ie(Gt)},children:[(0,V.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,V.jsx)(b,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,V.jsxs)(c,{to:Te(e),children:[(0,V.jsx)(p,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]});return(0,V.jsxs)(`div`,{ref:st,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`} ${at?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${rt}%`},children:[t===`page`&&De?(0,Oe.createPortal)(un,De):null,(0,V.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,V.jsxs)(`header`,{className:y(`px-4 pb-5`,$(`title`)&&`task-detail-live-update`),children:[(0,V.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[G?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),G]}):null,(0,V.jsx)(`span`,{children:`/`}),(0,V.jsx)(`span`,{children:v.taskLabel}),gt?(0,V.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:gt.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Ze?(0,V.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:Qe,onChange:e=>$e(e.target.value),onBlur:()=>void Ct(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ct.current=!0,$e(C.task.title),K(!1),queueMicrotask(()=>{ct.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,V.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:()=>{dt.current={value:C.task.title,version:C.task.version},J(null),$e(C.task.title),K(!0)},children:(0,V.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:C.task.title})}),ht===`title`?(0,V.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,V.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{$e(C.task.title),J(null),K(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Z({title:Qe.trim()}).then(e=>{e&&(J(null),K(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),je?(0,V.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:je}):null]}),(0,V.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,V.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`body`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.taskDescription}),et?(0,V.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:tt,onChange:e=>nt(e.target.value),onBlur:()=>void wt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),lt.current=!0,nt(C.task.body??C.task.contract?.objective??``),q(!1),queueMicrotask(()=>{lt.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,V.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=C.task.body??C.task.contract?.objective??``;ut.current=e,ft.current={value:C.task.body??``,version:C.task.version},J(null),nt(e),q(!0)},children:(0,V.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:Rt&&Rt!==C.task.title?Rt:v.noTaskDescription})}),ht===`description`?(0,V.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,V.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{nt(C.task.body??``),J(null),q(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Z({body:tt.trim()||null}).then(e=>{e&&(J(null),q(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),C.attention.length>0?(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-warning/10 p-4`,$(`attention`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h3`,{className:`font-medium text-fg`,children:Yt?v.needsAttention:v.waitingStatus}),(0,V.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:C.attention.map((e,t)=>(0,V.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`contract`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.taskDefinition}),(0,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:v.successDefinition}),Xt.length>0?(0,V.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:v.criteriaProgress.replace(`{{verified}}`,String(Zt)).replace(`{{total}}`,String(Xt.length))}):null]}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:Xt,empty:v.noDefinition,verificationByCriterion:zt})})]}),Qt.length>0?(0,V.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:v.expectedOutputs}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:Qt,empty:v.noDefinition})})]}):null,$t.length>0?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:v.constraints}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:$t,empty:v.noDefinition})})]}):null,en.length>0?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:v.approvalRequired}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:en,empty:v.noDefinition})})]}):null,tn.length>0?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:v.contextAssumptions}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:tn,empty:v.noDefinition})})]}):null,nn.length>0?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:v.contextRisks}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:nn,empty:v.noDefinition})})]}):null]}),Q?(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.latestResult}),(0,V.jsx)(g,{content:Q.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,V.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[v.receiptStatuses[Q.status],` · `,v.verificationStatuses[Q.verification.status]]})]}),Q.remainingWork.length>0?(0,V.jsxs)(`div`,{className:`mt-4`,children:[(0,V.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:v.remainingWork}),(0,V.jsx)(`div`,{className:`mt-2`,children:(0,V.jsx)(W,{items:Q.remainingWork,empty:v.noRemainingWork})})]}):null,Q.nextAction?(0,V.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.nextAction}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Q.nextAction})]}):null,(0,V.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(b,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void me(Q.runId,`helpful`),children:v.doneWell}),(0,V.jsx)(b,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void me(Q.runId,`not_helpful`),children:v.needsFix}),Q.evidence.filter(e=>e.uri).map(e=>(0,V.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,V.jsx)(p,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),C.receipts.length>1?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:v.executionHistory.replace(`{{count}}`,String(C.receipts.length-1))}),(0,V.jsx)(`div`,{className:`mt-3 space-y-3`,children:C.receipts.slice(1).map(e=>(0,V.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,V.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:v.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,C.context.length>0?(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`context`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.contextUsed}),(0,V.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:C.context.map(e=>(0,V.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,V.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[v.contextRoleLabels[e.role],` · `,v.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,V.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,V.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,V.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-subtle p-4`,$(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.taskProperties}),(0,V.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,V.jsx)(Fe,{value:C.task.phase,disabled:U.has(`phase`),canMove:an,canApprove:Ut,canReopen:Wt,language:l,label:v.taskPhase,onChange:Tt}),(0,V.jsx)(Ie,{value:C.task.priority,disabled:U.has(`priority`),label:v.priority,labels:v.priorityLabels,onChange:Et}),(0,V.jsx)(Le,{value:Ne(C.task.dueAt),disabled:U.has(`dueAt`),label:v.dueDate,onChange:Dt}),(0,V.jsx)(Re,{value:C.conversation.currentExecutorAgentId??``,disabled:U.has(`delegateAgentId`),label:v.executorLabel,unassignedLabel:v.unassigned,agents:Ye,onChange:Mt}),G?(0,V.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,V.jsx)(`span`,{children:v.projectLabel}),(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,V.jsx)(k,{className:`size-3.5`}),G]})]}):null]}),(0,V.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,V.jsx)(`p`,{children:It}),(0,V.jsx)(`p`,{children:Lt}),(0,V.jsx)(`p`,{className:`mt-2`,children:v.updatedAt.replace(`{{date}}`,P(C.task.updatedAt,l))})]})]}),(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`dependencies`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.taskRelations}),(0,V.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:v.dependencies}),(0,V.jsx)(ze,{candidates:Ke,selected:C.dependencies,disabled:U.has(`dependencies`),labels:bt,onChange:jt})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:v.dependents}),C.dependents.length>0?(0,V.jsx)(`div`,{className:`space-y-1.5`,children:C.dependents.map(e=>(0,V.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,V.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:v.noDependents})]})]})]})]})]})]}),(0,V.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(rt),tabIndex:0,onPointerDown:At,onKeyDown:kt,onDoubleClick:()=>Ot(Ve),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 ${at?`bg-surface-hover`:``}`,children:(0,V.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,V.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,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,V.jsx)(`div`,{className:`min-w-0`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Kt?(0,V.jsx)(M,{agentId:Kt,avatar:qt?.avatar,size:28,className:`shrink-0`}):null,(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,V.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[qt?.name??Kt??v.unassigned,` · `,It]})]})]})}),t===`modal`?un:null]}),Gt?(0,V.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,V.jsx)(L,{embedded:!0,sessionKey:Gt,taskId:e})}):we?(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,V.jsxs)(`div`,{className:`max-w-xs`,children:[(0,V.jsx)(ve,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,V.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):Ee?(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,V.jsxs)(`div`,{className:`max-w-xs`,children:[(0,V.jsx)(ve,{className:`mx-auto size-8 text-danger`}),(0,V.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,V.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:Ee instanceof Error?Ee.message:String(Ee)})]})}):(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,V.jsxs)(`div`,{className:`max-w-xs`,children:[(0,V.jsx)(ve,{className:`mx-auto size-8 text-fg-subtle`}),(0,V.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,V.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,V.jsx)(Se,{open:vt,title:v.deleteTaskTitle,description:v.deleteTaskDescription.replace(`{{title}}`,C.task.title),confirmLabel:v.confirmDeleteTask,cancelLabel:v.keepTask,destructive:!0,onConfirm:()=>{yt(!1),Nt()},onCancel:()=>yt(!1)})]})}function Ke(){let e=(0,B.c)(2),{taskId:t}=a(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,V.jsx)(Ge,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function qe(e){let t=(0,B.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=ee(q),{data:o}=oe(n),s=o?.conversation.activeSessionKey??null,l=E(et),u=E($e),d=E(Qe),f=E(K),m=pe(Ze),h=se(Xe),g=se(Ye),b=l?u:0,x;t[0]!==i||t[1]!==g?(x=e=>{e||(g(null),i())},t[0]=i,t[1]=g,t[2]=x):x=t[2];let S=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]!==S||t[7]!==w?(T=(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":S,onClick:w}),t[6]=S,t[7]=w,t[8]=T):T=t[8];let ce=l?`true`:`false`,le=`${b/2}px`,ue=`${b}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,D=a===`zh`?`任务详情`:`Task details`,O;t[12]===D?O=t[13]:(O=(0,V.jsx)(ae,{className:`font-medium text-fg`,children:D}),t[12]=D,t[13]=O);let me=a===`zh`?`查看并操作任务详情`:`View and manage task details`,k;t[14]===me?k=t[15]:(k=(0,V.jsx)(te,{className:`sr-only`,children:me}),t[14]=me,t[15]=k);let A;t[16]!==s||t[17]!==a||t[18]!==f||t[19]!==m||t[20]!==n||t[21]!==l||t[22]!==d?(A=s?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:y(`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,V.jsx)(_,{className:`size-4`,"aria-hidden":!0})}),(0,V.jsx)(c,{to:Te(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,V.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]=A):A=t[23];let he=a===`zh`?`关闭任务详情`:`Close task details`,ge;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,V.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[24]=ge):ge=t[24];let j;t[25]===he?j=t[26]:(j=(0,V.jsx)(ne,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":he,children:ge}),t[25]=he,t[26]=j);let M;t[27]!==A||t[28]!==j?(M=(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[A,j]}),t[27]=A,t[28]=j,t[29]=M):M=t[29];let N;t[30]!==O||t[31]!==k||t[32]!==M?(N=(0,V.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[O,k,M]}),t[30]=O,t[31]=k,t[32]=M,t[33]=N):N=t[33];let P;t[34]!==i||t[35]!==g?(P=()=>{g(null),i()},t[34]=i,t[35]=g,t[36]=P):P=t[36];let F;t[37]!==r||t[38]!==P||t[39]!==n?(F=(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,V.jsx)(Ge,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:P})}),t[37]=r,t[38]=P,t[39]=n,t[40]=F):F=t[40];let I;t[41]!==N||t[42]!==F||t[43]!==ce||t[44]!==fe?(I=(0,V.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:Je,onInteractOutside:G,children:[N,F]}),t[41]=N,t[42]=F,t[43]=ce,t[44]=fe,t[45]=I):I=t[45];let L;t[46]!==h||t[47]!==l||t[48]!==u||t[49]!==d?(L=h?(0,V.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,V.jsx)(we,{allowOutsideChat:!0,sessionKey:d??void 0})}):null,t[46]=h,t[47]=l,t[48]=u,t[49]=d,t[50]=L):L=t[50];let R;t[51]!==I||t[52]!==L||t[53]!==T?(R=(0,V.jsxs)(re,{children:[T,I,L]}),t[51]=I,t[52]=L,t[53]=T,t[54]=R):R=t[54];let _e;return t[55]!==x||t[56]!==R?(_e=(0,V.jsx)(C,{modal:!1,open:!0,onOpenChange:x,children:R}),t[55]=x,t[56]=R,t[57]=_e):_e=t[57],_e}function G(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Je(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Ye(e){return e.setPath}function Xe(e){return e.path}function Ze(e){return e.setOpen}function K(e){return e.openForSession}function Qe(e){return e.sessionKeyOverride}function $e(e){return e.widthPx}function et(e){return e.open}function q(e){return e.language}function tt(e){return(0,V.jsx)(u,{value:e.id,children:e.name||e.id},e.id)}function nt(e){return e.id}export{qe as TaskDetailModal,Ke 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-DrILF6mR.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-DR3yVwtV.js";import{t as _}from"./folder-open-CyzJ19I9.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./cn-JdwAhgNB.js";import{t as b}from"./button-CSEbl4zT.js";import{n as ee,s as x}from"./locale-store-DVzTJSj2.js";import{t as S}from"./skeleton-BwbyijEw.js";import{i as te,n as ne,o as re,r as ie,s as ae,t as C}from"./dist-BPoKqzeH.js";import{A as oe,B as w,Di as se,Gl as T,I as ce,J as le,K as ue,M as de,N as fe,Nr as pe,Oi as E,Qs as D,Ua as O,W as me,Xc as k,Y as A,ar as he,bn as ge,cr as j,et as M,gl as N,hi as P,hl as F,ir as I,n as L,oo as R,or as _e,pc as ve,rc as ye,rr as be,sr as xe,ta as Se,xa as Ce,xn as we,yn as Te}from"./index-J3FsIvTs.js";import{t as Ee}from"./date-picker-Bz1sLBEx.js";import{t as De}from"./dependency-picker-p9DWR8uU.js";var z=e(t(),1),Oe=e(n(),1),B=r();function ke(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Ae(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 V=i();function je(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Me(){let e=(0,B.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,V.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,V.jsx)(S,{className:`h-32 rounded-2xl`}),(0,V.jsx)(S,{className:`h-52 rounded-2xl`}),(0,V.jsx)(S,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Ne(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Pe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var H=[`backlog`,`ready`,`active`,`review`,`closed`],U=[`low`,`normal`,`high`,`critical`],Fe=(0,z.memo)(function(e){let t=(0,B.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,V.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=H.map(e=>(0,V.jsx)(u,{value:e,disabled:p(e),children:je(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,V.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,V.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}),Ie=(0,z.memo)(function(e){let t=(0,B.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,V.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=U.map(e=>(0,V.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,V.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,V.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}),Le=(0,z.memo)(function(e){let t=(0,B.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,V.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,V.jsx)(Ee,{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,V.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}),Re=(0,z.memo)(function(e){let t=(0,B.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,V.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,V.jsx)(u,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(tt),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,V.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,V.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}),ze=(0,z.memo)(function(e){let t=(0,B.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(nt),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,V.jsx)(De,{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)),Be=`xopc.taskDetail.chatPanelPercent`,Ve=42;function He(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?Ve:Math.min(r,Math.max(n,e))}function Ue(){try{let e=Number(window.localStorage.getItem(Be));return Number.isFinite(e)&&e>=30&&e<=60?e:Ve}catch{return Ve}}function We(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 W(e){let t=(0,B.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,V.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,V.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,V.jsx)(t===`passed`?d:t===`failed`?N:F,{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,V.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,V.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Ge({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=s(),a=o(),l=ee(e=>e.language),u=x(e=>e.token),v=(0,z.useMemo)(()=>A(l),[l]),S=R(e=>e.setPageHeader),te=R(e=>e.clearPageHeader),ne=E(e=>e.open),re=E(e=>e.sessionKeyOverride),ie=E(e=>e.openForSession),ae=pe(e=>e.setOpen),{data:C,error:se,mutate:N,lastChange:F,conversationLoading:we,conversationError:Ee}=oe(e),[De,B]=(0,z.useState)(null),[je,H]=(0,z.useState)(null),[U,Ge]=(0,z.useState)(()=>new Set),[Ke,qe]=(0,z.useState)([]),[G,Je]=(0,z.useState)(null),[Ye,Xe]=(0,z.useState)([]),[Ze,K]=(0,z.useState)(!1),[Qe,$e]=(0,z.useState)(``),[et,q]=(0,z.useState)(!1),[tt,nt]=(0,z.useState)(``),[rt,it]=(0,z.useState)(Ue),[at,ot]=(0,z.useState)(!1),st=(0,z.useRef)(null),ct=(0,z.useRef)(!1),lt=(0,z.useRef)(!1),ut=(0,z.useRef)(``),dt=(0,z.useRef)(null),ft=(0,z.useRef)(null),pt=(0,z.useRef)(null),mt=(0,z.useRef)(C),[ht,J]=(0,z.useState)(null),[gt,_t]=(0,z.useState)(null),[vt,yt]=(0,z.useState)(!1),bt=(0,z.useMemo)(()=>({link:v.linkDependencies,linked:v.linkedDependencies,searchPlaceholder:v.dependencySearchPlaceholder,noMatches:v.noDependencyMatches,noCandidates:v.noDependencyCandidates,remove:v.removeDependency}),[v.dependencySearchPlaceholder,v.linkDependencies,v.linkedDependencies,v.noDependencyCandidates,v.noDependencyMatches,v.removeDependency]),xt=C?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,St=(0,z.useMemo)(()=>m(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);mt.current=C;let Y=(0,z.useCallback)((e,t)=>{Ge(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,z.useEffect)(()=>{H(null),J(null),K(!1),q(!1),_t(null),yt(!1)},[e]),(0,z.useEffect)(()=>{let e=!0;return O().then(t=>{e&&Xe(t.items)}).catch(()=>void 0),()=>{e=!1}},[u]),(0,z.useEffect)(()=>{if(!F||F.source===`user`)return;_t(F);let e=window.setTimeout(()=>_t(null),3500);return()=>window.clearTimeout(e)},[F]),(0,z.useEffect)(()=>{let t=C?.task.projectId,n=C?.dependencies??[];if(!t){pt.current=null,Je(null),qe(n);return}pt.current!==t&&(pt.current=t,Je(null));let r=!0;return Ce(t).then(t=>{if(!r)return;Je(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});qe([...i.values()])}).catch(()=>{r&&qe(n)}),()=>{r=!1}},[xt,C?.task.projectId,e]);let X=(0,z.useCallback)(async(t,n=`command`)=>{let r=mt.current;if(r){Y(n,!0),H(null);try{await N(await fe(e,t,r.task.version),{revalidate:!1})}catch{H(v.actionFailed)}finally{Y(n,!1)}}},[v.actionFailed,N,Y,e]),Z=(0,z.useCallback)(async(t,n)=>{let r=mt.current;if(!r)return!1;n&&Y(n,!0),H(null);try{return await N(ue(e,t,r.task.version),{optimisticData:Ae(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return H(v.actionFailed),!1}finally{n&&Y(n,!1)}},[v.actionFailed,N,Y,e]),Ct=async()=>{if(!C)return;if(ct.current){ct.current=!1;return}let e=Qe.trim(),t=dt.current;if(ke(t,C.task.version,C.task.title,e)){J(`title`);return}if(!e||e===C.task.title){$e(C.task.title),K(!1);return}await Z({title:e})&&(J(null),K(!1))},wt=async()=>{if(!C)return;if(lt.current){lt.current=!1;return}let e=tt.trim(),t=ft.current;if(ke(t,C.task.version,C.task.body??``,e)){J(`description`);return}if(tt===ut.current||e===(C.task.body??``).trim()){q(!1);return}await Z({body:e||null})&&(J(null),q(!1))},Tt=(0,z.useCallback)(async e=>{let t=mt.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await X({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await X({type:`close`,resolution:`done`},`phase`);return}await X({type:`move`,phase:e},`phase`)}},[X]),Et=(0,z.useCallback)(e=>{Z({priority:e},`priority`)},[Z]),Dt=(0,z.useCallback)(e=>{Z({dueAt:Pe(e)},`dueAt`)},[Z]),Ot=(0,z.useCallback)(e=>{it(e);try{window.localStorage.setItem(Be,String(e))}catch{}},[]),kt=(0,z.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=st.current?.clientWidth??0;Ot(He(e.key===`Home`?Ve:rt+(e.key===`ArrowLeft`?2:-2),t))},[rt,Ot]),At=(0,z.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=st.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),ot(!0);let i=rt,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=He((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{}ot(!1),Ot(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)},[rt,Ot]),jt=(0,z.useCallback)(async t=>{let n=mt.current;if(n){Y(`dependencies`,!0),H(null);try{await N(await le(e,t,n.task.version),{revalidate:!1})}catch{H(v.dependencyUpdateFailed)}finally{Y(`dependencies`,!1)}}},[v.dependencyUpdateFailed,N,Y,e]),Mt=(0,z.useCallback)(async t=>{let n=mt.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){Y(`delegateAgentId`,!0),H(null);try{await N(await w(e,t,n.task.version),{revalidate:!1})}catch{H(v.actionFailed)}finally{Y(`delegateAgentId`,!1)}}},[v.actionFailed,N,Y,e]),Nt=(0,z.useCallback)(async()=>{Y(`delete`,!0),H(null);try{await ce(e),r?r():a(St,{replace:!0})}catch(e){H(e instanceof Error?e.message:v.actionFailed)}finally{Y(`delete`,!1)}},[v.actionFailed,a,r,St,Y,e]);if((0,z.useLayoutEffect)(()=>{if(t!==`modal`)return S({startExtra:(0,V.jsx)(c,{to:St,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":v.backToWork,children:(0,V.jsx)(T,{className:`size-4`})}),main:C?(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:G?`${G} / ${v.taskLabel}`:v.taskLabel}),(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:v.detailStatuses[We(C)]})]}):null,end:(0,V.jsx)(`div`,{ref:B,className:`flex min-w-0 items-center justify-end`})}),te},[te,v.backToWork,v.detailStatuses,v.taskLabel,C,t,G,St,S]),se&&!C)return(0,V.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:v.taskNotFound});if(!C)return(0,V.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,V.jsx)(Me,{})});let Pt=C.waits[0],Ft=Pt?.kind===`paused`?Pt:void 0,Q=C.receipts[0],It=v.detailStatuses[We(C)],Lt=v.detailStatusDescriptions[We(C)],Rt=C.task.body?.trim()||C.task.contract?.objective.trim(),zt=new Map(Q?.verification.checks.map(e=>[e.criterion,e.status])),Bt=C.allowedCommands.includes(`mark_ready`),Vt=C.allowedCommands.includes(`start`),Ht=C.allowedCommands.includes(`add_wait`),Ut=C.task.phase===`review`&&C.allowedCommands.includes(`close`),Wt=C.allowedCommands.includes(`reopen`),Gt=C.conversation.activeSessionKey,Kt=C.conversation.currentExecutorAgentId??C.task.delegateAgentId??C.task.ownerId,qt=Ye.find(e=>e.id===Kt),Jt=!!(Gt&&ne&&re===Gt),Yt=C.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Xt=C.task.contract?.acceptanceCriteria??[],Zt=Xt.filter(e=>zt.get(e)===`passed`).length,Qt=C.task.contract?.expectedOutputs??[],$t=C.task.contract?.constraints??[],en=C.task.contract?.approvalRequired??[],tn=C.task.contract?.assumptions??[],nn=C.task.contract?.risks??[],$=(...e)=>!!gt?.changedFields.some(t=>e.includes(t)),rn=e=>t===`modal`&&n?ge(n,e):h(`/tasks/${e}`,St),an=C.allowedCommands.includes(`move`),on=U.has(`command`),sn=U.has(`delete`),cn=C.runs.find(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),ln=cn!==void 0,un=(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Bt?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`mark_ready`}),children:[(0,V.jsx)(D,{className:`size-4`}),v.scheduleTask]}):null,Ft?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`resolve_wait`,waitId:Ft.id}),children:[(0,V.jsx)(D,{className:`size-4`}),v.resumeTask]}):null,!Pt&&Vt&&Kt?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`start`,executor:{kind:`agent`,agentId:Kt}}),children:[(0,V.jsx)(D,{className:`size-4`}),v.runTask]}):null,Ut?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`close`,resolution:`done`}),children:[(0,V.jsx)(d,{className:`size-4`}),v.approveTask]}):null,Wt?(0,V.jsxs)(b,{variant:`primary`,disabled:on,onClick:()=>void X({type:`reopen`,phase:`ready`}),children:[(0,V.jsx)(D,{className:`size-4`}),v.reopenTask]}):null,!Pt&&Ht?(0,V.jsxs)(b,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:on,onClick:()=>void X({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,V.jsx)(ye,{className:`size-4`}),v.pauseTask]}):null,(0,V.jsxs)(_e,{children:[(0,V.jsx)(j,{asChild:!0,children:(0,V.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:on||sn,"aria-label":v.moreActions,children:(0,V.jsx)(f,{className:`size-4`,"aria-hidden":!0})})}),(0,V.jsx)(he,{children:(0,V.jsxs)(be,{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,V.jsx)(I,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{Y(`command`,!0),H(null),N(de(e,cn.id,cn.version),{revalidate:!1}).catch(()=>H(v.actionFailed)).finally(()=>Y(`command`,!1))},children:v.cancelActiveRun}):null,cn?(0,V.jsx)(xe,{className:`my-1 h-px bg-edge`}):null,C.task.phase===`closed`?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(I,{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 X({type:`close`,resolution:`cancelled`}),children:v.cancelTask}),(0,V.jsx)(xe,{className:`my-1 h-px bg-edge`})]}),(0,V.jsx)(I,{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){H(v.deleteActiveTaskBlocked);return}yt(!0)},children:v.deleteTask})]})})]})]}),Gt&&t!==`modal`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(b,{type:`button`,variant:`ghost`,className:y(`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(Gt,!1),ie(Gt)},children:[(0,V.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,V.jsx)(b,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,V.jsxs)(c,{to:Te(e),children:[(0,V.jsx)(p,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]});return(0,V.jsxs)(`div`,{ref:st,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`} ${at?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${rt}%`},children:[t===`page`&&De?(0,Oe.createPortal)(un,De):null,(0,V.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,V.jsxs)(`header`,{className:y(`px-4 pb-5`,$(`title`)&&`task-detail-live-update`),children:[(0,V.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[G?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),G]}):null,(0,V.jsx)(`span`,{children:`/`}),(0,V.jsx)(`span`,{children:v.taskLabel}),gt?(0,V.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:gt.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Ze?(0,V.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:Qe,onChange:e=>$e(e.target.value),onBlur:()=>void Ct(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ct.current=!0,$e(C.task.title),K(!1),queueMicrotask(()=>{ct.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,V.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:()=>{dt.current={value:C.task.title,version:C.task.version},J(null),$e(C.task.title),K(!0)},children:(0,V.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:C.task.title})}),ht===`title`?(0,V.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,V.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{$e(C.task.title),J(null),K(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Z({title:Qe.trim()}).then(e=>{e&&(J(null),K(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),je?(0,V.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:je}):null]}),(0,V.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,V.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`body`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.taskDescription}),et?(0,V.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:tt,onChange:e=>nt(e.target.value),onBlur:()=>void wt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),lt.current=!0,nt(C.task.body??C.task.contract?.objective??``),q(!1),queueMicrotask(()=>{lt.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,V.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=C.task.body??C.task.contract?.objective??``;ut.current=e,ft.current={value:C.task.body??``,version:C.task.version},J(null),nt(e),q(!0)},children:(0,V.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:Rt&&Rt!==C.task.title?Rt:v.noTaskDescription})}),ht===`description`?(0,V.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,V.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{nt(C.task.body??``),J(null),q(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Z({body:tt.trim()||null}).then(e=>{e&&(J(null),q(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),C.attention.length>0?(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-warning/10 p-4`,$(`attention`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h3`,{className:`font-medium text-fg`,children:Yt?v.needsAttention:v.waitingStatus}),(0,V.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:C.attention.map((e,t)=>(0,V.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`contract`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.taskDefinition}),(0,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:v.successDefinition}),Xt.length>0?(0,V.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:v.criteriaProgress.replace(`{{verified}}`,String(Zt)).replace(`{{total}}`,String(Xt.length))}):null]}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:Xt,empty:v.noDefinition,verificationByCriterion:zt})})]}),Qt.length>0?(0,V.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:v.expectedOutputs}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:Qt,empty:v.noDefinition})})]}):null,$t.length>0?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:v.constraints}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:$t,empty:v.noDefinition})})]}):null,en.length>0?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:v.approvalRequired}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:en,empty:v.noDefinition})})]}):null,tn.length>0?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:v.contextAssumptions}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:tn,empty:v.noDefinition})})]}):null,nn.length>0?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:v.contextRisks}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{items:nn,empty:v.noDefinition})})]}):null]}),Q?(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.latestResult}),(0,V.jsx)(g,{content:Q.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,V.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[v.receiptStatuses[Q.status],` · `,v.verificationStatuses[Q.verification.status]]})]}),Q.remainingWork.length>0?(0,V.jsxs)(`div`,{className:`mt-4`,children:[(0,V.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:v.remainingWork}),(0,V.jsx)(`div`,{className:`mt-2`,children:(0,V.jsx)(W,{items:Q.remainingWork,empty:v.noRemainingWork})})]}):null,Q.nextAction?(0,V.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.nextAction}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Q.nextAction})]}):null,(0,V.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(b,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void me(Q.runId,`helpful`),children:v.doneWell}),(0,V.jsx)(b,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void me(Q.runId,`not_helpful`),children:v.needsFix}),Q.evidence.filter(e=>e.uri).map(e=>(0,V.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,V.jsx)(p,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),C.receipts.length>1?(0,V.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:v.executionHistory.replace(`{{count}}`,String(C.receipts.length-1))}),(0,V.jsx)(`div`,{className:`mt-3 space-y-3`,children:C.receipts.slice(1).map(e=>(0,V.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,V.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:v.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,C.context.length>0?(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`context`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.contextUsed}),(0,V.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:C.context.map(e=>(0,V.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,V.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[v.contextRoleLabels[e.role],` · `,v.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,V.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,V.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,V.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-subtle p-4`,$(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.taskProperties}),(0,V.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,V.jsx)(Fe,{value:C.task.phase,disabled:U.has(`phase`),canMove:an,canApprove:Ut,canReopen:Wt,language:l,label:v.taskPhase,onChange:Tt}),(0,V.jsx)(Ie,{value:C.task.priority,disabled:U.has(`priority`),label:v.priority,labels:v.priorityLabels,onChange:Et}),(0,V.jsx)(Le,{value:Ne(C.task.dueAt),disabled:U.has(`dueAt`),label:v.dueDate,onChange:Dt}),(0,V.jsx)(Re,{value:C.conversation.currentExecutorAgentId??``,disabled:U.has(`delegateAgentId`),label:v.executorLabel,unassignedLabel:v.unassigned,agents:Ye,onChange:Mt}),G?(0,V.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,V.jsx)(`span`,{children:v.projectLabel}),(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,V.jsx)(k,{className:`size-3.5`}),G]})]}):null]}),(0,V.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,V.jsx)(`p`,{children:It}),(0,V.jsx)(`p`,{children:Lt}),(0,V.jsx)(`p`,{className:`mt-2`,children:v.updatedAt.replace(`{{date}}`,P(C.task.updatedAt,l))})]})]}),(0,V.jsxs)(`section`,{className:y(`rounded-xl bg-surface-panel p-4`,$(`dependencies`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`font-medium text-fg`,children:v.taskRelations}),(0,V.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:v.dependencies}),(0,V.jsx)(ze,{candidates:Ke,selected:C.dependencies,disabled:U.has(`dependencies`),labels:bt,onChange:jt})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:v.dependents}),C.dependents.length>0?(0,V.jsx)(`div`,{className:`space-y-1.5`,children:C.dependents.map(e=>(0,V.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,V.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:v.noDependents})]})]})]})]})]})]}),(0,V.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(rt),tabIndex:0,onPointerDown:At,onKeyDown:kt,onDoubleClick:()=>Ot(Ve),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 ${at?`bg-surface-hover`:``}`,children:(0,V.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,V.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,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,V.jsx)(`div`,{className:`min-w-0`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Kt?(0,V.jsx)(M,{agentId:Kt,avatar:qt?.avatar,size:28,className:`shrink-0`}):null,(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,V.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[qt?.name??Kt??v.unassigned,` · `,It]})]})]})}),t===`modal`?un:null]}),Gt?(0,V.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,V.jsx)(L,{embedded:!0,sessionKey:Gt,taskId:e})}):we?(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,V.jsxs)(`div`,{className:`max-w-xs`,children:[(0,V.jsx)(ve,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,V.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):Ee?(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,V.jsxs)(`div`,{className:`max-w-xs`,children:[(0,V.jsx)(ve,{className:`mx-auto size-8 text-danger`}),(0,V.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,V.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:Ee instanceof Error?Ee.message:String(Ee)})]})}):(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,V.jsxs)(`div`,{className:`max-w-xs`,children:[(0,V.jsx)(ve,{className:`mx-auto size-8 text-fg-subtle`}),(0,V.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,V.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,V.jsx)(Se,{open:vt,title:v.deleteTaskTitle,description:v.deleteTaskDescription.replace(`{{title}}`,C.task.title),confirmLabel:v.confirmDeleteTask,cancelLabel:v.keepTask,destructive:!0,onConfirm:()=>{yt(!1),Nt()},onCancel:()=>yt(!1)})]})}function Ke(){let e=(0,B.c)(2),{taskId:t}=a(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,V.jsx)(Ge,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function qe(e){let t=(0,B.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=ee(q),{data:o}=oe(n),s=o?.conversation.activeSessionKey??null,l=E(et),u=E($e),d=E(Qe),f=E(K),m=pe(Ze),h=se(Xe),g=se(Ye),b=l?u:0,x;t[0]!==i||t[1]!==g?(x=e=>{e||(g(null),i())},t[0]=i,t[1]=g,t[2]=x):x=t[2];let S=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]!==S||t[7]!==w?(T=(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":S,onClick:w}),t[6]=S,t[7]=w,t[8]=T):T=t[8];let ce=l?`true`:`false`,le=`${b/2}px`,ue=`${b}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,D=a===`zh`?`任务详情`:`Task details`,O;t[12]===D?O=t[13]:(O=(0,V.jsx)(ae,{className:`font-medium text-fg`,children:D}),t[12]=D,t[13]=O);let me=a===`zh`?`查看并操作任务详情`:`View and manage task details`,k;t[14]===me?k=t[15]:(k=(0,V.jsx)(te,{className:`sr-only`,children:me}),t[14]=me,t[15]=k);let A;t[16]!==s||t[17]!==a||t[18]!==f||t[19]!==m||t[20]!==n||t[21]!==l||t[22]!==d?(A=s?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:y(`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,V.jsx)(_,{className:`size-4`,"aria-hidden":!0})}),(0,V.jsx)(c,{to:Te(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,V.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]=A):A=t[23];let he=a===`zh`?`关闭任务详情`:`Close task details`,ge;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,V.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[24]=ge):ge=t[24];let j;t[25]===he?j=t[26]:(j=(0,V.jsx)(ne,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":he,children:ge}),t[25]=he,t[26]=j);let M;t[27]!==A||t[28]!==j?(M=(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[A,j]}),t[27]=A,t[28]=j,t[29]=M):M=t[29];let N;t[30]!==O||t[31]!==k||t[32]!==M?(N=(0,V.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[O,k,M]}),t[30]=O,t[31]=k,t[32]=M,t[33]=N):N=t[33];let P;t[34]!==i||t[35]!==g?(P=()=>{g(null),i()},t[34]=i,t[35]=g,t[36]=P):P=t[36];let F;t[37]!==r||t[38]!==P||t[39]!==n?(F=(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,V.jsx)(Ge,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:P})}),t[37]=r,t[38]=P,t[39]=n,t[40]=F):F=t[40];let I;t[41]!==N||t[42]!==F||t[43]!==ce||t[44]!==fe?(I=(0,V.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:Je,onInteractOutside:G,children:[N,F]}),t[41]=N,t[42]=F,t[43]=ce,t[44]=fe,t[45]=I):I=t[45];let L;t[46]!==h||t[47]!==l||t[48]!==u||t[49]!==d?(L=h?(0,V.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,V.jsx)(we,{allowOutsideChat:!0,sessionKey:d??void 0})}):null,t[46]=h,t[47]=l,t[48]=u,t[49]=d,t[50]=L):L=t[50];let R;t[51]!==I||t[52]!==L||t[53]!==T?(R=(0,V.jsxs)(re,{children:[T,I,L]}),t[51]=I,t[52]=L,t[53]=T,t[54]=R):R=t[54];let _e;return t[55]!==x||t[56]!==R?(_e=(0,V.jsx)(C,{modal:!1,open:!0,onOpenChange:x,children:R}),t[55]=x,t[56]=R,t[57]=_e):_e=t[57],_e}function G(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Je(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Ye(e){return e.setPath}function Xe(e){return e.path}function Ze(e){return e.setOpen}function K(e){return e.openForSession}function Qe(e){return e.sessionKeyOverride}function $e(e){return e.widthPx}function et(e){return e.open}function q(e){return e.language}function tt(e){return(0,V.jsx)(u,{value:e.id,children:e.name||e.id},e.id)}function nt(e){return e.id}export{qe as TaskDetailModal,Ke as TaskDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{f as e}from"./locale-store-DVzTJSj2.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#f7f8fa`,emerald:`#f0fdf4`,mono:`#ffffff`,clay:`#fffaf0`},dark:{default:`#14171c`,emerald:`#000000`,mono:`#101010`,clay:`#0a1a1a`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e==="default"||e===`emerald`||e===`mono`||e===`clay`?e:n}function l(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function u(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}l(o(t),r,!1)}catch{l(o(`system`),`default`,!1)}}var d=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();l(r,a,r!==i),e({preference:n,resolved:r})},setColorScheme:n=>{let{resolved:r}=t();l(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function f(){let{preference:e,colorScheme:t}=d.getState(),n=o(e);l(n,t,!1),d.setState({resolved:n})}function p(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=d.getState();if(e!==`system`)return;let n=o(`system`),r=d.getState().resolved;l(n,t,n!==r),d.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{d as i,p as n,f as r,u as t};
|
|
@@ -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-_tYhRAHD.js";import{a as d,i as f,n as ee,r as p,s as te}from"./locale-store-C5wr3_pc.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-Bxe_R-JH.js";import{Bi as _,Yo as v,Ys as y}from"./index-7i2P3312.js";import{n as re,t as ie}from"./settings-form-section-DjWzRk4z.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-_tYhRAHD.js";import{a as d,i as f,n as ee,r as p,s as te}from"./locale-store-DVzTJSj2.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-HT7sLeO9.js";import{Bi as _,Yo as v,Ys as y}from"./index-J3FsIvTs.js";import{n as re,t as ie}from"./settings-form-section-DjWzRk4z.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};
|
package/dist/gateway/static/root/assets/{use-autosave-W_P8Kiv4.js → use-autosave-PSV89QuQ.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{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-
|
|
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-DVzTJSj2.js";import{wl as c}from"./index-J3FsIvTs.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};
|